[SAMBA4] Failed to bind to 255.255.255.255:138

Oleg Sharoiko os at rsu.ru
Mon Jan 9 12:24:02 GMT 2006


Hello!

Samba4 (I've checked r12785 and some earlier revisions) gives me an error 
(FreeBSD 6.0):

Failed to bind to 255.255.255.255:138 - NT_STATUS_ADDRESS_NOT_ASSOCIATED
Failed to setup dgram listen on 0.0.0.0 - NT_STATUS_ADDRESS_NOT_ASSOCIATED
task_server_terminate: [nbtd failed to setup interfaces]

This happens if 'bind interfaces only' is not set, when nbtd_dgram_setup() 
is called for pseudo interface 0.0.0.0. In this case nbtd_dgram_setup() 
tries to bind to 255.255.255.255, which is a broadcast address of that 
pseudo interface. Shouldn't nbtd_dgram_setup() have a check to not bind to 
broadcast address of pseudo interface similar to the check implemented in 
nbtd_add_socket() ?

Something like this:

Index: nbt_server/dgram/request.c
===================================================================
--- nbt_server/dgram/request.c	(revision 12786)
+++ nbt_server/dgram/request.c	(working copy)
@@ -56,25 +56,27 @@
 */
 NTSTATUS nbtd_dgram_setup(struct nbtd_interface *iface, const char *bind_address)
 {
-	struct nbt_dgram_socket *bcast_dgmsock;
+	struct nbt_dgram_socket *bcast_dgmsock = NULL;
 	struct nbtd_server *nbtsrv = iface->nbtsrv;
 	NTSTATUS status;
 	/* the list of mailslots that we are interested in */
 	int i;
 
 	/* listen for broadcasts on port 138 */
-	bcast_dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx);
-	NT_STATUS_HAVE_NO_MEMORY(bcast_dgmsock);
+	if (strcmp(iface->netmask, "0.0.0.0") != 0) {
+		bcast_dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx);
+		NT_STATUS_HAVE_NO_MEMORY(bcast_dgmsock);
 	
-	status = socket_listen(bcast_dgmsock->sock, iface->bcast_address, 
-			       lp_dgram_port(), 0, 0);
-	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(0,("Failed to bind to %s:%d - %s\n", 
-			 iface->bcast_address, lp_dgram_port(), nt_errstr(status)));
-		return status;
+		status = socket_listen(bcast_dgmsock->sock, iface->bcast_address, 
+			       	lp_dgram_port(), 0, 0);
+		if (!NT_STATUS_IS_OK(status)) {
+			DEBUG(0,("Failed to bind to %s:%d - %s\n", 
+			 	iface->bcast_address, lp_dgram_port(), nt_errstr(status)));
+			return status;
+		}
+	
+		dgram_set_incoming_handler(bcast_dgmsock, dgram_request_handler, iface);
 	}
-	
-	dgram_set_incoming_handler(bcast_dgmsock, dgram_request_handler, iface);
 
 	/* listen for unicasts on port 138 */
 	iface->dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx);
@@ -96,10 +98,12 @@
 		   we need */
 		struct dgram_mailslot_handler *dgmslot;
 
-		dgmslot = dgram_mailslot_listen(bcast_dgmsock, 
-						mailslot_handlers[i].mailslot_name,
-						mailslot_handlers[i].handler, iface);
-		NT_STATUS_HAVE_NO_MEMORY(dgmslot);
+		if (bcast_dgmsock != NULL) {
+			dgmslot = dgram_mailslot_listen(bcast_dgmsock, 
+							mailslot_handlers[i].mailslot_name,
+							mailslot_handlers[i].handler, iface);
+			NT_STATUS_HAVE_NO_MEMORY(dgmslot);
+		}
 
 		dgmslot = dgram_mailslot_listen(iface->dgmsock, 
 						mailslot_handlers[i].mailslot_name,

-- 
Oleg Sharoiko.
Software and Network Engineer
Computer Center of Rostov State University.


More information about the samba-technical mailing list