summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2019-06-25 13:41:24 +0200
committerStephen Hemminger <stephen@networkplumber.org>2019-06-26 14:27:00 -0700
commitb5cf263670dc13a8f56cbe3a45fef08a0420a494 (patch)
tree6e0bc738176e012e383b8dbc1278e6098f6611eb
parent5a403866f3691e1c2a1b7c7b677e9a7feeec0aa2 (diff)
downloadiproute2-devlink-pr.tar.gz
iproute: Set flags and attributes on dump to get IPv6 cached routes to be flusheddevlink-pr
With a current (5.1) kernel version, IPv6 exception routes can't be listed (ip -6 route list cache) or flushed (ip -6 route flush cache). Kernel support for this is being added back. Relevant net-next commits: 564c91f7e563 fib_frontend, ip6_fib: Select routes or exceptions dump from RTM_F_CLONED ef11209d4219 Revert "net/ipv6: Bail early if user only wants cloned entries" 3401bfb1638e ipv6/route: Don't match on fc_nh_id if not set in ip6_route_del() bf9a8a061ddc ipv6/route: Change return code of rt6_dump_route() for partial node dumps 1e47b4837f3b ipv6: Dump route exceptions if requested 40cb35d5dc04 ip6_fib: Don't discard nodes with valid routing information in fib6_locate_1() However, to allow the kernel to filter routes based on the RTM_F_CLONED flag, we need to make sure this flag is always passed when we want cached routes to be dumped, and we can also pass table and output interface attributes to have the kernel filtering on them, if requested by the user. Use the existing iproute_dump_filter() as a filter for the dump request in iproute_flush(). This way, 'ip -6 route flush cache' works again. v2: Instead of creating a separate 'filter' function dealing with RTM_F_CACHED only, use the existing iproute_dump_filter() and get table and oif kernel filtering for free. Suggested by David Ahern. Fixes: aba5acdfdb34 ("(Logical change 1.3)") Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
-rw-r--r--ip/iproute.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/ip/iproute.c b/ip/iproute.c
index 2b3dcc5d..1669e013 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -1602,6 +1602,30 @@ static int save_route_prep(void)
return 0;
}
+static int iproute_dump_filter(struct nlmsghdr *nlh, int reqlen)
+{
+ struct rtmsg *rtm = NLMSG_DATA(nlh);
+ int err;
+
+ rtm->rtm_protocol = filter.protocol;
+ if (filter.cloned)
+ rtm->rtm_flags |= RTM_F_CLONED;
+
+ if (filter.tb) {
+ err = addattr32(nlh, reqlen, RTA_TABLE, filter.tb);
+ if (err)
+ return err;
+ }
+
+ if (filter.oif) {
+ err = addattr32(nlh, reqlen, RTA_OIF, filter.oif);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
static int iproute_flush(int family, rtnl_filter_t filter_fn)
{
time_t start = time(0);
@@ -1624,7 +1648,7 @@ static int iproute_flush(int family, rtnl_filter_t filter_fn)
filter.flushe = sizeof(flushb);
for (;;) {
- if (rtnl_routedump_req(&rth, family, NULL) < 0) {
+ if (rtnl_routedump_req(&rth, family, iproute_dump_filter) < 0) {
perror("Cannot send dump request");
return -2;
}
@@ -1664,30 +1688,6 @@ static int iproute_flush(int family, rtnl_filter_t filter_fn)
}
}
-static int iproute_dump_filter(struct nlmsghdr *nlh, int reqlen)
-{
- struct rtmsg *rtm = NLMSG_DATA(nlh);
- int err;
-
- rtm->rtm_protocol = filter.protocol;
- if (filter.cloned)
- rtm->rtm_flags |= RTM_F_CLONED;
-
- if (filter.tb) {
- err = addattr32(nlh, reqlen, RTA_TABLE, filter.tb);
- if (err)
- return err;
- }
-
- if (filter.oif) {
- err = addattr32(nlh, reqlen, RTA_OIF, filter.oif);
- if (err)
- return err;
- }
-
- return 0;
-}
-
static int iproute_list_flush_or_save(int argc, char **argv, int action)
{
int dump_family = preferred_family;