]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ipv6: fib: Add helpers to hold / drop a reference on rt6_info
authorIdo Schimmel <idosch@mellanox.com>
Thu, 3 Aug 2017 11:28:25 +0000 (13:28 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Aug 2017 22:36:00 +0000 (15:36 -0700)
Similar to commit 1c677b3d2828 ("ipv4: fib: Add fib_info_hold() helper")
and commit b423cb10807b ("ipv4: fib: Export free_fib_info()") add an
helper to hold a reference on rt6_info and export rt6_release() to drop
it and potentially release the route.

This is needed so that drivers capable of FIB offload could hold a
reference on the route before queueing it for offload and drop it after
the route has been programmed to the device's tables.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ip6_fib.h
net/ipv6/ip6_fib.c

index 0b3052157e6bfb37f10dbf175d14e2d04a2ff5d7..1d790ea40ea7828e8eda44ca614fdc7528946fee 100644 (file)
@@ -187,6 +187,22 @@ static inline void ip6_rt_put(struct rt6_info *rt)
        dst_release(&rt->dst);
 }
 
+void rt6_free_pcpu(struct rt6_info *non_pcpu_rt);
+
+static inline void rt6_hold(struct rt6_info *rt)
+{
+       atomic_inc(&rt->rt6i_ref);
+}
+
+static inline void rt6_release(struct rt6_info *rt)
+{
+       if (atomic_dec_and_test(&rt->rt6i_ref)) {
+               rt6_free_pcpu(rt);
+               dst_dev_put(&rt->dst);
+               dst_release(&rt->dst);
+       }
+}
+
 enum fib6_walk_state {
 #ifdef CONFIG_IPV6_SUBTREES
        FWS_S,
index fe193b48ef6126e895c3e5d1d602103aeeea186b..69ed0043d1173f728e4f922b515c4bf39dc83e05 100644 (file)
@@ -154,7 +154,7 @@ static void node_free(struct fib6_node *fn)
        kmem_cache_free(fib6_node_kmem, fn);
 }
 
-static void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
+void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
 {
        int cpu;
 
@@ -177,15 +177,7 @@ static void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
        free_percpu(non_pcpu_rt->rt6i_pcpu);
        non_pcpu_rt->rt6i_pcpu = NULL;
 }
-
-static void rt6_release(struct rt6_info *rt)
-{
-       if (atomic_dec_and_test(&rt->rt6i_ref)) {
-               rt6_free_pcpu(rt);
-               dst_dev_put(&rt->dst);
-               dst_release(&rt->dst);
-       }
-}
+EXPORT_SYMBOL_GPL(rt6_free_pcpu);
 
 static void fib6_link_table(struct net *net, struct fib6_table *tb)
 {