Skip to content

Commit

Permalink
sit: add net device refcount tracking to ip_tunnel
Browse files Browse the repository at this point in the history
Note that other ip_tunnel users do not seem to hold a reference
on tunnel->dev. Probably needs some investigations.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Eric Dumazet authored and Jakub Kicinski committed Dec 7, 2021
1 parent fb67510 commit c0fd407
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/net/ip_tunnels.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ struct metadata_dst;
struct ip_tunnel {
struct ip_tunnel __rcu *next;
struct hlist_node hash_node;

struct net_device *dev;
netdevice_tracker dev_tracker;

struct net *net; /* netns for packet i/o */

unsigned long err_time; /* Time when the last ICMP error
Expand Down
4 changes: 2 additions & 2 deletions net/ipv6/sit.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ static void ipip6_tunnel_uninit(struct net_device *dev)
ipip6_tunnel_del_prl(tunnel, NULL);
}
dst_cache_reset(&tunnel->dst_cache);
dev_put(dev);
dev_put_track(dev, &tunnel->dev_tracker);
}

static int ipip6_err(struct sk_buff *skb, u32 info)
Expand Down Expand Up @@ -1463,7 +1463,7 @@ static int ipip6_tunnel_init(struct net_device *dev)
dev->tstats = NULL;
return err;
}
dev_hold(dev);
dev_hold_track(dev, &tunnel->dev_tracker, GFP_KERNEL);
return 0;
}

Expand Down

0 comments on commit c0fd407

Please sign in to comment.