linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [RFC] net: bpf: make __bpf_skb_max_len(skb) an skb-independent constant
@ 2020-04-20 23:14 Maciej Żenczykowski
  2020-04-20 23:26 ` Maciej Żenczykowski
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Maciej Żenczykowski @ 2020-04-20 23:14 UTC (permalink / raw)
  To: Maciej Żenczykowski, Alexei Starovoitov, Daniel Borkmann
  Cc: Linux Network Development Mailing List, linux-kernel, David S . Miller

From: Maciej Żenczykowski <maze@google.com>

This function is used from:
  bpf_skb_adjust_room
  __bpf_skb_change_tail
  __bpf_skb_change_head

but in the case of forwarding we're likely calling these functions
during receive processing on ingress and bpf_redirect()'ing at
a later point in time to egress on another interface, thus these
mtu checks are for the wrong device.

This is particularly problematic if we're receiving on an L3 1500 mtu
cellular interface, trying to add an L2 header and forwarding to
an L3 mtu 1500 mtu wifi/ethernet device.  The mtu check prevents
us from adding the ethernet header prior to forwarding the packet.
After the packet has already been redirected, we'd need to add
an additional 2nd ebpf program on the target device's egress tc hook,
but then we'd also see non-redirected traffic and have no easy
way to tell apart normal egress with ethernet header packets
from forwarded ethernet headerless packets.

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/core/filter.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index ec567d1e6fb9..1e119a47f9fe 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3159,8 +3159,7 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 off, u32 len_diff,
 
 static u32 __bpf_skb_max_len(const struct sk_buff *skb)
 {
-	return skb->dev ? skb->dev->mtu + skb->dev->hard_header_len :
-			  SKB_MAX_ALLOC;
+	return SKB_MAX_ALLOC;
 }
 
 BPF_CALL_4(bpf_skb_adjust_room, struct sk_buff *, skb, s32, len_diff,
-- 
2.26.1.301.g55bc3eb7cb9-goog


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

end of thread, other threads:[~2020-05-07 21:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 23:14 [PATCH] [RFC] net: bpf: make __bpf_skb_max_len(skb) an skb-independent constant Maciej Żenczykowski
2020-04-20 23:26 ` Maciej Żenczykowski
2020-04-21 17:27 ` Jakub Kicinski
2020-04-21 20:36   ` Maciej Żenczykowski
2020-04-28 17:53     ` Alexei Starovoitov
2020-05-06 23:32 ` [PATCH v2] net: bpf: permit redirect from L3 to L2 devices at near max mtu Maciej Żenczykowski
2020-05-06 23:55   ` Jakub Kicinski
2020-05-07  0:47     ` Maciej Żenczykowski
2020-05-07  2:32       ` Maciej Żenczykowski
2020-05-07  2:36         ` [PATCH v3] net: bpf: permit redirect from ingress L3 to egress " Maciej Żenczykowski
2020-05-07 15:54           ` Daniel Borkmann
2020-05-07 16:46             ` Maciej Żenczykowski
2020-05-07 21:05               ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).