Netdev List
 help / color / mirror / Atom feed
* [PATCH net] ipv6: don't stop backtracking in fib6_lookup_1 if subtree does not match
@ 2013-08-07  0:34 Hannes Frederic Sowa
  2013-08-07 19:58 ` Teco Boot
  2013-08-08  0:17 ` [PATCH net] ipv6: don't stop backtracking in fib6_lookup_1 if subtree does not match David Miller
  0 siblings, 2 replies; 20+ messages in thread
From: Hannes Frederic Sowa @ 2013-08-07  0:34 UTC (permalink / raw)
  To: netdev; +Cc: teco, yoshfuji, equinox, boutier

In case a subtree did not match we currently stop backtracking and return
NULL (root table from fib_lookup). This could yield in invalid routing
table lookups when using subtrees.

Instead continue to backtrack until a valid subtree or node is found
and return this match.

Also remove unneeded NULL check.

Reported-by: Teco Boot <teco@inf-net.nl>
Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Cc: David Lamparter <equinox@diac24.net>
Cc: <boutier@pps.univ-paris-diderot.fr>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
 net/ipv6/ip6_fib.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index ed828d6..73db48e 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -993,14 +993,22 @@ static struct fib6_node * fib6_lookup_1(struct fib6_node *root,
 
 			if (ipv6_prefix_equal(&key->addr, args->addr, key->plen)) {
 #ifdef CONFIG_IPV6_SUBTREES
-				if (fn->subtree)
-					fn = fib6_lookup_1(fn->subtree, args + 1);
+				if (fn->subtree) {
+					struct fib6_node *sfn;
+					sfn = fib6_lookup_1(fn->subtree,
+							    args + 1);
+					if (!sfn)
+						goto backtrack;
+					fn = sfn;
+				}
 #endif
-				if (!fn || fn->fn_flags & RTN_RTINFO)
+				if (fn->fn_flags & RTN_RTINFO)
 					return fn;
 			}
 		}
-
+#ifdef CONFIG_IPV6_SUBTREES
+backtrack:
+#endif
 		if (fn->fn_flags & RTN_ROOT)
 			break;
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-12-03 20:11 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-07  0:34 [PATCH net] ipv6: don't stop backtracking in fib6_lookup_1 if subtree does not match Hannes Frederic Sowa
2013-08-07 19:58 ` Teco Boot
2013-08-07 20:06   ` Hannes Frederic Sowa
2013-08-09 14:12     ` Teco Boot
2013-08-09 14:19       ` Hannes Frederic Sowa
2013-08-09 14:40         ` Teco Boot
2013-08-09 14:57           ` Hannes Frederic Sowa
2013-08-10 11:39             ` Teco Boot
2013-08-10 12:03               ` Hannes Frederic Sowa
2013-08-13  8:02                 ` Teco Boot
2013-08-13  8:15                   ` David Miller
2013-08-14  6:40                     ` Teco Boot
2013-08-14  7:55                       ` David Miller
2013-08-14  7:59                         ` Teco Boot
2013-08-14  8:06                           ` Teco Boot
2013-08-14 10:06                             ` Hannes Frederic Sowa
2013-08-10 12:15               ` Hannes Frederic Sowa
2015-12-02  9:55   ` [PATCH net 1/1] via-rhine: fix VLAN receive handling regression Teco Boot
2015-12-03 20:11     ` David Miller
2013-08-08  0:17 ` [PATCH net] ipv6: don't stop backtracking in fib6_lookup_1 if subtree does not match David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox