Commit 56c1c779 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

ipv6: add net device refcount tracker to struct ip6_tnl

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c0fd407a
...@@ -46,6 +46,7 @@ struct __ip6_tnl_parm { ...@@ -46,6 +46,7 @@ struct __ip6_tnl_parm {
struct ip6_tnl { struct ip6_tnl {
struct ip6_tnl __rcu *next; /* next tunnel in list */ struct ip6_tnl __rcu *next; /* next tunnel in list */
struct net_device *dev; /* virtual device associated with tunnel */ struct net_device *dev; /* virtual device associated with tunnel */
netdevice_tracker dev_tracker;
struct net *net; /* netns for packet i/o */ struct net *net; /* netns for packet i/o */
struct __ip6_tnl_parm parms; /* tunnel configuration parameters */ struct __ip6_tnl_parm parms; /* tunnel configuration parameters */
struct flowi fl; /* flowi template for xmit */ struct flowi fl; /* flowi template for xmit */
......
...@@ -403,7 +403,7 @@ static void ip6erspan_tunnel_uninit(struct net_device *dev) ...@@ -403,7 +403,7 @@ static void ip6erspan_tunnel_uninit(struct net_device *dev)
ip6erspan_tunnel_unlink_md(ign, t); ip6erspan_tunnel_unlink_md(ign, t);
ip6gre_tunnel_unlink(ign, t); ip6gre_tunnel_unlink(ign, t);
dst_cache_reset(&t->dst_cache); dst_cache_reset(&t->dst_cache);
dev_put(dev); dev_put_track(dev, &t->dev_tracker);
} }
static void ip6gre_tunnel_uninit(struct net_device *dev) static void ip6gre_tunnel_uninit(struct net_device *dev)
...@@ -416,7 +416,7 @@ static void ip6gre_tunnel_uninit(struct net_device *dev) ...@@ -416,7 +416,7 @@ static void ip6gre_tunnel_uninit(struct net_device *dev)
if (ign->fb_tunnel_dev == dev) if (ign->fb_tunnel_dev == dev)
WRITE_ONCE(ign->fb_tunnel_dev, NULL); WRITE_ONCE(ign->fb_tunnel_dev, NULL);
dst_cache_reset(&t->dst_cache); dst_cache_reset(&t->dst_cache);
dev_put(dev); dev_put_track(dev, &t->dev_tracker);
} }
...@@ -1496,7 +1496,7 @@ static int ip6gre_tunnel_init_common(struct net_device *dev) ...@@ -1496,7 +1496,7 @@ static int ip6gre_tunnel_init_common(struct net_device *dev)
} }
ip6gre_tnl_init_features(dev); ip6gre_tnl_init_features(dev);
dev_hold(dev); dev_hold_track(dev, &tunnel->dev_tracker, GFP_KERNEL);
return 0; return 0;
cleanup_dst_cache_init: cleanup_dst_cache_init:
...@@ -1888,7 +1888,7 @@ static int ip6erspan_tap_init(struct net_device *dev) ...@@ -1888,7 +1888,7 @@ static int ip6erspan_tap_init(struct net_device *dev)
dev->priv_flags |= IFF_LIVE_ADDR_CHANGE; dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
ip6erspan_tnl_link_config(tunnel, 1); ip6erspan_tnl_link_config(tunnel, 1);
dev_hold(dev); dev_hold_track(dev, &tunnel->dev_tracker, GFP_KERNEL);
return 0; return 0;
cleanup_dst_cache_init: cleanup_dst_cache_init:
......
...@@ -383,7 +383,7 @@ ip6_tnl_dev_uninit(struct net_device *dev) ...@@ -383,7 +383,7 @@ ip6_tnl_dev_uninit(struct net_device *dev)
else else
ip6_tnl_unlink(ip6n, t); ip6_tnl_unlink(ip6n, t);
dst_cache_reset(&t->dst_cache); dst_cache_reset(&t->dst_cache);
dev_put(dev); dev_put_track(dev, &t->dev_tracker);
} }
/** /**
...@@ -1883,7 +1883,7 @@ ip6_tnl_dev_init_gen(struct net_device *dev) ...@@ -1883,7 +1883,7 @@ ip6_tnl_dev_init_gen(struct net_device *dev)
dev->min_mtu = ETH_MIN_MTU; dev->min_mtu = ETH_MIN_MTU;
dev->max_mtu = IP6_MAX_MTU - dev->hard_header_len; dev->max_mtu = IP6_MAX_MTU - dev->hard_header_len;
dev_hold(dev); dev_hold_track(dev, &t->dev_tracker, GFP_KERNEL);
return 0; return 0;
destroy_dst: destroy_dst:
......
...@@ -293,7 +293,7 @@ static void vti6_dev_uninit(struct net_device *dev) ...@@ -293,7 +293,7 @@ static void vti6_dev_uninit(struct net_device *dev)
RCU_INIT_POINTER(ip6n->tnls_wc[0], NULL); RCU_INIT_POINTER(ip6n->tnls_wc[0], NULL);
else else
vti6_tnl_unlink(ip6n, t); vti6_tnl_unlink(ip6n, t);
dev_put(dev); dev_put_track(dev, &t->dev_tracker);
} }
static int vti6_input_proto(struct sk_buff *skb, int nexthdr, __be32 spi, static int vti6_input_proto(struct sk_buff *skb, int nexthdr, __be32 spi,
...@@ -934,7 +934,7 @@ static inline int vti6_dev_init_gen(struct net_device *dev) ...@@ -934,7 +934,7 @@ static inline int vti6_dev_init_gen(struct net_device *dev)
dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
if (!dev->tstats) if (!dev->tstats)
return -ENOMEM; return -ENOMEM;
dev_hold(dev); dev_hold_track(dev, &t->dev_tracker, GFP_KERNEL);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment