svn commit: samba r5411 - in branches/SAMBA_4_0/source: lib/netif nbt_server smbd torture/nbt

tridge at samba.org tridge at samba.org
Wed Feb 16 01:48:12 GMT 2005


Author: tridge
Date: 2005-02-16 01:48:11 +0000 (Wed, 16 Feb 2005)
New Revision: 5411

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

Log:
make network interface selection a bit saner

- if we have no configured network interfaces, then don't start nbtd (when I add dynamic
  interface loading this will change to a delay until a network interface comes up)

- choose the best interface by netmask for torture tests that need a
  specific IP (such as the WINS test). Added iface_best_ip() for that.

- if specific interfaces are chosen in smb.conf, then keep that ordering, and 
  default to the first one listed


Modified:
   branches/SAMBA_4_0/source/lib/netif/interface.c
   branches/SAMBA_4_0/source/nbt_server/nbt_server.c
   branches/SAMBA_4_0/source/smbd/process_single.c
   branches/SAMBA_4_0/source/smbd/service_task.c
   branches/SAMBA_4_0/source/torture/nbt/register.c
   branches/SAMBA_4_0/source/torture/nbt/wins.c
   branches/SAMBA_4_0/source/torture/nbt/winsbench.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/netif/interface.c
===================================================================
--- branches/SAMBA_4_0/source/lib/netif/interface.c	2005-02-15 12:53:58 UTC (rev 5410)
+++ branches/SAMBA_4_0/source/lib/netif/interface.c	2005-02-16 01:48:11 UTC (rev 5411)
@@ -94,7 +94,7 @@
 	iface->nmask = tov4(nmask);
 	iface->bcast.addr = MKBCADDR(iface->ip.addr, iface->nmask.addr);
 
-	DLIST_ADD(local_interfaces, iface);
+	DLIST_ADD_END(local_interfaces, iface, struct interface *);
 
 	DEBUG(2,("added interface ip=%s ",sys_inet_ntoa(iface->ip)));
 	DEBUG(2,("bcast=%s ",sys_inet_ntoa(iface->bcast)));
@@ -339,3 +339,18 @@
 	return NULL;
 }
 
+/*
+  return the local IP address that best matches a destination IP, or
+  our first interface if none match
+*/
+const char *iface_best_ip(const char *dest)
+{
+	struct interface *iface;
+	struct in_addr ip;
+	ip.s_addr = interpret_addr(dest);
+	iface = iface_find(ip, True);
+	if (iface) {
+		return sys_inet_ntoa(iface->ip);
+	}
+	return iface_n_ip(0);
+}

Modified: branches/SAMBA_4_0/source/nbt_server/nbt_server.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/nbt_server.c	2005-02-15 12:53:58 UTC (rev 5410)
+++ branches/SAMBA_4_0/source/nbt_server/nbt_server.c	2005-02-16 01:48:11 UTC (rev 5411)
@@ -34,6 +34,11 @@
 	struct nbtd_server *nbtsrv;
 	NTSTATUS status;
 
+	if (iface_count() == 0) {
+		task_terminate(task, "nbtd: no network interfaces configured");
+		return;
+	}
+
 	nbtsrv = talloc(task, struct nbtd_server);
 	if (nbtsrv == NULL) {
 		task_terminate(task, "nbtd: out of memory");

Modified: branches/SAMBA_4_0/source/smbd/process_single.c
===================================================================
--- branches/SAMBA_4_0/source/smbd/process_single.c	2005-02-15 12:53:58 UTC (rev 5410)
+++ branches/SAMBA_4_0/source/smbd/process_single.c	2005-02-16 01:48:11 UTC (rev 5411)
@@ -74,6 +74,7 @@
 /* called when a task goes down */
 static void single_terminate(struct event_context *ev, const char *reason) 
 {
+	DEBUG(2,("single_terminate: reason[%s]\n",reason));
 }
 
 static const struct model_ops single_ops = {

Modified: branches/SAMBA_4_0/source/smbd/service_task.c
===================================================================
--- branches/SAMBA_4_0/source/smbd/service_task.c	2005-02-15 12:53:58 UTC (rev 5410)
+++ branches/SAMBA_4_0/source/smbd/service_task.c	2005-02-16 01:48:11 UTC (rev 5411)
@@ -32,6 +32,7 @@
 {
 	struct event_context *event_ctx = task->event_ctx;
 	const struct model_ops *model_ops = task->model_ops;
+	DEBUG(0,("task_terminate: [%s]\n", reason));
 	talloc_free(task);
 	model_ops->terminate(event_ctx, reason);
 }

Modified: branches/SAMBA_4_0/source/torture/nbt/register.c
===================================================================
--- branches/SAMBA_4_0/source/torture/nbt/register.c	2005-02-15 12:53:58 UTC (rev 5410)
+++ branches/SAMBA_4_0/source/torture/nbt/register.c	2005-02-16 01:48:11 UTC (rev 5411)
@@ -49,7 +49,7 @@
 	NTSTATUS status;
 	struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL);
 	BOOL ret = True;
-	const char *myaddress = iface_n_ip(0);
+	const char *myaddress = iface_best_ip(address);
 
 	socket_listen(nbtsock->sock, myaddress, 0, 0, 0);
 
@@ -114,7 +114,7 @@
 	NTSTATUS status;
 	struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL);
 	BOOL ret = True;
-	const char *myaddress = iface_n_ip(0);
+	const char *myaddress = iface_best_ip(address);
 
 	socket_listen(nbtsock->sock, myaddress, 0, 0, 0);
 

Modified: branches/SAMBA_4_0/source/torture/nbt/wins.c
===================================================================
--- branches/SAMBA_4_0/source/torture/nbt/wins.c	2005-02-15 12:53:58 UTC (rev 5410)
+++ branches/SAMBA_4_0/source/torture/nbt/wins.c	2005-02-16 01:48:11 UTC (rev 5411)
@@ -60,7 +60,7 @@
 	NTSTATUS status;
 	struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL);
 	BOOL ret = True;
-	const char *myaddress = talloc_strdup(mem_ctx, iface_n_ip(0));
+	const char *myaddress = talloc_strdup(mem_ctx, iface_best_ip(address));
 
 	/* we do the listen here to ensure the WINS server receives the packets from
 	   the right IP */

Modified: branches/SAMBA_4_0/source/torture/nbt/winsbench.c
===================================================================
--- branches/SAMBA_4_0/source/torture/nbt/winsbench.c	2005-02-15 12:53:58 UTC (rev 5410)
+++ branches/SAMBA_4_0/source/torture/nbt/winsbench.c	2005-02-16 01:48:11 UTC (rev 5411)
@@ -231,7 +231,7 @@
 	state->num_names = torture_entries;
 	state->registered = talloc_zero_array(state, BOOL, state->num_names);
 	state->wins_server = address;
-	state->my_ip = talloc_strdup(mem_ctx, iface_n_ip(0));
+	state->my_ip = talloc_strdup(mem_ctx, iface_best_ip(address));
 	state->ttl = timelimit;
 
 	socket_listen(nbtsock->sock, state->my_ip, 0, 0, 0);



More information about the samba-cvs mailing list