libsmb: reuse connections derived from DFS referrals
authorDavid Disseldorp <ddiss@samba.org>
Fri, 16 Jan 2015 15:21:22 +0000 (16:21 +0100)
committerKarolin Seeger <kseeger@samba.org>
Thu, 29 Jan 2015 20:15:10 +0000 (21:15 +0100)
commit2856b641f321ecfd430fef24cd1158c0e2a1dd01
treeab940e4a6b3933a667f89d478a3d228be718f0f6
parentf9693a1766b88ce068bb04c88f1a41ce3330e2cc
libsmb: reuse connections derived from DFS referrals

[MS-DFSC] 3.2.1.1 and 3.2.1.2 states that DFS targets with the same site
location or relative cost are placed in random order in a DFS referral
response.

libsmbclient currently resolves DFS referrals on every API call, always
using the first entry in the referral response. With random ordering,
libsmbclient may open a new server connection, rather than reuse an
existing (cached) connection established in a previous DFS referred API
call.

This change sees libsmbclient check the connection cache for any of the
DFS referral response entries before creating a new connection.

This change is based on a patch by Har Gagan Sahai
<SHarGagan@novell.com>.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=10123

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 7b7d4f740fe5017107d3100041cc8c7982f0eac7)
[ddiss@samba.org: 4.0 rebase without smbXcli_tcon context]
source3/libsmb/clidfs.c