WINS server incorrectly ignores 127.0.0.1 requests

Peter Hurley phurley at imaginexd.com
Mon Feb 17 14:43:05 GMT 2003


This is an additional followup email to my original (13 Feb of same
title).

I believe I have uncovered the root cause of many seemingly unrelated
slowdowns.

In nmbd/nmbd_packets.c, function listen_for_packets(), lines #1847~1860
(as of 2.2.7a source), reads:

     if(lp_bind_interfaces_only() && (sock_array[i] == ClientNMB) &&
        (!is_local_net(packet->ip))) {
             DEBUG(7,("discarding nmb packet sent to broadcast socket
from %s:%d\n",
                      inet_ntoa(packet->ip),packet->port));
             free_packet(packet);
     } else if (ip_equal(loopback_ip, packet->ip) && packet->port ==
global_nmb_port) {
             DEBUG(7,("discarding own packet from %s:%d\n",
                      inet_ntoa(packet->ip),packet->port));
             free_packet(packet);
     } else {
             /* Save the file descriptor this packet came in on. */
             packet->fd = sock_array[i];
             queue_packet(packet);
     }

This is done while receiving packets from port 137.  The problem is that
if,
     bind interfaces only = true
     interfaces = 192.168.1.0/24
then, NMBD will discard any packets from local SMBDs (ie., 127.0.0.1).

To see how this slows down the system, use the following configuration
(a lot of installations are like this):
		[global]
		security = user
		wins support = yes
		bind interfaces only = true
            interfaces = 192.168.1.0/24
Any name lookups passing through resolve_wins() will attempt 3 times to
send packets to 127.0.0.1:137.  All of these packets will time out
because they will match the conditions that resulting in "discarding nmb
packet sent to broadcast socket....".  

This will result in > 6 sec. slowdown every time. (BTW, similar code
sequence exists for port 138 but I'm not sure if that's an issue.)

As a temporary solution, setting interfaces = to include 127.0.0.0/8
works, but has side effects (such as spawning SMBD to listen on
127.0.0.1:139).

Two possible code solutions:
1) is_local_net() always return true for 127.0.0.1 ip.  This would
certain match the semantics, but is_local_net is used in two other
functions (both looking for the DMB), and might have unintentional
consequences.
2) replace the code sequence above with,
     BOOL is_loopback = ip_equal(loopback_ip, packet->ip);
     if (!is_loopback && lp_bind_interfaces_only() && (sock_array[i] ==
ClientNMB) &&
        (!is_local_net(packet->ip))) {
             DEBUG(7,("discarding nmb packet sent to broadcast socket
from %s:%d\n",
                      inet_ntoa(packet->ip),packet->port));
             free_packet(packet);
     } else if (is_loopback && packet->port == global_nmb_port) {
             DEBUG(7,("discarding own packet from %s:%d\n",
                      inet_ntoa(packet->ip),packet->port));
             free_packet(packet);
     } else {
             /* Save the file descriptor this packet came in on. */
             packet->fd = sock_array[i];
             queue_packet(packet);
     }

Thanks,

Peter Hurley
phurley at imaginexd.com	

PS - I don't have a development environment or I would have changed this
myself and tested it.



More information about the samba-technical mailing list