Skip to contentSkip to conversation

bpf: fix error check in bpf_tcp_gen_syncookie

bpf-next Applied Petar Penkov 3 participants 3 messages Aug 27, 2019 – Aug 30, 2019

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

From: Petar Penkov <[email protected]>

If a SYN cookie is not issued by tcp_v#_gen_syncookie, then the return value will be exactly 0, rather than <= 0. Let's change the check to reflect that, especially since mss is an unsigned value and cannot be negative.

Fixes 70d66244317e ("bpf: add bpf_tcp_gen_syncookie helper")
---
 net/core/filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/filter.c +1 -1
index 0c1059cdad3d..17bc9af8f156 100644
@@ -5903,7 +5903,7 @@ BPF_CALL_5(bpf_tcp_gen_syncookie, struct sock *, sk, void *, iph, u32, iph_len,
 	default:
 		return -EPROTONOSUPPORT;
 	}
-	if (mss <= 0)
+	if (mss == 0)
 		return -ENOENT;
 
 	return cookie | ((u64)mss << 32);
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
Acked-by
#1 lore raw
Quoted 11 lines · Petar Penkov

From: Petar Penkov <[email protected]>

If a SYN cookie is not issued by tcp_v#_gen_syncookie, then the return value will be exactly 0, rather than <= 0. Let's change the check to reflect that, especially since mss is an unsigned value and cannot be negative.

Fixes 70d66244317e ("bpf: add bpf_tcp_gen_syncookie helper")
maintainer Applied
#2 lore raw
In reply to Petar Penkov
Quoted 10 lines · Petar Penkov

From: Petar Penkov <[email protected]>

If a SYN cookie is not issued by tcp_v#_gen_syncookie, then the return value will be exactly 0, rather than <= 0. Let's change the check to reflect that, especially since mss is an unsigned value and cannot be negative.

Fixes 70d66244317e ("bpf: add bpf_tcp_gen_syncookie helper")

Applied, thanks!