Commit 8092a12
net: Track skb metadata end separately from MAC offset
Currently skb metadata location is derived from the MAC header offset.
This breaks when L2 tunnel/tagging devices (VLAN, GRE, etc.) reset the MAC
offset after pulling the encapsulation header, making the metadata
inaccessible.
A naive fix would be to move metadata on every skb_pull() path. However, we
can avoid a memmove on L2 decapsulation if we can locate metadata
independently of the MAC offset.
Introduce a meta_end field in skb_shared_info to track where metadata ends,
decoupling it from mac_header. The new field takes 2 bytes out of the
existing 4 byte hole, with structure size unchanged if we reorder the
gso_type field.
Update skb_metadata_set() to record meta_end at the time of the call, and
adjust skb_data_move() and pskb_expand_head() to keep meta_end in sync with
head buffer layout.
Remove the now-unneeded metadata adjustment in skb_reorder_vlan_header().
Note that this breaks BPF skb metadata access through skb->data_meta when
there is a gap between meta_end and skb->data. Following BPF verifier
changes address this.
Also, we still need to relocate the metadata on encapsulation on forward
path. VLAN and QinQ have already been patched when fixing TC BPF helpers
[1], but other tagging/tunnel code still requires similar changes. This
will be done as a follow up.
Signed-off-by: Jakub Sitnicki <[email protected]>1 parent 9df90a8 commit 8092a12
2 files changed
+14
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
595 | 595 | | |
596 | 596 | | |
597 | 597 | | |
| 598 | + | |
598 | 599 | | |
599 | 600 | | |
600 | 601 | | |
| 602 | + | |
601 | 603 | | |
602 | 604 | | |
603 | 605 | | |
604 | 606 | | |
605 | 607 | | |
606 | | - | |
607 | 608 | | |
608 | 609 | | |
609 | 610 | | |
| |||
4499 | 4500 | | |
4500 | 4501 | | |
4501 | 4502 | | |
4502 | | - | |
| 4503 | + | |
4503 | 4504 | | |
4504 | 4505 | | |
4505 | 4506 | | |
| |||
4554 | 4555 | | |
4555 | 4556 | | |
4556 | 4557 | | |
| 4558 | + | |
| 4559 | + | |
| 4560 | + | |
| 4561 | + | |
| 4562 | + | |
| 4563 | + | |
| 4564 | + | |
4557 | 4565 | | |
4558 | 4566 | | |
| 4567 | + | |
4559 | 4568 | | |
4560 | 4569 | | |
4561 | 4570 | | |
| |||
4601 | 4610 | | |
4602 | 4611 | | |
4603 | 4612 | | |
| 4613 | + | |
4604 | 4614 | | |
4605 | 4615 | | |
4606 | 4616 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2306 | 2306 | | |
2307 | 2307 | | |
2308 | 2308 | | |
| 2309 | + | |
2309 | 2310 | | |
2310 | 2311 | | |
2311 | 2312 | | |
| |||
6219 | 6220 | | |
6220 | 6221 | | |
6221 | 6222 | | |
6222 | | - | |
6223 | | - | |
| 6223 | + | |
6224 | 6224 | | |
6225 | 6225 | | |
6226 | 6226 | | |
| |||
6233 | 6233 | | |
6234 | 6234 | | |
6235 | 6235 | | |
6236 | | - | |
6237 | | - | |
6238 | | - | |
6239 | | - | |
6240 | | - | |
6241 | | - | |
6242 | 6236 | | |
6243 | 6237 | | |
6244 | 6238 | | |
| |||
0 commit comments