xdp: don't make drivers report attachment mode
prog_attached of struct netdev_bpf should have been superseded by simply setting prog_id long time ago, but we kept it around to allow offloading drivers to communicate attachment mode (drv vs hw). Subsequently drivers were also allowed to report back attachment flags (prog_flags), and since nowadays only programs attached will XDP_FLAGS_HW_MODE can get offloaded, we can tell the attachment mode from the flags driver reports. Remove prog_attached member. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
4f91da26c8
commit
6b86758973
|
@ -219,7 +219,6 @@ int bnxt_xdp(struct net_device *dev, struct netdev_bpf *xdp)
|
||||||
rc = bnxt_xdp_set(bp, xdp->prog);
|
rc = bnxt_xdp_set(bp, xdp->prog);
|
||||||
break;
|
break;
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
xdp->prog_attached = !!bp->xdp_prog;
|
|
||||||
xdp->prog_id = bp->xdp_prog ? bp->xdp_prog->aux->id : 0;
|
xdp->prog_id = bp->xdp_prog ? bp->xdp_prog->aux->id : 0;
|
||||||
rc = 0;
|
rc = 0;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1848,7 +1848,6 @@ static int nicvf_xdp(struct net_device *netdev, struct netdev_bpf *xdp)
|
||||||
case XDP_SETUP_PROG:
|
case XDP_SETUP_PROG:
|
||||||
return nicvf_xdp_setup(nic, xdp->prog);
|
return nicvf_xdp_setup(nic, xdp->prog);
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
xdp->prog_attached = !!nic->xdp_prog;
|
|
||||||
xdp->prog_id = nic->xdp_prog ? nic->xdp_prog->aux->id : 0;
|
xdp->prog_id = nic->xdp_prog ? nic->xdp_prog->aux->id : 0;
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -11841,7 +11841,6 @@ static int i40e_xdp(struct net_device *dev,
|
||||||
case XDP_SETUP_PROG:
|
case XDP_SETUP_PROG:
|
||||||
return i40e_xdp_setup(vsi, xdp->prog);
|
return i40e_xdp_setup(vsi, xdp->prog);
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
xdp->prog_attached = i40e_enabled_xdp_vsi(vsi);
|
|
||||||
xdp->prog_id = vsi->xdp_prog ? vsi->xdp_prog->aux->id : 0;
|
xdp->prog_id = vsi->xdp_prog ? vsi->xdp_prog->aux->id : 0;
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -9966,7 +9966,6 @@ static int ixgbe_xdp(struct net_device *dev, struct netdev_bpf *xdp)
|
||||||
case XDP_SETUP_PROG:
|
case XDP_SETUP_PROG:
|
||||||
return ixgbe_xdp_setup(dev, xdp->prog);
|
return ixgbe_xdp_setup(dev, xdp->prog);
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
xdp->prog_attached = !!(adapter->xdp_prog);
|
|
||||||
xdp->prog_id = adapter->xdp_prog ?
|
xdp->prog_id = adapter->xdp_prog ?
|
||||||
adapter->xdp_prog->aux->id : 0;
|
adapter->xdp_prog->aux->id : 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -4462,7 +4462,6 @@ static int ixgbevf_xdp(struct net_device *dev, struct netdev_bpf *xdp)
|
||||||
case XDP_SETUP_PROG:
|
case XDP_SETUP_PROG:
|
||||||
return ixgbevf_xdp_setup(dev, xdp->prog);
|
return ixgbevf_xdp_setup(dev, xdp->prog);
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
xdp->prog_attached = !!(adapter->xdp_prog);
|
|
||||||
xdp->prog_id = adapter->xdp_prog ?
|
xdp->prog_id = adapter->xdp_prog ?
|
||||||
adapter->xdp_prog->aux->id : 0;
|
adapter->xdp_prog->aux->id : 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -2926,7 +2926,6 @@ static int mlx4_xdp(struct net_device *dev, struct netdev_bpf *xdp)
|
||||||
return mlx4_xdp_set(dev, xdp->prog);
|
return mlx4_xdp_set(dev, xdp->prog);
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
xdp->prog_id = mlx4_xdp_query(dev);
|
xdp->prog_id = mlx4_xdp_query(dev);
|
||||||
xdp->prog_attached = !!xdp->prog_id;
|
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -4192,7 +4192,6 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_bpf *xdp)
|
||||||
return mlx5e_xdp_set(dev, xdp->prog);
|
return mlx5e_xdp_set(dev, xdp->prog);
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
xdp->prog_id = mlx5e_xdp_query(dev);
|
xdp->prog_id = mlx5e_xdp_query(dev);
|
||||||
xdp->prog_attached = !!xdp->prog_id;
|
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -3459,9 +3459,6 @@ static int nfp_net_xdp(struct net_device *netdev, struct netdev_bpf *xdp)
|
||||||
return nfp_net_xdp_setup(nn, xdp->prog, xdp->flags,
|
return nfp_net_xdp_setup(nn, xdp->prog, xdp->flags,
|
||||||
xdp->extack);
|
xdp->extack);
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
xdp->prog_attached = !!nn->xdp_prog;
|
|
||||||
if (nn->dp.bpf_offload_xdp)
|
|
||||||
xdp->prog_attached = XDP_ATTACHED_HW;
|
|
||||||
xdp->prog_id = nn->xdp_prog ? nn->xdp_prog->aux->id : 0;
|
xdp->prog_id = nn->xdp_prog ? nn->xdp_prog->aux->id : 0;
|
||||||
xdp->prog_flags = nn->xdp_prog ? nn->xdp_flags : 0;
|
xdp->prog_flags = nn->xdp_prog ? nn->xdp_flags : 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1116,7 +1116,6 @@ int qede_xdp(struct net_device *dev, struct netdev_bpf *xdp)
|
||||||
case XDP_SETUP_PROG:
|
case XDP_SETUP_PROG:
|
||||||
return qede_xdp_set(edev, xdp->prog);
|
return qede_xdp_set(edev, xdp->prog);
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
xdp->prog_attached = !!edev->xdp_prog;
|
|
||||||
xdp->prog_id = edev->xdp_prog ? edev->xdp_prog->aux->id : 0;
|
xdp->prog_id = edev->xdp_prog ? edev->xdp_prog->aux->id : 0;
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -567,7 +567,6 @@ int nsim_bpf(struct net_device *dev, struct netdev_bpf *bpf)
|
||||||
nsim_bpf_destroy_prog(bpf->offload.prog);
|
nsim_bpf_destroy_prog(bpf->offload.prog);
|
||||||
return 0;
|
return 0;
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
bpf->prog_attached = ns->xdp_prog_mode;
|
|
||||||
bpf->prog_id = ns->xdp_prog ? ns->xdp_prog->aux->id : 0;
|
bpf->prog_id = ns->xdp_prog ? ns->xdp_prog->aux->id : 0;
|
||||||
bpf->prog_flags = ns->xdp_prog ? ns->xdp_flags : 0;
|
bpf->prog_flags = ns->xdp_prog ? ns->xdp_flags : 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1268,7 +1268,6 @@ static int tun_xdp(struct net_device *dev, struct netdev_bpf *xdp)
|
||||||
return tun_xdp_set(dev, xdp->prog, xdp->extack);
|
return tun_xdp_set(dev, xdp->prog, xdp->extack);
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
xdp->prog_id = tun_xdp_query(dev);
|
xdp->prog_id = tun_xdp_query(dev);
|
||||||
xdp->prog_attached = !!xdp->prog_id;
|
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -2343,7 +2343,6 @@ static int virtnet_xdp(struct net_device *dev, struct netdev_bpf *xdp)
|
||||||
return virtnet_xdp_set(dev, xdp->prog, xdp->extack);
|
return virtnet_xdp_set(dev, xdp->prog, xdp->extack);
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
xdp->prog_id = virtnet_xdp_query(dev);
|
xdp->prog_id = virtnet_xdp_query(dev);
|
||||||
xdp->prog_attached = !!xdp->prog_id;
|
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -819,10 +819,6 @@ enum bpf_netdev_command {
|
||||||
*/
|
*/
|
||||||
XDP_SETUP_PROG,
|
XDP_SETUP_PROG,
|
||||||
XDP_SETUP_PROG_HW,
|
XDP_SETUP_PROG_HW,
|
||||||
/* Check if a bpf program is set on the device. The callee should
|
|
||||||
* set @prog_attached to one of XDP_ATTACHED_* values, note that "true"
|
|
||||||
* is equivalent to XDP_ATTACHED_DRV.
|
|
||||||
*/
|
|
||||||
XDP_QUERY_PROG,
|
XDP_QUERY_PROG,
|
||||||
/* BPF program for offload callbacks, invoked at program load time. */
|
/* BPF program for offload callbacks, invoked at program load time. */
|
||||||
BPF_OFFLOAD_VERIFIER_PREP,
|
BPF_OFFLOAD_VERIFIER_PREP,
|
||||||
|
@ -849,7 +845,6 @@ struct netdev_bpf {
|
||||||
};
|
};
|
||||||
/* XDP_QUERY_PROG */
|
/* XDP_QUERY_PROG */
|
||||||
struct {
|
struct {
|
||||||
u8 prog_attached;
|
|
||||||
u32 prog_id;
|
u32 prog_id;
|
||||||
/* flags with which program was installed */
|
/* flags with which program was installed */
|
||||||
u32 prog_flags;
|
u32 prog_flags;
|
||||||
|
|
|
@ -4926,7 +4926,6 @@ static int generic_xdp_install(struct net_device *dev, struct netdev_bpf *xdp)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XDP_QUERY_PROG:
|
case XDP_QUERY_PROG:
|
||||||
xdp->prog_attached = !!old;
|
|
||||||
xdp->prog_id = old ? old->aux->id : 0;
|
xdp->prog_id = old ? old->aux->id : 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -7593,13 +7592,13 @@ void __dev_xdp_query(struct net_device *dev, bpf_op_t bpf_op,
|
||||||
WARN_ON(bpf_op(dev, xdp) < 0);
|
WARN_ON(bpf_op(dev, xdp) < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 __dev_xdp_attached(struct net_device *dev, bpf_op_t bpf_op)
|
static bool __dev_xdp_attached(struct net_device *dev, bpf_op_t bpf_op)
|
||||||
{
|
{
|
||||||
struct netdev_bpf xdp;
|
struct netdev_bpf xdp;
|
||||||
|
|
||||||
__dev_xdp_query(dev, bpf_op, &xdp);
|
__dev_xdp_query(dev, bpf_op, &xdp);
|
||||||
|
|
||||||
return xdp.prog_attached;
|
return xdp.prog_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_xdp_install(struct net_device *dev, bpf_op_t bpf_op,
|
static int dev_xdp_install(struct net_device *dev, bpf_op_t bpf_op,
|
||||||
|
@ -7634,7 +7633,7 @@ static void dev_xdp_uninstall(struct net_device *dev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
__dev_xdp_query(dev, ndo_bpf, &xdp);
|
__dev_xdp_query(dev, ndo_bpf, &xdp);
|
||||||
if (xdp.prog_attached == XDP_ATTACHED_NONE)
|
if (!xdp.prog_id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Program removal should always succeed */
|
/* Program removal should always succeed */
|
||||||
|
|
|
@ -1372,9 +1372,13 @@ static u8 rtnl_xdp_attached_mode(struct net_device *dev, u32 *prog_id)
|
||||||
return XDP_ATTACHED_NONE;
|
return XDP_ATTACHED_NONE;
|
||||||
|
|
||||||
__dev_xdp_query(dev, ops->ndo_bpf, &xdp);
|
__dev_xdp_query(dev, ops->ndo_bpf, &xdp);
|
||||||
*prog_id = xdp.prog_id;
|
if (!xdp.prog_id)
|
||||||
|
return XDP_ATTACHED_NONE;
|
||||||
|
|
||||||
return xdp.prog_attached;
|
*prog_id = xdp.prog_id;
|
||||||
|
if (xdp.prog_flags & XDP_FLAGS_HW_MODE)
|
||||||
|
return XDP_ATTACHED_HW;
|
||||||
|
return XDP_ATTACHED_DRV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev)
|
static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev)
|
||||||
|
|
Loading…
Reference in New Issue