aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2016-12-01 07:27:52 -0500
committerDavid S. Miller <davem@davemloft.net>2016-12-05 13:15:58 -0500
commit1a239173cccff726b60ac6a9c79ae4a1e26cfa49 (patch)
tree1d60c464560140c9805472cf17e258a7b0ff28b7 /net
parentc66ebf2db555c6ed705044eabd2b37dcd546f68b (diff)
ipv4: Drop leaf from suffix pull/push functions
It wasn't necessary to pass a leaf in when doing the suffix updates so just drop it. Instead just pass the suffix and work with that. Since we dropped the leaf there is no need to include that in the name so the names are updated to node_push_suffix and node_pull_suffix. Finally I noticed that the logic for pulling the suffix length back actually had some issues. Specifically it would stop prematurely if there was a longer suffix, but it was not as long as the original suffix. I updated the code to address that in node_pull_suffix. Fixes: 5405afd1a306 ("fib_trie: Add tracking value for suffix length") Suggested-by: Robert Shearman <rshearma@brocade.com> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Reviewed-by: Robert Shearman <rshearma@brocade.com> Tested-by: Robert Shearman <rshearma@brocade.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/fib_trie.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 026f309c51e9..eec90d72dd52 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -930,22 +930,24 @@ static struct key_vector *resize(struct trie *t, struct key_vector *tn)
930 return tp; 930 return tp;
931} 931}
932 932
933static void leaf_pull_suffix(struct key_vector *tp, struct key_vector *l) 933static void node_pull_suffix(struct key_vector *tn, unsigned char slen)
934{ 934{
935 while ((tp->slen > tp->pos) && (tp->slen > l->slen)) { 935 unsigned char node_slen = tn->slen;
936 if (update_suffix(tp) > l->slen) 936
937 while ((node_slen > tn->pos) && (node_slen > slen)) {
938 slen = update_suffix(tn);
939 if (node_slen == slen)
937 break; 940 break;
938 tp = node_parent(tp); 941
942 tn = node_parent(tn);
943 node_slen = tn->slen;
939 } 944 }
940} 945}
941 946
942static void leaf_push_suffix(struct key_vector *tn, struct key_vector *l) 947static void node_push_suffix(struct key_vector *tn, unsigned char slen)
943{ 948{
944 /* if this is a new leaf then tn will be NULL and we can sort 949 while (tn->slen < slen) {
945 * out parent suffix lengths as a part of trie_rebalance 950 tn->slen = slen;
946 */
947 while (tn->slen < l->slen) {
948 tn->slen = l->slen;
949 tn = node_parent(tn); 951 tn = node_parent(tn);
950 } 952 }
951} 953}
@@ -1107,7 +1109,7 @@ static int fib_insert_alias(struct trie *t, struct key_vector *tp,
1107 /* if we added to the tail node then we need to update slen */ 1109 /* if we added to the tail node then we need to update slen */
1108 if (l->slen < new->fa_slen) { 1110 if (l->slen < new->fa_slen) {
1109 l->slen = new->fa_slen; 1111 l->slen = new->fa_slen;
1110 leaf_push_suffix(tp, l); 1112 node_push_suffix(tp, new->fa_slen);
1111 } 1113 }
1112 1114
1113 return 0; 1115 return 0;
@@ -1511,7 +1513,7 @@ static void fib_remove_alias(struct trie *t, struct key_vector *tp,
1511 1513
1512 /* update the trie with the latest suffix length */ 1514 /* update the trie with the latest suffix length */
1513 l->slen = fa->fa_slen; 1515 l->slen = fa->fa_slen;
1514 leaf_pull_suffix(tp, l); 1516 node_pull_suffix(tp, fa->fa_slen);
1515} 1517}
1516 1518
1517/* Caller must hold RTNL. */ 1519/* Caller must hold RTNL. */