From 2883c323268800fc09fe1535d12528c8f054904d Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Thu, 2 Jul 2015 15:01:37 +0300 Subject: ipoe: introduced option "check-mac-change" Default behaviour of accel-ppp when it receives DHCP request with same Option 82 but different MAC address is termination of old session (with previous MAC address). This option can turn off such behaviour, so multiple sessions with same Option 82 but different MAC may coesist. --- accel-pppd/ctrl/ipoe/ipoe.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'accel-pppd/ctrl') diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 765996f7..1f904bf6 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) @@ -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(); -- cgit v1.2.3 From d5b314539669e2d13af8bc638dfbaa0516ca10ea Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Tue, 7 Jul 2015 17:31:53 +0300 Subject: ipoe: disable udp checksum validation --- accel-pppd/ctrl/ipoe/dhcpv4.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'accel-pppd/ctrl') diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c index 21a62f58..f58a49a7 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; -- cgit v1.2.3 From 215cb6354e6b4cae1c9b8262fd3ad04ac88ea21d Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Tue, 7 Jul 2015 17:43:26 +0300 Subject: fixed check for interface name length --- accel-pppd/ctrl/ipoe/ipoe.c | 2 +- accel-pppd/ifcfg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'accel-pppd/ctrl') diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 1f904bf6..81c4df30 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -2932,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; } diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c index 5c828a78..77a37321 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; } -- cgit v1.2.3