]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip rule: Honor filter arguments on flush
authorDavid Ahern <dsahern@gmail.com>
Tue, 30 Oct 2018 20:58:56 +0000 (13:58 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 1 Nov 2018 19:49:48 +0000 (12:49 -0700)
'ip ru flush' currently removes all rules with priority > 0 regardless
of any other command line arguments passed in. Update flush_rule to
call filter_nlmsg to determine if the rule should be flushed or not.
This enables rule flushing such as 'ip ru flush table 1001' and
'ip ru flush pref 99'.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/iprule.c

index d89d808d89095d3e958bd02f14ceaec76d25d1ac..74805b6cea2aa558b09de5496eac7ac9f5d9e3e4 100644 (file)
@@ -461,6 +461,7 @@ static int flush_rule(struct nlmsghdr *n, void *arg)
        struct fib_rule_hdr *frh = NLMSG_DATA(n);
        int len = n->nlmsg_len;
        struct rtattr *tb[FRA_MAX+1];
+       int host_len = -1;
 
        len -= NLMSG_LENGTH(sizeof(*frh));
        if (len < 0)
@@ -468,6 +469,10 @@ static int flush_rule(struct nlmsghdr *n, void *arg)
 
        parse_rtattr(tb, FRA_MAX, RTM_RTA(frh), len);
 
+       host_len = af_bit_len(frh->family);
+       if (!filter_nlmsg(n, tb, host_len))
+               return 0;
+
        if (tb[FRA_PROTOCOL]) {
                __u8 protocol = rta_getattr_u8(tb[FRA_PROTOCOL]);