DMB registration bug: query sent from wrong interface
vorlon at netexpress.net
Tue Aug 29 19:15:41 GMT 2000
Cc'ing samba-technical, as this may be of interest there as well.
On Tue, 29 Aug 2000, Steve Langasek wrote:
> Closer inspection shows that the query sent to the wins server for the
> DOMAIN<1b> name, to see if the name is already registered, is being sent from
> the wrong interface. I have 'interfaces = 22.214.171.124/24' and
> 'bind interfaces only = yes' in my smb.conf file, and all other communications
> with the WINS server happen on the right interface; but for some reason, this
> query uses interface eth0 for its source IP. Since this copy of nmbd isn't
> listening on that interface (another copy of nmbd is), nmbd never receives the
> reply, which results in the 'Error 0' in become_domain_master_query_fail().
> I'm going to see if I can find the bug in the code, but in the meantime I
> figured I'd post the information here in case anyone else wanted to take a
> crack at it :)
To follow up on my own post, I've found that registrations, refreshes, and
releases of names all work correctly. This is easy: the packets being sent
contain the IP information we need to correctly choose an interface, so the
packet is sent out with an appropriate source IP. With a query, on the other
hand, there is no obvious "right" IP to bind to when sending the packet; all
we care about is that our query makes it to the WINS server, and the WINS
server's response makes it back to us. So nmbd uses the socket that's bound
to INADDR_ANY (0.0.0.0). This lets the OS choose the source IP to use when
sending the outgoing packet -- and in at least some cases, it's choosing the
'wrong' one, because it's using the primary IP for my Linux box. That IP has
another copy of nmbd running on it, and the response packet sent by the WINS
server disappears into the void.
What's the right way to make nmbd talk to the WINS server using the
appropriate source IP when 'interfaces' and 'bind interfaces only' are
configured? A comment I found talks about 'socket address' being a deprecated
option, so it looks like this was used at one point but later abandoned. I
could add code to queue_query_name() in nmbd/nmbd_packets.c to check for
bind_interfaces_only, and use one of the interface sockets instead of the
broadcast socket. Would this be better than what nmbd does now, or would that
cause other problems? The big problem I see is that nmbd might choose to send
the packet from an interface that doesn't have a route to the WINS server.
That wouldn't be a problem for me personally, but I don't want to trade one
bug in the code for another. :) Anyone have any thoughts on this?
More information about the samba-technical