public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 1/2] bpf: return correct -ENOBUFS from bpf_clone_redirect
@ 2023-09-08 21:00 Stanislav Fomichev
  2023-09-08 21:00 ` [PATCH bpf-next 2/2] selftests/bpf: update bpf_clone_redirect expected return code Stanislav Fomichev
  2023-09-09  7:31 ` [PATCH bpf-next 1/2] bpf: return correct -ENOBUFS from bpf_clone_redirect Martin KaFai Lau
  0 siblings, 2 replies; 10+ messages in thread
From: Stanislav Fomichev @ 2023-09-08 21:00 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa

Commit 151e887d8ff9 ("veth: Fixing transmit return status for dropped
packets") exposed the fact that bpf_clone_redirect is capable of
returning raw NET_XMIT_XXX return codes.

This is in the conflict with its UAPI doc which says the following:
"0 on success, or a negative error in case of failure."

Let's wrap dev_queue_xmit's return value (in __bpf_tx_skb) into
net_xmit_errno to make sure we correctly propagate NET_XMIT_DROP
as -ENOBUFS instead of 1.

Note, this is technically breaking existing UAPI where we used to
return 1 and now will do -ENOBUFS. The alternative is to
document that bpf_clone_redirect can return 1 for DROP and 2 for CN.

Reported-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
 net/core/filter.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index a094694899c9..9e297931b02f 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2129,6 +2129,9 @@ static inline int __bpf_tx_skb(struct net_device *dev, struct sk_buff *skb)
 	ret = dev_queue_xmit(skb);
 	dev_xmit_recursion_dec();
 
+	if (ret > 0)
+		ret = net_xmit_errno(ret);
+
 	return ret;
 }
 
-- 
2.42.0.283.g2d96d420d3-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-09-11 19:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-08 21:00 [PATCH bpf-next 1/2] bpf: return correct -ENOBUFS from bpf_clone_redirect Stanislav Fomichev
2023-09-08 21:00 ` [PATCH bpf-next 2/2] selftests/bpf: update bpf_clone_redirect expected return code Stanislav Fomichev
2023-09-09  7:31 ` [PATCH bpf-next 1/2] bpf: return correct -ENOBUFS from bpf_clone_redirect Martin KaFai Lau
2023-09-11 17:11   ` Stanislav Fomichev
2023-09-11 17:23     ` Daniel Borkmann
2023-09-11 17:41       ` Stanislav Fomichev
2023-09-11 18:36         ` Daniel Borkmann
2023-09-11 18:52           ` Stanislav Fomichev
2023-09-11 19:05             ` Daniel Borkmann
2023-09-11 18:08       ` Martin KaFai Lau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox