From 6e150a7ca507869df7b639e1a80ba101b1d5771a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 30 Aug 2000 17:34:35 +0000 Subject: Fix for bind interfaces only sometimes picking the wrong IP address for a name query. From Steve Langasek . Jeremy. (This used to be commit 9890740121ae7bd7a0196bbf946c6f8c82aa7f6e) --- source3/nmbd/nmbd_packets.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'source3/nmbd') diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c index 05b75e984e..cf00dc9083 100644 --- a/source3/nmbd/nmbd_packets.c +++ b/source3/nmbd/nmbd_packets.c @@ -699,8 +699,30 @@ struct response_record *queue_query_name( struct subnet_record *subrec, subrec->bcast_ip)) == NULL) return NULL; - if(initiate_name_query_packet( p ) == False) - { + if(lp_bind_interfaces_only()) { + int i; + + DEBUG(10,("queue_query_name: bind_interfaces_only is set, looking for suitable source IP\n")); + for(i = 0; i < iface_count(); i++) { + struct in_addr *ifip = iface_n_ip(i); + + if(ifip == NULL) { + DEBUG(0,("queue_query_name: interface %d has NULL IP address !\n", i)); + continue; + } + + if (ip_equal(*ifip,loopback_ip)) { + DEBUG(5,("queue_query_name: ignoring loopback interface (%d)\n", i)); + continue; + } + + DEBUG(10,("queue_query_name: using source IP %s\n",inet_ntoa(*ifip))); + p->fd = find_subnet_fd_for_address( *ifip ); + break; + } + } + + if(initiate_name_query_packet( p ) == False) { p->locked = False; free_packet(p); return NULL; -- cgit