From 4ade925f6be2b16d443941c13007d9cd0e47a8e6 Mon Sep 17 00:00:00 2001 From: aland Date: Mon, 16 Jul 2007 14:37:15 +0000 Subject: [PATCH] Added "keyed-balance", which allows load balancing based on anything the administrator cares to think about. --- raddb/proxy.conf | 11 ++++++++++- share/dictionary.freeradius.internal | 1 + src/include/radius.h | 1 + src/include/realms.h | 3 ++- src/main/realms.c | 10 ++++++++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/raddb/proxy.conf b/raddb/proxy.conf index a6e4d93..7e0ec2a 100644 --- a/raddb/proxy.conf +++ b/raddb/proxy.conf @@ -369,6 +369,16 @@ server_pool my_auth_failover { # also means that authentication and accounting packets # for the same session MAY go to different home servers. # + # keyed-balance - the home server is chosen by hashing (FNV) + # the contents of the Load-Balance-Key attribute from the + # control items. The request is then sent to home server + # chosen by taking: + # + # server = (hash % num_servers_in_pool). + # + # If there is no Load-Balance-Key in the control items, + # the load balancing method is identical to "load-balance". + # type = fail-over # @@ -500,4 +510,3 @@ realm LOCAL { # accthost = radius.company.com:1601 # secret = testing123 #} - diff --git a/share/dictionary.freeradius.internal b/share/dictionary.freeradius.internal index 1241b7f..d051bc5 100644 --- a/share/dictionary.freeradius.internal +++ b/share/dictionary.freeradius.internal @@ -60,6 +60,7 @@ ATTRIBUTE EAP-Code 1021 integer # used only be radeapclient. It's been replaced by Cleartext-Password ATTRIBUTE PEAP-Version 1023 integer ATTRIBUTE Client-Shortname 1024 string +ATTRIBUTE Load-Balance-Key 1025 string # # Range: 1025-1028 diff --git a/src/include/radius.h b/src/include/radius.h index 65d53f7..af85ac1 100644 --- a/src/include/radius.h +++ b/src/include/radius.h @@ -144,6 +144,7 @@ #define PW_EAP_TYPE 1018 #define PW_EAP_TLS_REQUIRE_CLIENT_CERT 1019 #define PW_CLIENT_SHORTNAME 1024 +#define PW_LOAD_BALANCE_KEY 1025 #define PW_USER_CATEGORY 1029 #define PW_GROUP_NAME 1030 diff --git a/src/include/realms.h b/src/include/realms.h index 846c18a..c712aee 100644 --- a/src/include/realms.h +++ b/src/include/realms.h @@ -71,7 +71,8 @@ typedef enum home_pool_type_t { HOME_POOL_LOAD_BALANCE, HOME_POOL_FAIL_OVER, HOME_POOL_CLIENT_BALANCE, - HOME_POOL_CLIENT_PORT_BALANCE + HOME_POOL_CLIENT_PORT_BALANCE, + HOME_POOL_KEYED_BALANCE } home_pool_type_t; diff --git a/src/main/realms.c b/src/main/realms.c index 9d29f8b..e61527c 100644 --- a/src/main/realms.c +++ b/src/main/realms.c @@ -544,6 +544,7 @@ static int server_pool_add(CONF_SECTION *cs, int server_type, int do_print) { "fail_over", HOME_POOL_FAIL_OVER }, { "client-balance", HOME_POOL_CLIENT_BALANCE }, { "client-port-balance", HOME_POOL_CLIENT_PORT_BALANCE }, + { "keyed-balance", HOME_POOL_KEYED_BALANCE }, { NULL, 0 } }; @@ -1162,6 +1163,7 @@ home_server *home_server_ldb(const char *realmname, int start; int count; home_server *found = NULL; + VALUE_PAIR *vp; start = 0; @@ -1215,6 +1217,14 @@ home_server *home_server_ldb(const char *realmname, start = hash % pool->num_home_servers; break; + case HOME_POOL_KEYED_BALANCE: + if ((vp = pairfind(request->config_items, PW_LOAD_BALANCE_KEY)) != NULL) { + hash = lrad_hash(vp->vp_strvalue, vp->length); + start = hash % pool->num_home_servers; + break; + } + /* FALL-THROUGH */ + case HOME_POOL_LOAD_BALANCE: found = pool->servers[0]; -- 2.1.4