[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150224205030.26106.12411.stgit@ahduyck-vm-fedora20>
Date: Tue, 24 Feb 2015 12:50:30 -0800
From: Alexander Duyck <alexander.h.duyck@...hat.com>
To: netdev@...r.kernel.org
Subject: [RFC PATCH 23/29] fib_trie: Add leaf_init
Since the leaf will now need to configure an entry in the key_vector array
of the parent I am adding a new function called leaf_init. It will
eventually replace leaf_new as we begin to pull fields out of the leaf
key_vector and push them into the parent.
Signed-off-by: Alexander Duyck <alexander.h.duyck@...hat.com>
---
net/ipv4/fib_trie.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index f9abbf4..65ea194 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -412,6 +412,31 @@ static inline void put_child_root(struct key_vector *tp, t_key key,
put_child(tp, get_index(key, tp), n);
}
+static void leaf_init(struct key_vector *tn, t_key key, struct key_vector *l)
+{
+ /* link leaf to parent */
+ NODE_INIT_PARENT(l, tn);
+
+ /* update parent node stats */
+ if (!IS_TRIE(tn)) {
+ unsigned long i = get_index(key, tn);
+ struct key_vector *n = get_child(tn + i);
+
+ BUG_ON(i >= child_length(tn));
+
+ if (!n)
+ empty_child_dec(tn);
+ else if (tnode_full(tn, n))
+ tn_info(tn)->full_children--;
+
+ /* update offset to correct key_vector for update */
+ tn += i;
+ }
+
+ /* populate key vector */
+ rcu_assign_pointer(tn->tnode, l);
+}
+
static struct key_vector *tnode_new(struct key_vector *pn, t_key key,
int pos, int bits)
{
@@ -1128,8 +1153,7 @@ static struct fib_table *fib_insert_node(struct net *net, struct trie *t,
}
/* Case 3: n is NULL, and will just insert a new leaf */
- NODE_INIT_PARENT(l, n);
- put_child_root(n, key, l);
+ leaf_init(n, key, l);
vector_replace(net, tp, tn);
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists