Commit 5b0e6629 authored by Martin KaFai Lau's avatar Martin KaFai Lau Committed by David S. Miller

bpf: virtio_net: Report bpf_prog ID during XDP_QUERY_PROG

Add support to virtio_net to report bpf_prog ID during XDP_QUERY_PROG.
Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Jason Wang <jasowang@redhat.com>
Acked-by: default avatarAlexei Starovoitov <ast@fb.com>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 821b2e29
...@@ -1955,16 +1955,18 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog, ...@@ -1955,16 +1955,18 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
return err; return err;
} }
static bool virtnet_xdp_query(struct net_device *dev) static u32 virtnet_xdp_query(struct net_device *dev)
{ {
struct virtnet_info *vi = netdev_priv(dev); struct virtnet_info *vi = netdev_priv(dev);
const struct bpf_prog *xdp_prog;
int i; int i;
for (i = 0; i < vi->max_queue_pairs; i++) { for (i = 0; i < vi->max_queue_pairs; i++) {
if (vi->rq[i].xdp_prog) xdp_prog = rtnl_dereference(vi->rq[i].xdp_prog);
return true; if (xdp_prog)
return xdp_prog->aux->id;
} }
return false; return 0;
} }
static int virtnet_xdp(struct net_device *dev, struct netdev_xdp *xdp) static int virtnet_xdp(struct net_device *dev, struct netdev_xdp *xdp)
...@@ -1973,7 +1975,8 @@ static int virtnet_xdp(struct net_device *dev, struct netdev_xdp *xdp) ...@@ -1973,7 +1975,8 @@ static int virtnet_xdp(struct net_device *dev, struct netdev_xdp *xdp)
case XDP_SETUP_PROG: case XDP_SETUP_PROG:
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_attached = 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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment