diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-05-13 13:16:06 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-05-13 13:16:06 +0400 |
commit | ec41e172a9da0de7cf5c28027928c698d0d1ebf8 (patch) | |
tree | 017eb8e5a65e421ac4ccb93039ffafedea2873b2 /accel-pppd/radius | |
parent | e7b98bc79bf8e01d6e2897a95502827ce2a83e7d (diff) | |
download | accel-ppp-ec41e172a9da0de7cf5c28027928c698d0d1ebf8.tar.gz accel-ppp-ec41e172a9da0de7cf5c28027928c698d0d1ebf8.zip |
radius: introduced weight and backup per-server options
New options are applied to server option as server=...[,weight=x][,backup]
Weight is used for multi-server configurations (larger weight takes more users).
Backup is used to mark backup server f.e. server which will be used only if all other servers are failed.
Diffstat (limited to 'accel-pppd/radius')
-rw-r--r-- | accel-pppd/radius/radius_p.h | 2 | ||||
-rw-r--r-- | accel-pppd/radius/serv.c | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/accel-pppd/radius/radius_p.h b/accel-pppd/radius/radius_p.h index 4654c78d..f6262135 100644 --- a/accel-pppd/radius/radius_p.h +++ b/accel-pppd/radius/radius_p.h @@ -82,6 +82,7 @@ struct rad_server_t { time_t fail_time; int conf_fail_time; int timeout_cnt; + double weight; pthread_mutex_t lock; unsigned long stat_auth_sent; @@ -107,6 +108,7 @@ struct rad_server_t { struct stat_accm_t *stat_interim_query_1m; struct stat_accm_t *stat_interim_query_5m; + int backup:1; int starting:1; int acct_on:1; int need_free:1; diff --git a/accel-pppd/radius/serv.c b/accel-pppd/radius/serv.c index 6a080709..46d064a0 100644 --- a/accel-pppd/radius/serv.c +++ b/accel-pppd/radius/serv.c @@ -63,7 +63,7 @@ static struct rad_server_t *__rad_server_get(int type, struct rad_server_t *excl continue; } - if (s->client_cnt[type] < s0->client_cnt[type]) + if (s0->backup || s->weight*s->client_cnt[type] < s0->weight*s0->client_cnt[type]) s0 = s; } @@ -648,6 +648,18 @@ static int parse_server2(const char *_opt, struct rad_server_t *s) goto out; } else s->conf_fail_time = conf_fail_time; + + ptr3 = strstr(ptr2, ",weight="); + if (ptr3) + s->weight = 1.0/atoi(ptr3 + 8); + else + s->weight = 1; + + ptr3 = strstr(ptr2, ",backup"); + if (ptr3) + s->backup = 1; + else + s->backup = 0; if (ptr2) *ptr2 = 0; |