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 | |
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')
-rw-r--r-- | accel-pppd/accel-ppp.conf | 5 | ||||
-rw-r--r-- | accel-pppd/accel-ppp.conf.5 | 8 | ||||
-rw-r--r-- | accel-pppd/radius/radius_p.h | 2 | ||||
-rw-r--r-- | accel-pppd/radius/serv.c | 14 |
4 files changed, 23 insertions, 6 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index b833aae2..2cec7d74 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -138,10 +138,7 @@ interface=eth0 nas-identifier=accel-ppp nas-ip-address=127.0.0.1 gw-ip-address=192.168.100.1 -#auth-server=127.0.0.1:1812,testing123 (obsolete) -#acct-server=127.0.0.1:1813,testing123 (obsolete) -#server=127.0.0.1,testing123 (obsolete) -server=127.0.0.1,testing123,auth-port=1812,acct-port=1813,req-limit=0,fail-time=0 +server=127.0.0.1,testing123,auth-port=1812,acct-port=1813,req-limit=0,fail-time=0,weight=1 dae-server=127.0.0.1:3799,testing123 verbose=1 #timeout=3 diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5 index 0b3ac31d..c386f772 100644 --- a/accel-pppd/accel-ppp.conf.5 +++ b/accel-pppd/accel-ppp.conf.5 @@ -578,7 +578,7 @@ Specifies IP address, port and secret of authentication RADIUS server. (obsolete .BI "acct-server=" x.x.x.x:port,secret Specifies IP address, port and secret of accounting RADIUS server. (obsolete) .TP -.BI "server=" address,secret[,auth-port=1812][,acct-port=1813][,req-limit=0][,fail-time=0] +.BI "server=" address,secret[,auth-port=1812][,acct-port=1813][,req-limit=0][,fail-time=0][,weight=1][,backup] Specifies IP address, secret, ports of RADIUS server. .br .B req-limit @@ -587,6 +587,12 @@ Specifies IP address, secret, ports of RADIUS server. .B fail-time - if server doesn't responds mark it as unavailable for this time (sec). .br +.B weight +- specifies weight of server for multi-server configuration. +.br +.B backup +- mark server as backup server f.e. use this server only when all other servers are failed. +.br If you want to specify only authentication or accounting server then set auth-port/acct-port to zero. You may specify multiple radius servers. .TP 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; |