net: xdp: report flags program was installed with on query

Some drivers enforce that flags on program replacement and
removal must match the flags passed on install.  This leaves
the possibility open to enable simultaneous loading
of XDP programs both to HW and DRV.

Allow such drivers to report the flags back to the stack.

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:
Jakub Kicinski 2017-12-01 15:08:56 -08:00 коммит произвёл Daniel Borkmann
Родитель 118b4aa25d
Коммит 92f0292b35
2 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

@ -3392,6 +3392,7 @@ static int nfp_net_xdp(struct net_device *netdev, struct netdev_bpf *xdp)
if (nn->dp.bpf_offload_xdp) if (nn->dp.bpf_offload_xdp)
xdp->prog_attached = XDP_ATTACHED_HW; 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->flags = nn->xdp_prog ? nn->xdp_flags : 0;
return 0; return 0;
case BPF_OFFLOAD_VERIFIER_PREP: case BPF_OFFLOAD_VERIFIER_PREP:
return nfp_app_bpf_verifier_prep(nn->app, nn, xdp); return nfp_app_bpf_verifier_prep(nn->app, nn, xdp);

Просмотреть файл

@ -820,6 +820,8 @@ struct netdev_bpf {
struct { struct {
u8 prog_attached; u8 prog_attached;
u32 prog_id; u32 prog_id;
/* flags with which program was installed */
u32 prog_flags;
}; };
/* BPF_OFFLOAD_VERIFIER_PREP */ /* BPF_OFFLOAD_VERIFIER_PREP */
struct { struct {