netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] route: filter routes by family if it's specified
@ 2015-09-23 11:43 Andrey Vagin
  0 siblings, 0 replies; 2+ messages in thread
From: Andrey Vagin @ 2015-09-23 11:43 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger, Andrew Vagin

From: Andrew Vagin <avagin@openvz.org>

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 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ip/iproute.c b/ip/iproute.c
index abe4180..da25548 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -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;
 
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread
[parent not found: <35fe2442e87b4e91a7b4ff16739ba216@HQ1WP-EXMB11.corp.brocade.com>]

end of thread, other threads:[~2015-09-23 23:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-23 11:43 [PATCH iproute2] route: filter routes by family if it's specified Andrey Vagin
     [not found] <35fe2442e87b4e91a7b4ff16739ba216@HQ1WP-EXMB11.corp.brocade.com>
2015-09-23 23:16 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).