NetBIOS keepalive causing Windows to reset connection on NetBIOS connection on port 139

Christopher R. Hertel crh at ubiqx.mn.org
Sat Sep 1 15:36:13 GMT 2007


Derrell Lipman wrote:
> libsmbclient periodically checks whether a cached connection is still
> alive.  Traditionally, it did this using a NetBIOS keepalive request.
> Fairly recently, I made changes because a NetBIOS keepalive is
> inappropriate when using naked transport (typically over port 445).
> The test we used (as inaccurate as it is) was to use a keepalive
> request if the connection was using port 139, and a getpeername() call
> otherwise.
> 
> Today, I encountered a NAS device that resets a connection upon
> receiving a NetBIOS keepalive request even though the request is
> issued on port 139 and after it previously responded to a NBSS Session
> Request with a NBSS Positive Session Response.  Sigh.

Ugh.  Seems they've forgotten how NBT is supposed to work.

> The NAS device identifies itself as: Microsoft(R) Windows(R) Server
> 2003 Standard x64 Edition Version 5.2.3790 Service Pack 1 Build 3790,
> R2.  This problem does not exhibit itself on the w2k3 servers I've
> tested against in the past.
> 
> I am looking for any reason why the NetBIOS keepalive request should
> not be stripped entirely out of this code, and replaced with
> getpeername() in all cases.  Can anyone explain why this would not be
> an appropriate change in libsmbclient?

I went back to my book to see what I'd written about this.

  RFC 1001 makes it clear that sending the NBT Session Service Keepalive
  message is optional. TCP itself also has a keepalive mechanism, which
  should be used instead, if possible."

So I think the getpeername(3p) approach makes a lot of sense.

It also simplifies things a whole lot, since you'd no longer need to
determine which transport is in use.

Digging through some old IBM manuals, my guess is that support for the
NetBIOS keepalive was included in RFC1001/1002 because it was part of the
original NetBIOS system.  Not supporting the keepalive would have caused
incompatibilities with existing code that used the NetBIOS API.

Still, the failure of that particular Windows version to handle the packet
correctly is a bug.

Hope that helps.

Chris -)-----

-- 
"Implementing CIFS - the Common Internet FileSystem" ISBN: 013047116X
Samba Team -- http://www.samba.org/     -)-----   Christopher R. Hertel
jCIFS Team -- http://jcifs.samba.org/   -)-----   ubiqx development, uninq.
ubiqx Team -- http://www.ubiqx.org/     -)-----   crh at ubiqx.mn.org
OnLineBook -- http://ubiqx.org/cifs/    -)-----   crh at ubiqx.org


More information about the samba-technical mailing list