libsmbclient: Vista servers disconnect on netbios keepalive message on port 445

derrell at samba.org derrell at samba.org
Sun Dec 24 02:35:42 GMT 2006


"elupus" <elupus at xboxmediacenter.com> writes:

> If libsmbclient is connected to a vista server on port 445, only every
> second command will work. Before every command libsmbclient tries to verify
> that the server is valid by sending it a SMBkeepalive. However this is a
> netbios packet and can't be used on port 445 (smb over tcp). It seems
> previous windows version ignored this, vista however disconnects the client
> on such an invalid request.
>
> I changed the smbc_check_server to only do the keepalive when connected on
> port 139, sorry for this not being a patch, but I currently don't have any
> checked out version of samba. The alternative is to use cli_echo, but
> waiting for a roundtrip before trying to do anything seems overkill. 
>
> The proper solution would be to do a retry on a failed request instead of
> the current way if checking connection prior to doing the actual request.
> But that is abit to much work for me.

Please post the above text and code snippet with your fix, as a bugzilla bug.
Mark it as a libsmbclient bug, and I'll take a look at it when I get a chance
(hopefully reasonably soon).  I'll discuss with others whether there are
alternative methods to solve the problem.

Thanks for tracking that down!

Derrell


> Cheers
>
>
> /Joakim
>
> static int
> smbc_check_server(SMBCCTX * context,
>                   SMBCSRV * server) 
> {
>     if (server->cli.port == 139)
>     {
> 		if ( send_keepalive(server->cli.fd) == False )
> 			return 1;
>     }
>     else
>     {
> 		/* can't send netbios keepalive over raw tcp samba sockets
> */
> 		struct sockaddr addr;
> 		int size = sizeof(addr);
> 		if (getpeername(server->cli.fd, &addr, &size))
> 			return 1;
>     }
>
>
> 	/* connection is ok */
> 	return 0;
> }
>

-- 


More information about the samba-technical mailing list