Skip to contentSkip to conversation

fib_trie: Fix lookup error return

PATCH Applied Ben Hutchings 3 participants 3 messages Jul 10, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fib_trie: Fix lookup error return

In commit a07f5f508a4d9728c8e57d7f66294bf5b254ff7f "[IPV4] fib_trie: style cleanup", the changes to check_leaf() and fn_trie_lookup() were wrong - where fn_trie_lookup() would previously return a negative error value from check_leaf(), it now returns 0.

Now fn_trie_lookup() doesn't appear to care about plen, so we can revert check_leaf() to returning the error value.

net/ipv4/fib_trie.c +6 -11
index 394db9c..43ed894 100644
@@ -1357,17 +1357,17 @@ static int check_leaf(struct trie *t, struct leaf *l,
 			t->stats.semantic_match_miss++;
 #endif
 		if (err <= 0)
-			return plen;
+			return err;
 	}
 
-	return -1;
+	return 1;
 }
 
 static int fn_trie_lookup(struct fib_table *tb, const struct flowi *flp,
 			  struct fib_result *res)
 {
 	struct trie *t = (struct trie *) tb->tb_data;
-	int plen, ret = 0;
+	int ret;
 	struct node *n;
 	struct tnode *pn;
 	int pos, bits;
@@ -1391,10 +1391,7 @@ static int fn_trie_lookup(struct fib_table *tb, const struct flowi *flp,
 
 	/* Just a leaf? */
 	if (IS_LEAF(n)) {
-		plen = check_leaf(t, (struct leaf *)n, key, flp, res);
-		if (plen < 0)
-			goto failed;
-		ret = 0;
+		ret = check_leaf(t, (struct leaf *)n, key, flp, res);
 		goto found;
 	}
 
@@ -1419,11 +1416,9 @@ static int fn_trie_lookup(struct fib_table *tb, const struct flowi *flp,
 		}
 
 		if (IS_LEAF(n)) {
-			plen = check_leaf(t, (struct leaf *)n, key, flp, res);
-			if (plen < 0)
+			ret = check_leaf(t, (struct leaf *)n, key, flp, res);
+			if (ret > 0)
 				goto backtrace;
-
-			ret = 0;
 			goto found;
 		}
 
Signature · 2 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Thu, 10 Jul 2008 14:23:37 +0100 Ben Hutchings <[email protected]>…

In commit a07f5f508a4d9728c8e57d7f66294bf5b254ff7f "[IPV4] fib_trie: style cleanup", the changes to check_leaf() and fn_trie_lookup() were wrong - where fn_trie_lookup() would previously return a negative error value from check_leaf(), it now returns 0.

Now fn_trie_lookup() doesn't appear to care about plen, so we can revert check_leaf() to returning the error value.

maintainer Applied
#2 lore raw

From: Stephen Hemminger <[email protected]>
Date: Thu, 10 Jul 2008 10:54:50 -0700

Quoted 8 lines
Quoted 5 lines · On Thu, 10 Jul 2008 14:23:37 +0100 Ben Hutchings <[email protected]>…

In commit a07f5f508a4d9728c8e57d7f66294bf5b254ff7f "[IPV4] fib_trie: style cleanup", the changes to check_leaf() and fn_trie_lookup() were wrong - where fn_trie_lookup() would previously return a negative error value from check_leaf(), it now returns 0.

Quoted 7 lines
Quoted 5 lines

Now fn_trie_lookup() doesn't appear to care about plen, so we can revert check_leaf() to returning the error value.

Applied, thanks everyone.