ipv6: Create cleanup helper for fib6_nh
authorDavid Ahern <dsahern@gmail.com>
Thu, 28 Mar 2019 03:53:51 +0000 (20:53 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 29 Mar 2019 17:48:03 +0000 (10:48 -0700)
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>
include/net/ip6_fib.h
net/ipv6/ip6_fib.c
net/ipv6/route.c

index ce1f81345c8e8cad3022a62b5d8d1d00380067f1..2d2a468b3d6d6897fe12b45dd0b84e69a20fbcef 100644 (file)
@@ -447,6 +447,7 @@ static inline struct net_device *fib6_info_nh_dev(const struct fib6_info *f6i)
 int fib6_nh_init(struct net *net, struct fib6_nh *fib6_nh,
                 struct fib6_config *cfg, gfp_t gfp_flags,
                 struct netlink_ext_ack *extack);
+void fib6_nh_release(struct fib6_nh *fib6_nh);
 
 static inline
 struct lwtunnel_state *fib6_info_nh_lwt(const struct fib6_info *f6i)
index 6613d8dbb0e5a5c3ba883c957e5bc4ba2bf00777..db886085369b24f0384afbbde8a8ca52c2e4ccde 100644 (file)
@@ -199,10 +199,7 @@ void fib6_info_destroy_rcu(struct rcu_head *head)
                free_percpu(f6i->rt6i_pcpu);
        }
 
-       lwtstate_put(f6i->fib6_nh.nh_lwtstate);
-
-       if (f6i->fib6_nh.nh_dev)
-               dev_put(f6i->fib6_nh.nh_dev);
+       fib6_nh_release(&f6i->fib6_nh);
 
        ip_fib_metrics_put(f6i->fib6_metrics);
 
index 8c5a998b28a18b711ea9425d6452bb389386cf22..5f453c79dd00a059de97c8c762394d0756d1a53e 100644 (file)
@@ -3025,6 +3025,14 @@ out:
        return err;
 }
 
+void fib6_nh_release(struct fib6_nh *fib6_nh)
+{
+       lwtstate_put(fib6_nh->nh_lwtstate);
+
+       if (fib6_nh->nh_dev)
+               dev_put(fib6_nh->nh_dev);
+}
+
 static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
                                              gfp_t gfp_flags,
                                              struct netlink_ext_ack *extack)