* [PATCH bpf] bpf: fix XDP FD-based attach/detach logic around XDP_FLAGS_UPDATE_IF_NOEXIST
@ 2020-08-12 2:29 Andrii Nakryiko
2020-08-12 9:24 ` Toke Høiland-Jørgensen
0 siblings, 1 reply; 4+ messages in thread
From: Andrii Nakryiko @ 2020-08-12 2:29 UTC (permalink / raw)
To: bpf, netdev, ast, daniel
Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko, Stanislav Fomichev
Enforce XDP_FLAGS_UPDATE_IF_NOEXIST only if new BPF program to be attached is
non-NULL (i.e., we are not detaching a BPF program).
Reported-by: Stanislav Fomichev <sdf@google.com>
Fixes: d4baa9368a5e ("bpf, xdp: Extract common XDP program attachment logic")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
net/core/dev.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 7df6c9617321..b5d1129d8310 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8913,10 +8913,6 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
NL_SET_ERR_MSG(extack, "Active program does not match expected");
return -EEXIST;
}
- if ((flags & XDP_FLAGS_UPDATE_IF_NOEXIST) && cur_prog) {
- NL_SET_ERR_MSG(extack, "XDP program already attached");
- return -EBUSY;
- }
/* put effective new program into new_prog */
if (link)
@@ -8927,6 +8923,10 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
enum bpf_xdp_mode other_mode = mode == XDP_MODE_SKB
? XDP_MODE_DRV : XDP_MODE_SKB;
+ if ((flags & XDP_FLAGS_UPDATE_IF_NOEXIST) && cur_prog) {
+ NL_SET_ERR_MSG(extack, "XDP program already attached");
+ return -EBUSY;
+ }
if (!offload && dev_xdp_prog(dev, other_mode)) {
NL_SET_ERR_MSG(extack, "Native and generic XDP can't be active at the same time");
return -EEXIST;
--
2.24.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] bpf: fix XDP FD-based attach/detach logic around XDP_FLAGS_UPDATE_IF_NOEXIST
2020-08-12 2:29 [PATCH bpf] bpf: fix XDP FD-based attach/detach logic around XDP_FLAGS_UPDATE_IF_NOEXIST Andrii Nakryiko
@ 2020-08-12 9:24 ` Toke Høiland-Jørgensen
2020-08-12 15:47 ` Stanislav Fomichev
0 siblings, 1 reply; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-08-12 9:24 UTC (permalink / raw)
To: Andrii Nakryiko, bpf, netdev, ast, daniel
Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko, Stanislav Fomichev
Andrii Nakryiko <andriin@fb.com> writes:
> Enforce XDP_FLAGS_UPDATE_IF_NOEXIST only if new BPF program to be attached is
> non-NULL (i.e., we are not detaching a BPF program).
>
> Reported-by: Stanislav Fomichev <sdf@google.com>
> Fixes: d4baa9368a5e ("bpf, xdp: Extract common XDP program attachment logic")
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] bpf: fix XDP FD-based attach/detach logic around XDP_FLAGS_UPDATE_IF_NOEXIST
2020-08-12 9:24 ` Toke Høiland-Jørgensen
@ 2020-08-12 15:47 ` Stanislav Fomichev
2020-08-13 1:08 ` Alexei Starovoitov
0 siblings, 1 reply; 4+ messages in thread
From: Stanislav Fomichev @ 2020-08-12 15:47 UTC (permalink / raw)
To: Toke Høiland-Jørgensen
Cc: Andrii Nakryiko, bpf, Netdev, Alexei Starovoitov,
Daniel Borkmann, Andrii Nakryiko, Kernel Team
On Wed, Aug 12, 2020 at 2:24 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>
> Andrii Nakryiko <andriin@fb.com> writes:
>
> > Enforce XDP_FLAGS_UPDATE_IF_NOEXIST only if new BPF program to be attached is
> > non-NULL (i.e., we are not detaching a BPF program).
> >
> > Reported-by: Stanislav Fomichev <sdf@google.com>
> > Fixes: d4baa9368a5e ("bpf, xdp: Extract common XDP program attachment logic")
> > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
>
> Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
That fixed it for me, thank you!
Tested-by: Stanislav Fomichev <sdf@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] bpf: fix XDP FD-based attach/detach logic around XDP_FLAGS_UPDATE_IF_NOEXIST
2020-08-12 15:47 ` Stanislav Fomichev
@ 2020-08-13 1:08 ` Alexei Starovoitov
0 siblings, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2020-08-13 1:08 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: Toke Høiland-Jørgensen, Andrii Nakryiko, bpf, Netdev,
Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Kernel Team
On Wed, Aug 12, 2020 at 8:48 AM Stanislav Fomichev <sdf@google.com> wrote:
>
> On Wed, Aug 12, 2020 at 2:24 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
> >
> > Andrii Nakryiko <andriin@fb.com> writes:
> >
> > > Enforce XDP_FLAGS_UPDATE_IF_NOEXIST only if new BPF program to be attached is
> > > non-NULL (i.e., we are not detaching a BPF program).
> > >
> > > Reported-by: Stanislav Fomichev <sdf@google.com>
> > > Fixes: d4baa9368a5e ("bpf, xdp: Extract common XDP program attachment logic")
> > > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> >
> > Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
> That fixed it for me, thank you!
>
> Tested-by: Stanislav Fomichev <sdf@google.com>
Applied. Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-13 1:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-12 2:29 [PATCH bpf] bpf: fix XDP FD-based attach/detach logic around XDP_FLAGS_UPDATE_IF_NOEXIST Andrii Nakryiko
2020-08-12 9:24 ` Toke Høiland-Jørgensen
2020-08-12 15:47 ` Stanislav Fomichev
2020-08-13 1:08 ` Alexei Starovoitov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.