Skip to content

Commit dac7d0f

Browse files
dsaherndavem330
authored andcommitted
ipv6: Create cleanup helper for fib6_nh
Move the fib6_nh cleanup code to a new helper, fib6_nh_release. Signed-off-by: David Ahern <dsahern@gmail.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 83c4425 commit dac7d0f

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎include/net/ip6_fib.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ static inline struct net_device *fib6_info_nh_dev(const struct fib6_info *f6i)
447447
int fib6_nh_init(struct net *net, struct fib6_nh *fib6_nh,
448448
struct fib6_config *cfg, gfp_t gfp_flags,
449449
struct netlink_ext_ack *extack);
450+
void fib6_nh_release(struct fib6_nh *fib6_nh);
450451

451452
static inline
452453
struct lwtunnel_state *fib6_info_nh_lwt(const struct fib6_info *f6i)

‎net/ipv6/ip6_fib.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ void fib6_info_destroy_rcu(struct rcu_head *head)
199199
free_percpu(f6i->rt6i_pcpu);
200200
}
201201

202-
lwtstate_put(f6i->fib6_nh.nh_lwtstate);
203-
204-
if (f6i->fib6_nh.nh_dev)
205-
dev_put(f6i->fib6_nh.nh_dev);
202+
fib6_nh_release(&f6i->fib6_nh);
206203

207204
ip_fib_metrics_put(f6i->fib6_metrics);
208205

‎net/ipv6/route.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3025,6 +3025,14 @@ int fib6_nh_init(struct net *net, struct fib6_nh *fib6_nh,
30253025
return err;
30263026
}
30273027

3028+
void fib6_nh_release(struct fib6_nh *fib6_nh)
3029+
{
3030+
lwtstate_put(fib6_nh->nh_lwtstate);
3031+
3032+
if (fib6_nh->nh_dev)
3033+
dev_put(fib6_nh->nh_dev);
3034+
}
3035+
30283036
static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
30293037
gfp_t gfp_flags,
30303038
struct netlink_ext_ack *extack)

0 commit comments

Comments
 (0)