bpf: add bpf_skb_adjust_room mode BPF_ADJ_ROOM_MAC
bpf_skb_adjust_room net allows inserting room in an skb. Existing mode BPF_ADJ_ROOM_NET inserts room after the network header by pulling the skb, moving the network header forward and zeroing the new space. Add new mode BPF_ADJUST_ROOM_MAC that inserts room after the mac header. This allows inserting tunnel headers in front of the network header without having to recreate the network header in the original space, avoiding two copies. Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:

committed by
Alexei Starovoitov

parent
8142958954
commit
14aa31929b
@@ -1478,7 +1478,10 @@ union bpf_attr {
|
||||
* Grow or shrink the room for data in the packet associated to
|
||||
* *skb* by *len_diff*, and according to the selected *mode*.
|
||||
*
|
||||
* There is a single supported mode at this time:
|
||||
* There are two supported modes at this time:
|
||||
*
|
||||
* * **BPF_ADJ_ROOM_MAC**: Adjust room at the mac layer
|
||||
* (room space is added or removed below the layer 2 header).
|
||||
*
|
||||
* * **BPF_ADJ_ROOM_NET**: Adjust room at the network layer
|
||||
* (room space is added or removed below the layer 3 header).
|
||||
@@ -2627,6 +2630,7 @@ enum bpf_func_id {
|
||||
/* Mode for BPF_FUNC_skb_adjust_room helper. */
|
||||
enum bpf_adj_room_mode {
|
||||
BPF_ADJ_ROOM_NET,
|
||||
BPF_ADJ_ROOM_MAC,
|
||||
};
|
||||
|
||||
/* Mode for BPF_FUNC_skb_load_bytes_relative helper. */
|
||||
|
Reference in New Issue
Block a user