Repository navigation
Commit 58dfc90
bpf: add layer 2 encap support to bpf_skb_adjust_room
commit 868d523 ("bpf: add bpf_skb_adjust_room encap flags")
introduced support to bpf_skb_adjust_room for GSO-friendly GRE
and UDP encapsulation.
For GSO to work for skbs, the inner headers (mac and network) need to
be marked. For L3 encapsulation using bpf_skb_adjust_room, the mac
and network headers are identical. Here we provide a way of specifying
the inner mac header length for cases where L2 encap is desired. Such
an approach can support encapsulated ethernet headers, MPLS headers etc.
For example to convert from a packet of form [eth][ip][tcp] to
[eth][ip][udp][inner mac][ip][tcp], something like the following could
be done:
headroom = sizeof(iph) + sizeof(struct udphdr) + inner_maclen;
ret = bpf_skb_adjust_room(skb, headroom, BPF_ADJ_ROOM_MAC,
BPF_F_ADJ_ROOM_ENCAP_L4_UDP |
BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 |
BPF_F_ADJ_ROOM_ENCAP_L2(inner_maclen));
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>1 parent 166b5a7 commit 58dfc90
2 files changed
Lines changed: 18 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1523 | 1523 | | |
1524 | 1524 | | |
1525 | 1525 | | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
1526 | 1530 | | |
1527 | 1531 | | |
1528 | 1532 | | |
| |||
2664 | 2668 | | |
2665 | 2669 | | |
2666 | 2670 | | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
2667 | 2674 | | |
2668 | 2675 | | |
2669 | 2676 | | |
2670 | 2677 | | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
2671 | 2681 | | |
2672 | 2682 | | |
2673 | 2683 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2969 | 2969 | | |
2970 | 2970 | | |
2971 | 2971 | | |
2972 | | - | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
2973 | 2975 | | |
2974 | 2976 | | |
2975 | 2977 | | |
2976 | 2978 | | |
| 2979 | + | |
2977 | 2980 | | |
2978 | 2981 | | |
2979 | 2982 | | |
| |||
3008 | 3011 | | |
3009 | 3012 | | |
3010 | 3013 | | |
| 3014 | + | |
| 3015 | + | |
3011 | 3016 | | |
3012 | 3017 | | |
3013 | 3018 | | |
| |||
3016 | 3021 | | |
3017 | 3022 | | |
3018 | 3023 | | |
3019 | | - | |
3020 | | - | |
| 3024 | + | |
3021 | 3025 | | |
3022 | 3026 | | |
3023 | 3027 | | |
| |||
3031 | 3035 | | |
3032 | 3036 | | |
3033 | 3037 | | |
3034 | | - | |
| 3038 | + | |
3035 | 3039 | | |
3036 | 3040 | | |
3037 | 3041 | | |
| |||
0 commit comments