Skip to contentSkip to conversation

selftests/bpf: reserve flags in bpf_skb_net_shrink

PATCH In review Willem de Bruijn 3 participants 5 messages Apr 12, 2019 – Apr 16, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: reserve flags in bpf_skb_net_shrink

From: Willem de Bruijn <[email protected]>

The ENCAP flags in bpf_skb_adjust_room are ignored on decap with bpf_skb_net_shrink. Reserve these bits for future use.

Fixes 868d523535c2d ("bpf: add bpf_skb_adjust_room encap flags")
---
 net/core/filter.c | 3 +++
 1 file changed, 3 insertions(+)
net/core/filter.c +3 -0
index 95a27fdf9a405..bd1f51907b83b 100644
@@ -3069,6 +3069,9 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 off, u32 len_diff,
 {
 	int ret;
 
+	if (flags & ~BPF_F_ADJ_ROOM_FIXED_GSO)
+		return -EINVAL;
+
 	if (skb_is_gso(skb) && !skb_is_gso_tcp(skb)) {
 		/* udp gso_size delineates datagrams, only allow if fixed */
 		if (!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) ||
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

The ENCAP flags in bpf_skb_adjust_room are ignored on decap with bpf_skb_net_shrink. Reserve these bits for future use.

Fixes 868d523535c2d ("bpf: add bpf_skb_adjust_room encap flags")

One thought; should we add a line to the growth-only flags in the description of bpf_skb_adjust_room (ENCAP_L[234]) in bpf.h; something like:

"This flag is valid for use with positive len_diff values only."

? Don't want to delay this patch with that suggestion though, I can spin that up later.

Quoted 22 lines
---
 net/core/filter.c | 3 +++
 1 file changed, 3 insertions(+)
net/core/filter.c +3 -0
index 95a27fdf9a405..bd1f51907b83b 100644
@@ -3069,6 +3069,9 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 off, u32 len_diff,
 {
 	int ret;
 
+	if (flags & ~BPF_F_ADJ_ROOM_FIXED_GSO)
+		return -EINVAL;
+
 	if (skb_is_gso(skb) && !skb_is_gso_tcp(skb)) {
 		/* udp gso_size delineates datagrams, only allow if fixed */
 		if (!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) ||
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
#2 lore raw
Quoted 5 lines · Alan Maguire
Quoted 2 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

Quoted 7 lines
Quoted 5 lines

The ENCAP flags in bpf_skb_adjust_room are ignored on decap with bpf_skb_net_shrink. Reserve these bits for future use.

Fixes 868d523535c2d ("bpf: add bpf_skb_adjust_room encap flags")

Thanks Alan.

Quoted 5 lines

One thought; should we add a line to the growth-only flags in the description of bpf_skb_adjust_room (ENCAP_L[234]) in bpf.h; something like:

"This flag is valid for use with positive len_diff values only."

That is easily gleaned from reading the code. I'm not a fan of documentation that duplicates concise readable code.

Plus, we'd add it and then remove again before long. We just need to implement the decap behavior. I actually maintain TC ingress decap code in C from that I wrote before eBPF and want to deprecate one day. But it will take some time to do properly.

maintainer
#3 lore raw
In reply to Willem de Bruijn
Quoted 7 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

The ENCAP flags in bpf_skb_adjust_room are ignored on decap with bpf_skb_net_shrink. Reserve these bits for future use.

Fixes 868d523535c2d ("bpf: add bpf_skb_adjust_room encap flags")

Applied, thanks! I fixed up $SUBJECT since it's not selftests. ;-)

Quoted 19 lines
---
 net/core/filter.c | 3 +++
 1 file changed, 3 insertions(+)
net/core/filter.c +3 -0
index 95a27fdf9a405..bd1f51907b83b 100644
@@ -3069,6 +3069,9 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 off, u32 len_diff,
 {
 	int ret;
 
+	if (flags & ~BPF_F_ADJ_ROOM_FIXED_GSO)
+		return -EINVAL;
+
 	if (skb_is_gso(skb) && !skb_is_gso_tcp(skb)) {
 		/* udp gso_size delineates datagrams, only allow if fixed */
 		if (!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) ||
#4 lore raw
Quoted 11 lines · Daniel Borkmann
Quoted 7 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

The ENCAP flags in bpf_skb_adjust_room are ignored on decap with bpf_skb_net_shrink. Reserve these bits for future use.

Fixes 868d523535c2d ("bpf: add bpf_skb_adjust_room encap flags")

Applied, thanks! I fixed up $SUBJECT since it's not selftests. ;-)

Ai, sorry about that :/ Thanks!