[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1570515415-45593-4-git-send-email-sridhar.samudrala@intel.com>
Date: Mon, 7 Oct 2019 23:16:54 -0700
From: Sridhar Samudrala <sridhar.samudrala@...el.com>
To: magnus.karlsson@...el.com, bjorn.topel@...el.com,
netdev@...r.kernel.org, bpf@...r.kernel.org,
sridhar.samudrala@...el.com, intel-wired-lan@...ts.osuosl.org,
maciej.fijalkowski@...el.com, tom.herbert@...el.com
Subject: [PATCH bpf-next 3/4] libbpf: handle AF_XDP sockets created with XDP_DIRECT bind flag.
Don't allow an AF_XDP socket trying to bind with XDP_DIRECT bind
flag when a normal XDP program is already attached to the device,
Don't attach the default XDP program when AF_XDP socket is created
with XDP_DIRECT bind flag.
Signed-off-by: Sridhar Samudrala <sridhar.samudrala@...el.com>
---
tools/lib/bpf/xsk.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
index d5f4900e5c54..953b479040cd 100644
--- a/tools/lib/bpf/xsk.c
+++ b/tools/lib/bpf/xsk.c
@@ -454,6 +454,9 @@ static int xsk_setup_xdp_prog(struct xsk_socket *xsk)
return err;
if (!prog_id) {
+ if (xsk->config.bind_flags & XDP_DIRECT)
+ return 0;
+
err = xsk_create_bpf_maps(xsk);
if (err)
return err;
@@ -464,6 +467,9 @@ static int xsk_setup_xdp_prog(struct xsk_socket *xsk)
return err;
}
} else {
+ if (xsk->config.bind_flags & XDP_DIRECT)
+ return -EEXIST;
+
xsk->prog_fd = bpf_prog_get_fd_by_id(prog_id);
err = xsk_lookup_bpf_maps(xsk);
if (err) {
--
2.14.5
Powered by blists - more mailing lists