From 6f6f7f2efb9432efe7d3b4f749022da2cfc39fb3 Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Wed, 19 Dec 2018 19:13:08 +0100 Subject: iputils: add 'src' and 'gw' parameters to iproute_del() Rework iproute_del() to have the same parameters as iproute_add(). This will allow callers to specify more precisely the route they want to delete. Callers will later be converted to make use of these parameters to ensure that the removed route precisely matches the one that was originaly inserted. Signed-off-by: Guillaume Nault --- accel-pppd/libnetlink/iputils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'accel-pppd/libnetlink/iputils.c') diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c index 343088f..5f830f0 100644 --- a/accel-pppd/libnetlink/iputils.c +++ b/accel-pppd/libnetlink/iputils.c @@ -500,7 +500,7 @@ int __export iproute_add(int ifindex, in_addr_t src, in_addr_t dst, in_addr_t gw return r; } -int __export iproute_del(int ifindex, in_addr_t dst, int proto, int mask, uint32_t prio) +int __export iproute_del(int ifindex, in_addr_t src, in_addr_t dst, in_addr_t gw, int proto, int mask, uint32_t prio) { struct ipaddr_req { struct nlmsghdr n; @@ -525,12 +525,15 @@ int __export iproute_del(int ifindex, in_addr_t dst, int proto, int mask, uint32 req.i.rtm_type = RTN_UNICAST; req.i.rtm_dst_len = mask; - addattr32(&req.n, sizeof(req), RTA_DST, dst); - if (ifindex) addattr32(&req.n, sizeof(req), RTA_OIF, ifindex); + if (src) + addattr32(&req.n, sizeof(req), RTA_PREFSRC, src); + if (gw) + addattr32(&req.n, sizeof(req), RTA_GATEWAY, gw); if (prio) addattr32(&req.n, sizeof(req), RTA_PRIORITY, prio); + addattr32(&req.n, sizeof(req), RTA_DST, dst); if (rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0) < 0) r = -1; -- cgit v1.2.3