[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170613210841.509578-5-kafai@fb.com>
Date: Tue, 13 Jun 2017 14:08:36 -0700
From: Martin KaFai Lau <kafai@...com>
To: <netdev@...r.kernel.org>
CC: Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>, <kernel-team@...com>,
John Fastabend <john.fastabend@...il.com>,
Jason Wang <jasowang@...hat.com>
Subject: [PATCH v2 net-next 4/9] 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: Martin KaFai Lau <kafai@...com>
Cc: John Fastabend <john.fastabend@...il.com>
Cc: Jason Wang <jasowang@...hat.com>
Acked-by: Alexei Starovoitov <ast@...com>
Acked-by: Daniel Borkmann <daniel@...earbox.net>
---
drivers/net/virtio_net.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 1f8c15cb63b0..deecd24f2db8 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1955,16 +1955,18 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
return err;
}
-static bool virtnet_xdp_query(struct net_device *dev)
+static u32 virtnet_xdp_query(struct net_device *dev)
{
+ const struct bpf_prog *xdp_prog;
struct virtnet_info *vi = netdev_priv(dev);
int i;
for (i = 0; i < vi->max_queue_pairs; i++) {
- if (vi->rq[i].xdp_prog)
- return true;
+ xdp_prog = rtnl_dereference(vi->rq[i].xdp_prog);
+ if (xdp_prog)
+ return xdp_prog->aux->id;
}
- return false;
+ return 0;
}
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:
return virtnet_xdp_set(dev, xdp->prog, xdp->extack);
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;
default:
return -EINVAL;
--
2.9.3
Powered by blists - more mailing lists