svn commit: samba r5259 - in branches/SAMBA_4_0/source/nbt_server: .

tridge at samba.org tridge at samba.org
Mon Feb 7 11:49:55 GMT 2005


Author: tridge
Date: 2005-02-07 11:49:55 +0000 (Mon, 07 Feb 2005)
New Revision: 5259

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5259

Log:
make sure we give the ip of the interface that a name query comes in
on as the first IP in a multi-homed reply


Modified:
   branches/SAMBA_4_0/source/nbt_server/interfaces.c
   branches/SAMBA_4_0/source/nbt_server/query.c
   branches/SAMBA_4_0/source/nbt_server/winsclient.c


Changeset:
Modified: branches/SAMBA_4_0/source/nbt_server/interfaces.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/interfaces.c	2005-02-07 10:35:00 UTC (rev 5258)
+++ branches/SAMBA_4_0/source/nbt_server/interfaces.c	2005-02-07 11:49:55 UTC (rev 5259)
@@ -234,18 +234,35 @@
 
 /*
   form a list of addresses that we should use in name query replies
+  we always place the IP in the given interface first
 */
-const char **nbtd_address_list(struct nbtd_server *nbtsrv, TALLOC_CTX *mem_ctx)
+const char **nbtd_address_list(struct nbtd_interface *iface, TALLOC_CTX *mem_ctx)
 {
+	struct nbtd_server *nbtsrv = iface->nbtsrv;
 	const char **ret = NULL;
-	struct nbtd_interface *iface;
-	int count = 0;
+	struct nbtd_interface *iface2;
+	int count;
 
-	for (iface=nbtsrv->interfaces;iface;iface=iface->next) {
-		const char **ret2 = talloc_realloc(mem_ctx, ret, const char *, count+2);
+	ret = talloc_array(mem_ctx, const char *, 2);
+	if (ret == NULL) goto failed;
+
+	ret[0] = talloc_strdup(ret, iface->ip_address);
+	if (ret[0] == NULL) goto failed;
+	ret[1] = NULL;
+
+	count = 1;
+
+	for (iface2=nbtsrv->interfaces;iface2;iface2=iface2->next) {
+		const char **ret2;
+
+		if (strcmp(iface2->ip_address, iface->ip_address) == 0) {
+			continue;
+		}
+
+		ret2 = talloc_realloc(mem_ctx, ret, const char *, count+2);
 		if (ret2 == NULL) goto failed;
 		ret = ret2;
-		ret[count] = talloc_strdup(ret, iface->ip_address);
+		ret[count] = talloc_strdup(ret, iface2->ip_address);
 		if (ret[count] == NULL) goto failed;
 		count++;
 	}

Modified: branches/SAMBA_4_0/source/nbt_server/query.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/query.c	2005-02-07 10:35:00 UTC (rev 5258)
+++ branches/SAMBA_4_0/source/nbt_server/query.c	2005-02-07 11:49:55 UTC (rev 5259)
@@ -129,5 +129,5 @@
 
 	nbtd_name_query_reply(nbtsock, packet, src_address, src_port,
 			      &iname->name, iname->ttl, iname->nb_flags, 
-			      nbtd_address_list(iface->nbtsrv, packet));
+			      nbtd_address_list(iface, packet));
 }

Modified: branches/SAMBA_4_0/source/nbt_server/winsclient.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/winsclient.c	2005-02-07 10:35:00 UTC (rev 5258)
+++ branches/SAMBA_4_0/source/nbt_server/winsclient.c	2005-02-07 11:49:55 UTC (rev 5259)
@@ -107,7 +107,7 @@
 	/* setup a wins name refresh request */
 	io.in.name            = iname->name;
 	io.in.wins_servers    = lp_wins_server_list();
-	io.in.addresses       = nbtd_address_list(iface->nbtsrv, iname);
+	io.in.addresses       = nbtd_address_list(iface, iname);
 	io.in.nb_flags        = iname->nb_flags;
 	io.in.ttl             = iname->ttl;
 



More information about the samba-cvs mailing list