net: xdp: make the stack take care of the tear down
Since day one of XDP drivers had to remember to free the program on the remove path. This leads to code duplication and is error prone. Make the stack query the installed programs on unregister and if something is installed, remove the program. Freeing of program attached to XDP generic is moved from free_netdev() as well. Because the remove will now be called before notifiers are invoked, BPF offload state of the program will not get destroyed before uninstall. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:

committed by
Daniel Borkmann

parent
92f0292b35
commit
bd0b2e7fe6
@@ -673,7 +673,6 @@ static void tun_detach(struct tun_file *tfile, bool clean)
|
||||
static void tun_detach_all(struct net_device *dev)
|
||||
{
|
||||
struct tun_struct *tun = netdev_priv(dev);
|
||||
struct bpf_prog *xdp_prog = rtnl_dereference(tun->xdp_prog);
|
||||
struct tun_file *tfile, *tmp;
|
||||
int i, n = tun->numqueues;
|
||||
|
||||
@@ -708,9 +707,6 @@ static void tun_detach_all(struct net_device *dev)
|
||||
}
|
||||
BUG_ON(tun->numdisabled != 0);
|
||||
|
||||
if (xdp_prog)
|
||||
bpf_prog_put(xdp_prog);
|
||||
|
||||
if (tun->flags & IFF_PERSIST)
|
||||
module_put(THIS_MODULE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user