Commit bd0b2e7f authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Daniel Borkmann
Browse files

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: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 92f0292b
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -7800,8 +7800,6 @@ static void bnxt_remove_one(struct pci_dev *pdev)
	bnxt_dcb_free(bp);
	kfree(bp->edev);
	bp->edev = NULL;
	if (bp->xdp_prog)
		bpf_prog_put(bp->xdp_prog);
	bnxt_cleanup_pci(bp);
	free_netdev(dev);
}
+0 −3
Original line number Diff line number Diff line
@@ -4308,9 +4308,6 @@ static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
{
	mlx5e_ipsec_cleanup(priv);
	mlx5e_vxlan_cleanup(priv);

	if (priv->channels.params.xdp_prog)
		bpf_prog_put(priv->channels.params.xdp_prog);
}

static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
+0 −7
Original line number Diff line number Diff line
@@ -82,12 +82,6 @@ static const char *nfp_bpf_extra_cap(struct nfp_app *app, struct nfp_net *nn)
	return nfp_net_ebpf_capable(nn) ? "BPF" : "";
}

static void nfp_bpf_vnic_free(struct nfp_app *app, struct nfp_net *nn)
{
	if (nn->dp.bpf_offload_xdp)
		nfp_bpf_xdp_offload(app, nn, NULL);
}

static int nfp_bpf_setup_tc_block_cb(enum tc_setup_type type,
				     void *type_data, void *cb_priv)
{
@@ -168,7 +162,6 @@ const struct nfp_app_type app_bpf = {
	.extra_cap	= nfp_bpf_extra_cap,

	.vnic_alloc	= nfp_app_nic_vnic_alloc,
	.vnic_free	= nfp_bpf_vnic_free,

	.setup_tc	= nfp_bpf_setup_tc,
	.tc_busy	= nfp_bpf_tc_busy,
+0 −3
Original line number Diff line number Diff line
@@ -3562,9 +3562,6 @@ struct nfp_net *nfp_net_alloc(struct pci_dev *pdev, bool needs_netdev,
 */
void nfp_net_free(struct nfp_net *nn)
{
	if (nn->xdp_prog)
		bpf_prog_put(nn->xdp_prog);

	if (nn->dp.netdev)
		free_netdev(nn->dp.netdev);
	else
+0 −4
Original line number Diff line number Diff line
@@ -1068,10 +1068,6 @@ static void __qede_remove(struct pci_dev *pdev, enum qede_remove_mode mode)

	pci_set_drvdata(pdev, NULL);

	/* Release edev's reference to XDP's bpf if such exist */
	if (edev->xdp_prog)
		bpf_prog_put(edev->xdp_prog);

	/* Use global ops since we've freed edev */
	qed_ops->common->slowpath_stop(cdev);
	if (system_state == SYSTEM_POWER_OFF)
Loading