summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/accel-ppp.conf2
-rw-r--r--accel-pppd/accel-ppp.conf.56
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c28
-rw-r--r--accel-pppd/ppp/ipcp_opt_ipaddr.c11
4 files changed, 40 insertions, 7 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index 929402b..530c341 100644
--- a/accel-pppd/accel-ppp.conf
+++ b/accel-pppd/accel-ppp.conf
@@ -40,6 +40,7 @@ thread-count=4
#sid-case=upper
#sid-source=seq
#max-sessions=1000
+#check-ip=0
[ppp]
verbose=1
@@ -49,7 +50,6 @@ mru=1400
#accomp=deny
#pcomp=deny
#ccp=0
-#check-ip=0
#mppe=require
ipv4=require
ipv6=deny
diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5
index 15becb3..52cd1e6 100644
--- a/accel-pppd/accel-ppp.conf.5
+++ b/accel-pppd/accel-ppp.conf.5
@@ -122,6 +122,9 @@ Path to file for sessions sequence number. Start sequence number may be set ther
.TP
.BI "max-sessions=" n
Specifies maximum sessions which server may processed (default 0, disabled)
+.TP
+.BI "check-ip=" 0|1
+Specifies whether accel-ppp should check if IP already assigned to other ppp interface (default 0).
.SH [ppp]
.br
PPP module configuration.
@@ -159,9 +162,6 @@ Protocol field compression negotiation.
.BI "ccp=" n
Disable CCP negotiation if this parameter is zero.
.TP
-.BI "check-ip=" 0|1
-Specifies whether accel-ppp should check if IP already assigned to other ppp interface (default 0).
-.TP
.BI "mppe=" require|prefer|deny
Specifies mppe negotiation preference.
.br
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 5438b61..9880162 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -107,6 +107,7 @@ struct local_net {
enum {SID_MAC, SID_IP};
+static int conf_check_exists;
static int conf_dhcpv4 = 1;
static int conf_up;
static int conf_auto;
@@ -577,6 +578,24 @@ static int ipoe_create_interface(struct ipoe_session *ses)
return 0;
}
+static int check_exists(struct ipoe_session *self_ipoe, in_addr_t addr)
+{
+ struct ap_session *ses;
+ int r = 0;
+
+ pthread_rwlock_rdlock(&ses_lock);
+ list_for_each_entry(ses, &ses_list, entry) {
+ if (!ses->terminating && ses->ipv4 && ses->ipv4->peer_addr == addr && ses != &self_ipoe->ses) {
+ log_ppp_warn("ipoe: IPv4 address already assigned to %s\n", ses->ifname);
+ r = 1;
+ break;
+ }
+ }
+ pthread_rwlock_unlock(&ses_lock);
+
+ return r;
+}
+
static void auth_result(struct ipoe_session *ses, int r)
{
char *username = ses->username;
@@ -617,6 +636,11 @@ static void auth_result(struct ipoe_session *ses, int r)
ap_session_set_username(&ses->ses, username);
log_ppp_info1("%s: authentication succeeded\n", ses->ses.username);
+ if (conf_check_exists && check_exists(ses, ses->yiaddr)){
+ ap_session_terminate(&ses->ses, TERM_NAS_REQUEST, 1);
+ return;
+ }
+
cont:
triton_event_fire(EV_SES_AUTHORIZED, &ses->ses);
@@ -3930,6 +3954,10 @@ static void load_config(void)
else
conf_weight = 0;
+ opt = conf_get_opt("common", "check-ip");
+ if (opt && atoi(opt) >= 0)
+ conf_check_exists = atoi(opt) > 0;
+
#ifdef RADIUS
if (triton_module_loaded("radius"))
load_radius_attrs();
diff --git a/accel-pppd/ppp/ipcp_opt_ipaddr.c b/accel-pppd/ppp/ipcp_opt_ipaddr.c
index 7bac55b..03eb418 100644
--- a/accel-pppd/ppp/ipcp_opt_ipaddr.c
+++ b/accel-pppd/ppp/ipcp_opt_ipaddr.c
@@ -171,9 +171,14 @@ static void load_config(void)
{
const char *opt;
- opt = conf_get_opt("ppp", "check-ip");
- if (opt && atoi(opt) >= 0)
- conf_check_exists = atoi(opt) > 0;
+ opt = conf_get_opt("common", "check-ip");
+ if (opt && atoi(opt) > 0)
+ conf_check_exists = atoi(opt);
+ else {
+ opt = conf_get_opt("ppp", "check-ip");
+ if (opt && atoi(opt) >= 0)
+ conf_check_exists = atoi(opt) > 0;
+ }
}
static void ipaddr_opt_init()