]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
route: filter routes by family if it's specified
authorAndrew Vagin <avagin@openvz.org>
Wed, 23 Sep 2015 11:43:46 +0000 (14:43 +0300)
committerStephen Hemminger <shemming@brocade.com>
Wed, 23 Sep 2015 23:16:19 +0000 (16:16 -0700)
Currently when we specify AF_INET6 when it is disabled, we will get
all routes.

For example, we can boot kernel with ipv6.disable=1 and try to get ipv6
routes:
$ ip -6 route show
default via 192.168.122.1 dev eth0  proto static  metric 100
192.168.122.0/24 dev eth0  proto kernel  scope link  src 192.168.122.141  metric 100

Here are ipv4 routes and this is unexpected behaviour.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
ip/iproute.c

index abe41803e251615bddc504b0a5395b9a23a8b743..da25548c5464b6ea7d5c7a856d49e20b4930ea79 100644 (file)
@@ -145,6 +145,9 @@ static int filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len)
 
        table = rtm_get_table(r, tb);
 
+       if (preferred_family != AF_UNSPEC && r->rtm_family != preferred_family)
+               return 0;
+
        if (r->rtm_family == AF_INET6 && table != RT_TABLE_MAIN)
                ip6_multiple_tables = 1;