xdp: support simultaneous driver and hw XDP attachment
Split the query of HW-attached program from the software one. Introduce new .ndo_bpf command to query HW-attached program. This will allow drivers to install different programs in HW and SW at the same time. Netlink can now also carry multiple programs on dump (in which case mode will be set to XDP_ATTACHED_MULTI and user has to check per-attachment point attributes, IFLA_XDP_PROG_ID will not be present). We reuse IFLA_XDP_PROG_ID skb space for second mode, so rtnl_xdp_size() doesn't need to be updated. Note that the installation side is still not there, since all drivers currently reject installing more than one program at the time. 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:

committed by
Daniel Borkmann

parent
05296620f6
commit
a25717d2b6
@@ -820,6 +820,7 @@ enum bpf_netdev_command {
|
||||
XDP_SETUP_PROG,
|
||||
XDP_SETUP_PROG_HW,
|
||||
XDP_QUERY_PROG,
|
||||
XDP_QUERY_PROG_HW,
|
||||
/* BPF program for offload callbacks, invoked at program load time. */
|
||||
BPF_OFFLOAD_VERIFIER_PREP,
|
||||
BPF_OFFLOAD_TRANSLATE,
|
||||
@@ -843,7 +844,7 @@ struct netdev_bpf {
|
||||
struct bpf_prog *prog;
|
||||
struct netlink_ext_ack *extack;
|
||||
};
|
||||
/* XDP_QUERY_PROG */
|
||||
/* XDP_QUERY_PROG, XDP_QUERY_PROG_HW */
|
||||
struct {
|
||||
u32 prog_id;
|
||||
/* flags with which program was installed */
|
||||
@@ -3533,8 +3534,8 @@ struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
|
||||
typedef int (*bpf_op_t)(struct net_device *dev, struct netdev_bpf *bpf);
|
||||
int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
|
||||
int fd, u32 flags);
|
||||
void __dev_xdp_query(struct net_device *dev, bpf_op_t xdp_op,
|
||||
struct netdev_bpf *xdp);
|
||||
u32 __dev_xdp_query(struct net_device *dev, bpf_op_t xdp_op,
|
||||
enum bpf_netdev_command cmd);
|
||||
|
||||
int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb);
|
||||
int dev_forward_skb(struct net_device *dev, struct sk_buff *skb);
|
||||
|
Reference in New Issue
Block a user