[PATCH - 1/1] libsmb: Sending smb echo or keepalive request on the cached connection before re-using

Har Gagan Sahai shargagan at novell.com
Mon Feb 2 22:18:30 MST 2015


Hi Stefan, 

Thanks for reviewing the patch and providing detailed explanation about it. 

In libsmbclient with SMBv2 we noticed the session handle reuse was failing with error NT_STATUS_CONNECTION_RESET. This session re-use is happening sometimes in less than one minute of last use. After some readings I found this link http://blogs.msdn.com/b/openspecification/archive/2013/03/27/smb-2-x-and-smb-3-0-timeouts-in-windows.aspx and in that the explanation about session expiration timer tells that it is about 45 secs. It could be an old explanation altogether but with that I could correlate to the behavior I am noticing. And with the proposed patch the issue seemed to be resolving. But as you are suggesting it is not the right approach, I will try to work on the suggested change that would work in this case. 

Also can you please guide me if samba 4 based libsmbclient library has ( or plan to) support of durable handles ? As that seems to be exactly what would be required in this case. 

Thanks again, 
Har Gagan Sahai

>>> "Stefan (metze) Metzmacher" <metze at samba.org> 2/3/2015 5:12 AM >>>
Hi Har Gagan

thanks for the patch, but I fear it's not the correct approach.
See below.

>  The ( https://bugzilla.samba.org/show_bug.cgi?id=11079.The ) issue is with libsmbclient, which is using the cached connection part of SMBC context without checking for its alive status. We noticed this issue while using libsmbclient against 2008R2 (SMB2). 
>
>
> [MS-SMB2]  3.3.2.3 Session Expiration Timer - 
> This timer controls the periodic scheduling of searching for sessions that have passed their expiration time. The server SHOULD<172> schedule this timer such that sessions are expired in a timely manner. This timer is also used for scavenging connections on which the NEGOTIATE and SESSION_SETUP have not been performed within a specified time.
>
> This timer is typically 45 secs. Because of 45 secs of session expiration timer, if the SMBC context is reused after 45 secs anytime, the cached connection is picked without checking for its connection status. In that case the SMB call done on that connection fails with NT_STATUS_CONNECTION_RESET error.

Sessions don't expire after 45 seconds, typically 8 or 10 hours.

We need to do a reauthentication before the session expires
or when we get NT_STATUS_NETWORK_SESSION_EXPIRED.

Sending echos before each single request doesn't help.

> This patch is attempting to address the issue. After doing this change, the SMBC_check_server() will returns '1', when the connection is closed during time expiration processing on the server. When that happens, SMBC_find_server() which had called SMBC_check_server(), will return 'NULL' for the 'srv' to the SMBC_server_internal(). In that case the function will attempt to re-create the connection, so that the client is not impacted.

If the connection gets disconnected, we need to replay operations on
after a reconnect.

metze



More information about the samba-technical mailing list