[Accel-ppp-users] [RFC PATCH 7/7] ipoe: stricter route deletion
Status: Beta
Brought to you by:
xebd
|
From: Guillaume N. <g....@al...> - 2018-12-19 18:13:32
|
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 <g....@al...>
---
Sending as RFC, as I couldn't test this patch beyond compilation.
Setting the source here looks quite logical, but an external review
would be in order.
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);
}
}
--
2.20.1
|