--- /dev/null
+<samba:parameter name="msdfs shuffle referrals"
+ context="S"
+ type="boolean"
+ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+ <para>If set to <constant>yes</constant>, Samba will shuffle
+ Dfs referrals for a given Dfs link if multiple are available,
+ allowing for load balancing across clients. For more information
+ on setting up a Dfs tree on Samba, refer to the MSDFS chapter in
+ the Samba3-HOWTO book.</para>
+</description>
+
+<related>host msdfs</related>
+<related>msdfs root</related>
+<value type="default">no</value>
+</samba:parameter>
MSDFS services for Samba
Copyright (C) Shirish Kalele 2000
Copyright (C) Jeremy Allison 2007
+ Copyright (C) Robin McCorkell 2015
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
return NT_STATUS_OK;
}
+static void shuffle_strlist(char **list, int count)
+{
+ int i, r;
+ char *tmp;
+
+ srandom(time(NULL));
+
+ for (i = count; i > 1; i--) {
+ r = random() % i;
+
+ tmp = list[i-1];
+ list[i-1] = list[r];
+ list[r] = tmp;
+ }
+}
+
/**********************************************************************
Parse the contents of a symlink to verify if it is an msdfs referral
A valid referral is of the form:
**********************************************************************/
static bool parse_msdfs_symlink(TALLOC_CTX *ctx,
+ int snum,
const char *target,
struct referral **preflist,
int *refcount)
count++;
}
+ /* shuffle alternate paths */
+ if (lp_msdfs_shuffle_referrals(snum)) {
+ shuffle_strlist(alt_path, count);
+ }
+
DEBUG(10,("parse_msdfs_symlink: count=%d\n", count));
if (count) {
return NT_STATUS_NO_MEMORY;
}
- if (!parse_msdfs_symlink(ctx, tmp, &ref, &refcount)) {
+ if (!parse_msdfs_symlink(ctx, snum, tmp, &ref, &refcount)) {
TALLOC_FREE(tmp);
TALLOC_FREE(pdp);
return NT_STATUS_INVALID_PARAMETER;
}
/* We know this is a valid dfs link. Parse the targetpath. */
- if (!parse_msdfs_symlink(ctx, targetpath,
+ if (!parse_msdfs_symlink(ctx, snum, targetpath,
&jucn->referral_list,
&jucn->referral_count)) {
DEBUG(3,("get_referred_path: failed to parse symlink "
conn,
dname, &link_target,
NULL)) {
- if (parse_msdfs_symlink(ctx,
+ if (parse_msdfs_symlink(ctx, snum,
link_target,
&jucn[cnt].referral_list,
&jucn[cnt].referral_count)) {