Skip to content

Commit 083d867

Browse files
netoptimizertsipa
authored andcommitted
Multiple BPF-helpers that can manipulate/increase the size of the SKB uses
__bpf_skb_max_len() as the max-length. This function limit size against the current net_device MTU (skb->dev->mtu). Often packets gets redirected to another net_device, that can have a larger MTU, and this is the MTU that should count. The MTU limiting at this stage seems wrong and redundant as the netstack will handle MTU checking elsewhere. Redirecting into sockmap by sk_skb programs already skip this MTU check. Keep what commit 0c6bc6e ("bpf: fix sk_skb programs without skb->dev assigned") did, and limit the max_len to SKB_MAX_ALLOC. Also notice that the max_len MTU check is already skipped for GRO SKBs (skb_is_gso), in both bpf_skb_adjust_room() and bpf_skb_change_head(). Thus, it is clearly safe to remove this check. Signed-off-by: Jesper Dangaard Brouer <[email protected]> --- net/core/filter.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
1 parent a7d6409 commit 083d867

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

net/core/filter.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3211,8 +3211,7 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 off, u32 len_diff,
32113211

32123212
static u32 __bpf_skb_max_len(const struct sk_buff *skb)
32133213
{
3214-
return skb->dev ? skb->dev->mtu + skb->dev->hard_header_len :
3215-
SKB_MAX_ALLOC;
3214+
return SKB_MAX_ALLOC;
32163215
}
32173216

32183217
BPF_CALL_4(bpf_skb_adjust_room, struct sk_buff *, skb, s32, len_diff,

0 commit comments

Comments
 (0)