From 2910add2238d419ad82e43f3ebf1fb8d5708e13b Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Wed, 19 Dec 2018 19:13:22 +0100 Subject: ipoe: stricter route deletion Rework the conditionals to make __ipoe_session_activate() and ipoe_session_finished() follow the same logic: * Drop the second '!serv->opt_ifcfg' test in __ipoe_session_activate(), which is is already checked by the parent conditional. * Invert the order of the tests in ipoe_session_finished(), so that it uses the same conditions as __ipoe_session_activate(). Finally, set the 'src' parameter in iproute_del(), so that we can be sure that the deleted route matches the one added by __ipoe_session_activate(). Signed-off-by: Guillaume Nault --- accel-pppd/ctrl/ipoe/ipoe.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 0fe16ae1..eb06e7b7 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -981,9 +981,9 @@ static void __ipoe_session_activate(struct ipoe_session *ses) ap_session_activate(&ses->ses); if (ses->ifindex == -1 && !serv->opt_ifcfg) { - if (serv->opt_ip_unnumbered == 0) + if (!serv->opt_ip_unnumbered) iproute_add(serv->ifindex, ses->router, ses->yiaddr, 0, conf_proto, ses->mask, 0); - else if (!serv->opt_ifcfg) + else iproute_add(serv->ifindex, serv->opt_src ?: ses->router, ses->yiaddr, 0, conf_proto, 32, 0); } @@ -1166,10 +1166,10 @@ static void ipoe_session_finished(struct ap_session *s) ipoe_nl_delete(ses->ifindex); } else if (ses->started) { if (!serv->opt_ifcfg) { - if (serv->opt_ip_unnumbered) - iproute_del(serv->ifindex, 0, ses->yiaddr, 0, conf_proto, 32, 0); + if (!serv->opt_ip_unnumbered) + iproute_del(serv->ifindex, ses->router, ses->yiaddr, 0, conf_proto, ses->mask, 0); else - iproute_del(serv->ifindex, 0, ses->yiaddr, 0, conf_proto, ses->mask, 0); + iproute_del(serv->ifindex, serv->opt_src ?: ses->router, ses->yiaddr, 0, conf_proto, 32, 0); } } -- cgit v1.2.3