Skip to content

Commit

Permalink
xfrm: add net device refcount tracker to struct xfrm_state_offload
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Dumazet <[email protected]>
Acked-by: Steffen Klassert <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Eric Dumazet authored and kuba-moo committed Dec 10, 2021
1 parent 3d20408 commit e1b539b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/net/xfrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct xfrm_state_walk {

struct xfrm_state_offload {
struct net_device *dev;
netdevice_tracker dev_tracker;
struct net_device *real_dev;
unsigned long offload_handle;
unsigned int num_exthdrs;
Expand Down Expand Up @@ -1913,7 +1914,7 @@ static inline void xfrm_dev_state_free(struct xfrm_state *x)
if (dev->xfrmdev_ops->xdo_dev_state_free)
dev->xfrmdev_ops->xdo_dev_state_free(x);
xso->dev = NULL;
dev_put(dev);
dev_put_track(dev, &xso->dev_tracker);
}
}
#else
Expand Down
3 changes: 2 additions & 1 deletion net/xfrm/xfrm_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
}

xso->dev = dev;
netdev_tracker_alloc(dev, &xso->dev_tracker, GFP_ATOMIC);
xso->real_dev = dev;
xso->num_exthdrs = 1;
xso->flags = xuo->flags;
Expand All @@ -269,7 +270,7 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
xso->flags = 0;
xso->dev = NULL;
xso->real_dev = NULL;
dev_put(dev);
dev_put_track(dev, &xso->dev_tracker);

if (err != -EOPNOTSUPP)
return err;
Expand Down

0 comments on commit e1b539b

Please sign in to comment.