diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2015-07-08 21:29:33 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2015-07-08 21:29:33 +0300 |
commit | 27579436f1f9aaec0e477d36cb6b75a35af42517 (patch) | |
tree | 952c7e8b6b81a3ab2d77271066283dbcaa8894bb | |
parent | 75edc5199bfcf7c83079b58990760f3de57680ec (diff) | |
parent | 215cb6354e6b4cae1c9b8262fd3ad04ac88ea21d (diff) | |
download | accel-ppp-27579436f1f9aaec0e477d36cb6b75a35af42517.tar.gz accel-ppp-27579436f1f9aaec0e477d36cb6b75a35af42517.zip |
Merge branch 'master' of ssh://git.code.sf.net/p/accel-ppp/code
-rw-r--r-- | accel-pppd/accel-ppp.conf | 1 | ||||
-rw-r--r-- | accel-pppd/accel-ppp.conf.5 | 3 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/dhcpv4.c | 5 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 19 | ||||
-rw-r--r-- | accel-pppd/ifcfg.c | 2 |
5 files changed, 23 insertions, 7 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index 3568872..3102e20 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -137,6 +137,7 @@ start=dhcpv4 #idle-timeout=0 #session-timeout=0 #soft-terminate=0 +#check-mac-change=1 interface=eth0 diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5 index 773bfe5..b5c5e88 100644 --- a/accel-pppd/accel-ppp.conf.5 +++ b/accel-pppd/accel-ppp.conf.5 @@ -387,6 +387,9 @@ By default vlan-name=%I.%N. .TP .BI "soft-terminate=" 0|1 Turns on soft terminate mode. Soft terminate means that session won't be terminated immediately, but when next lease renewal request will be received. +.TP +.BI "check-mac-change=" 0|1 +If enabled accel-ppp will terminate session when detects change of mac address of client (by default it is enabled). .SH [dns] .TP .BI "dns1=" x.x.x.x diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c index 21a62f5..f58a49a 100644 --- a/accel-pppd/ctrl/ipoe/dhcpv4.c +++ b/accel-pppd/ctrl/ipoe/dhcpv4.c @@ -155,6 +155,11 @@ struct dhcpv4_serv *dhcpv4_create(struct triton_context_t *ctx, const char *ifna goto out_err; } + if (setsockopt(sock, SOL_SOCKET, SO_NO_CHECK, &f, sizeof(f))) { + log_error("setsockopt(SO_NO_CHECK): %s\n", strerror(errno)); + goto out_err; + } + if (bind(sock, &addr, sizeof(addr))) { log_error("bind: %s\n", strerror(errno)); goto out_err; diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 765996f..81c4df3 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -150,6 +150,7 @@ static int conf_proto; static LIST_HEAD(conf_offer_delay); static const char *conf_vlan_name; static int conf_ip_unnumbered; +static int conf_check_mac_change; static int conf_soft_terminate; static unsigned int stat_starting; @@ -199,13 +200,13 @@ static struct ipoe_session *ipoe_session_lookup(struct ipoe_serv *serv, struct d if (opt82_ses) *opt82_ses = NULL; - if (pack->relay_agent && dhcpv4_parse_opt82(pack->relay_agent, &agent_circuit_id, &agent_remote_id)) { + if (!conf_check_mac_change || (pack->relay_agent && dhcpv4_parse_opt82(pack->relay_agent, &agent_circuit_id, &agent_remote_id))) { agent_circuit_id = NULL; agent_remote_id = NULL; } list_for_each_entry(ses, &serv->sessions, entry) { - opt82_match = pack->relay_agent != NULL; + opt82_match = conf_check_mac_change && pack->relay_agent != NULL; if (agent_circuit_id && !ses->agent_circuit_id) opt82_match = 0; @@ -1322,7 +1323,7 @@ static void ipoe_ses_recv_dhcpv4(struct dhcpv4_serv *dhcpv4, struct dhcpv4_packe opt82_match = 0; } - if (pack->relay_agent && !opt82_match) { + if (conf_check_mac_change && pack->relay_agent && !opt82_match) { log_ppp_info2("port change detected\n"); if (pack->msg_type == DHCPREQUEST) dhcpv4_send_nak(dhcpv4, pack); @@ -1595,7 +1596,7 @@ static void __ipoe_recv_dhcpv4(struct dhcpv4_serv *dhcpv4, struct dhcpv4_packet goto out; } - if ((opt82_ses && ses != opt82_ses) || (!opt82_ses && pack->relay_agent)) { + if (conf_check_mac_change && ((opt82_ses && ses != opt82_ses) || (!opt82_ses && pack->relay_agent))) { dhcpv4_packet_ref(pack); triton_context_call(&ses->ctx, (triton_event_func)port_change_detected, pack); if (opt82_ses) @@ -1634,7 +1635,7 @@ static void __ipoe_recv_dhcpv4(struct dhcpv4_serv *dhcpv4, struct dhcpv4_packet goto out; } - if ((opt82_ses && ses != opt82_ses) || (!opt82_ses && pack->relay_agent)) { + if (conf_check_mac_change && ((opt82_ses && ses != opt82_ses) || (!opt82_ses && pack->relay_agent))) { dhcpv4_packet_ref(pack); triton_context_call(&ses->ctx, (triton_event_func)port_change_detected, pack); if (opt82_ses) @@ -2931,7 +2932,7 @@ static void add_vlan_mon(const char *opt, long *mask) for (ptr = opt; *ptr && *ptr != ','; ptr++); - if (ptr - opt >= sizeof(ifr.ifr_name)) { + if (ptr - opt >= IFNAMSIZ) { log_error("ipoe: vlan-mon=%s: interface name is too long\n", opt); return; } @@ -3281,6 +3282,12 @@ static void load_config(void) else conf_soft_terminate = 0; + opt = conf_get_opt("ipoe", "check-mac-change"); + if (opt) + conf_check_mac_change = atoi(opt); + else + conf_check_mac_change = 1; + #ifdef RADIUS if (triton_module_loaded("radius")) load_radius_attrs(); diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c index 5c828a7..77a3732 100644 --- a/accel-pppd/ifcfg.c +++ b/accel-pppd/ifcfg.c @@ -265,7 +265,7 @@ int __export ap_session_rename(struct ap_session *ses, const char *ifname, int l if (len == -1) len = strlen(ifname); - if (len >= IFNAMSIZ - 1) { + if (len >= IFNAMSIZ) { log_ppp_warn("cannot rename interface (name is too long)\n"); return -1; } |