Repository navigation
Commit 1d6e51e
bpf: Fix bpf_fib_lookup helper MTU check for SKB ctx
[ Upstream commit 2c0a10a ]
BPF end-user on Cilium slack-channel (Carlo Carraro) wants to use
bpf_fib_lookup for doing MTU-check, but *prior* to extending packet size,
by adjusting fib_params 'tot_len' with the packet length plus the expected
encap size. (Just like the bpf_check_mtu helper supports). He discovered
that for SKB ctx the param->tot_len was not used, instead skb->len was used
(via MTU check in is_skb_forwardable() that checks against netdev MTU).
Fix this by using fib_params 'tot_len' for MTU check. If not provided (e.g.
zero) then keep existing TC behaviour intact. Notice that 'tot_len' for MTU
check is done like XDP code-path, which checks against FIB-dst MTU.
V16:
- Revert V13 optimization, 2nd lookup is against egress/resulting netdev
V13:
- Only do ifindex lookup one time, calling dev_get_by_index_rcu().
V10:
- Use same method as XDP for 'tot_len' MTU check
Fixes: 4c79579 ("bpf: Change bpf_fib_lookup to return lookup status")
Reported-by: Carlo Carraro <colrack@gmail.com>
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/161287789444.790810.15247494756551413508.stgit@firesoul
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent e3c29af commit 1d6e51e
1 file changed
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5549 | 5549 | | |
5550 | 5550 | | |
5551 | 5551 | | |
| 5552 | + | |
5552 | 5553 | | |
5553 | 5554 | | |
5554 | 5555 | | |
5555 | 5556 | | |
5556 | 5557 | | |
5557 | 5558 | | |
5558 | 5559 | | |
| 5560 | + | |
| 5561 | + | |
| 5562 | + | |
5559 | 5563 | | |
5560 | 5564 | | |
5561 | 5565 | | |
5562 | | - | |
| 5566 | + | |
5563 | 5567 | | |
5564 | 5568 | | |
5565 | 5569 | | |
5566 | 5570 | | |
5567 | | - | |
| 5571 | + | |
5568 | 5572 | | |
5569 | 5573 | | |
5570 | 5574 | | |
5571 | 5575 | | |
5572 | | - | |
| 5576 | + | |
5573 | 5577 | | |
5574 | 5578 | | |
| 5579 | + | |
| 5580 | + | |
| 5581 | + | |
5575 | 5582 | | |
5576 | 5583 | | |
5577 | 5584 | | |
| |||
0 commit comments