Skip to content

Commit a460aa8

Browse files
idoschdavem330
authored andcommitted
ipv6: fib: Add helpers to hold / drop a reference on rt6_info
Similar to commit 1c677b3 ("ipv4: fib: Add fib_info_hold() helper") and commit b423cb1 ("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>
1 parent fc882fc commit a460aa8

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

include/net/ip6_fib.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,22 @@ static inline void ip6_rt_put(struct rt6_info *rt)
187187
dst_release(&rt->dst);
188188
}
189189

190+
void rt6_free_pcpu(struct rt6_info *non_pcpu_rt);
191+
192+
static inline void rt6_hold(struct rt6_info *rt)
193+
{
194+
atomic_inc(&rt->rt6i_ref);
195+
}
196+
197+
static inline void rt6_release(struct rt6_info *rt)
198+
{
199+
if (atomic_dec_and_test(&rt->rt6i_ref)) {
200+
rt6_free_pcpu(rt);
201+
dst_dev_put(&rt->dst);
202+
dst_release(&rt->dst);
203+
}
204+
}
205+
190206
enum fib6_walk_state {
191207
#ifdef CONFIG_IPV6_SUBTREES
192208
FWS_S,

net/ipv6/ip6_fib.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static void node_free(struct fib6_node *fn)
154154
kmem_cache_free(fib6_node_kmem, fn);
155155
}
156156

157-
static void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
157+
void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
158158
{
159159
int cpu;
160160

@@ -177,15 +177,7 @@ static void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
177177
free_percpu(non_pcpu_rt->rt6i_pcpu);
178178
non_pcpu_rt->rt6i_pcpu = NULL;
179179
}
180-
181-
static void rt6_release(struct rt6_info *rt)
182-
{
183-
if (atomic_dec_and_test(&rt->rt6i_ref)) {
184-
rt6_free_pcpu(rt);
185-
dst_dev_put(&rt->dst);
186-
dst_release(&rt->dst);
187-
}
188-
}
180+
EXPORT_SYMBOL_GPL(rt6_free_pcpu);
189181

190182
static void fib6_link_table(struct net *net, struct fib6_table *tb)
191183
{

0 commit comments

Comments
 (0)