Rainer Clasen wrote:
> Chris Parker wrote:
> > Realm/proxy failover is still a newer feature. You're probably best
> > off making changes to get it doing what you want, and posting a patch.
> > That will likely spark off some additional patches/work, as well.
>
> While writing the following patch, I realised, it might be quit easy to make
> the behavior optional. So I might find some time and add this, too.
There was some spare time and I made this configurable.
I hope the supplied context diff is ok. Solaris diff doesn't know
unified diffs and the previosly used cvs diff output isn't that good,
isn't it?
--
KeyID=759975BD fingerprint=887A 4BE3 6AB7 EE3C 4AE0 B0E1 0556 E25A 7599 75BD
*** freeradius-2002-02-11/raddb/proxy.conf Mon Feb 11 20:56:48 2002
--- freeradius-local/raddb/proxy.conf Fri Feb 15 20:56:52 2002
***************
*** 68,73 ****
--- 68,85 ----
# (60 to 3600)
#
dead_time = 120
+
+
+ #
+ # If all exact matching servers didn't respond, we can try the
+ # DEFAULT realm, too.
+ #
+ # When using Gric, you don't want to fall back to the Default entry,
+ # but you might have one allmighty server, who knows better and this
+ # one should retry the request.
+ #
+ default_fallback = no
+
}
#######################################################################
diff -cr freeradius-2002-02-11/src/include/radiusd.h
freeradius-local//src/include/radiusd.h
*** freeradius-2002-02-11/src/include/radiusd.h Mon Feb 11 20:56:36 2002
--- freeradius-local//src/include/radiusd.h Fri Feb 15 20:36:00 2002
***************
*** 190,195 ****
--- 190,196 ----
extern int proxyfd;
extern int proxy_retry_count;
extern int proxy_retry_delay;
+ extern int proxy_fallback;
extern int spawn_flag;
extern const char *radiusd_version;
diff -cr freeradius-2002-02-11/src/main/files.c freeradius-local//src/main/files.c
*** freeradius-2002-02-11/src/main/files.c Mon Feb 11 20:56:36 2002
--- freeradius-local//src/main/files.c Fri Feb 15 20:36:00 2002
***************
*** 508,513 ****
--- 508,515 ----
(ipaddr == cl->acct_ipaddr)) {
cl->active = FALSE;
cl->wakeup = now + proxy_dead_time;
+ radlog(L_PROXY, "marking server %s for realm %s dead",
+ cl->server, cl->realm);
}
}
***************
*** 519,524 ****
--- 521,527 ----
REALM *cl;
REALM *default_realm = NULL;
time_t now;
+ unsigned int exact_matches = 0;
now = time(NULL);
***************
*** 539,555 ****
}
/*
! * It's not alive, skip it.
*/
! if (!cl->active) {
! continue;
}
/*
! * If it matches exactly, return it.
*/
! if (strcmp(cl->realm, realm) == 0) {
! return cl;
}
/*
--- 542,570 ----
}
/*
! * If it matches exactly, ...
*/
! if (strcmp(cl->realm, realm) == 0) {
! exact_matches++;
!
! /*
! * It's not alive, skip it.
! */
! if (!cl->active) {
! continue;
! }
!
! /*
! * otherwise return it
! */
! return cl;
}
/*
! * It's not alive, skip it.
*/
! if (!cl->active) {
! continue;
}
/*
***************
*** 557,567 ****
*/
if ((default_realm == NULL) &&
(strcmp(cl->realm, "DEFAULT") == 0)) {
! default_realm = cl;
}
} /* loop over all realms */
/*
* Didn't find anything that matched exactly, return
* the default.
*/
--- 572,595 ----
*/
if ((default_realm == NULL) &&
(strcmp(cl->realm, "DEFAULT") == 0)) {
! default_realm = cl;
}
} /* loop over all realms */
/*
+ * there were exact matches, but all weren't alive.
+ * don't fall through to the DEFAULT realm
+ */
+ if (exact_matches) {
+ if (proxy_fallback) {
+ radlog(L_PROXY, "all servers for realm %s are dead, trying
+DEFAULT", realm);
+ } else {
+ radlog(L_PROXY, "all servers for realm %s are dead", realm);
+ return NULL;
+ }
+ }
+
+ /*
* Didn't find anything that matched exactly, return
* the default.
*/
diff -cr freeradius-2002-02-11/src/main/radiusd.c freeradius-local//src/main/radiusd.c
*** freeradius-2002-02-11/src/main/radiusd.c Mon Feb 11 20:56:37 2002
--- freeradius-local//src/main/radiusd.c Fri Feb 15 20:36:00 2002
***************
*** 110,115 ****
--- 110,116 ----
int proxy_retry_count = RETRY_COUNT;
int proxy_dead_time = DEAD_TIME;
int proxy_synchronous = FALSE;
+ int proxy_fallback = FALSE;
int need_reload = FALSE;
struct main_config_t mainconfig;
const char *radiusd_version = "FreeRADIUS Version " RADIUSD_VERSION ", for host "
HOSTINFO ", built on " __DATE__ " at " __TIME__;
***************
*** 165,170 ****
--- 166,172 ----
{ "retry_delay", PW_TYPE_INTEGER, 0, &proxy_retry_delay,
Stringify(RETRY_DELAY) },
{ "retry_count", PW_TYPE_INTEGER, 0, &proxy_retry_count,
Stringify(RETRY_COUNT) },
{ "synchronous", PW_TYPE_BOOLEAN, 0, &proxy_synchronous, "no" },
+ { "default_fallback", PW_TYPE_BOOLEAN, 0, &proxy_fallback, "no" },
{ "dead_time", PW_TYPE_INTEGER, 0, &proxy_dead_time, Stringify(DEAD_TIME) },
{ NULL, -1, 0, NULL, NULL }
};
diff -cr freeradius-2002-02-11/src/main/radwho.c freeradius-local//src/main/radwho.c
*** freeradius-2002-02-11/src/main/radwho.c Mon Feb 11 20:56:37 2002
--- freeradius-local//src/main/radwho.c Fri Feb 15 20:36:00 2002
***************
*** 75,80 ****
--- 75,81 ----
const char *radutmp_file = NULL;
int proxy_synchronous = TRUE;
+ int proxy_fallback = FALSE;
const char *radius_dir = NULL;
const char *radacct_dir = NULL;
const char *radlib_dir = NULL;
diff -cr freeradius-2002-02-11/src/main/radzap.c freeradius-local//src/main/radzap.c
*** freeradius-2002-02-11/src/main/radzap.c Mon Feb 11 20:56:37 2002
--- freeradius-local//src/main/radzap.c Fri Feb 15 20:36:00 2002
***************
*** 50,55 ****
--- 50,56 ----
const char *radlib_dir = NULL;
int debug_flag = 0;
int proxy_synchronous = TRUE;
+ int proxy_fallback = FALSE;
int auth_port = 0;
int acct_port;
int proxy_retry_delay = RETRY_DELAY;
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html