Index | Thread | Search

From:
Jan Klemkow <jan@openbsd.org>
Subject:
softlro: reduce max packet size by max_linkhdr
To:
tech@openbsd.org
Date:
Mon, 4 Aug 2025 18:42:18 +0200

Download raw body.

Thread
Hi,

While debugging with stsp@, we figured out:
SoftLRO produces to large packets in some corner cases.  The following
diff reduces the max IP packet size by max_linkhdr as tcp_output() do.

ok?

bye,
Jan

Index: netinet/tcp_input.c
===================================================================
RCS file: /cvs/src/sys/netinet/tcp_input.c,v
diff -u -p -r1.457 tcp_input.c
--- netinet/tcp_input.c	24 Jul 2025 21:34:07 -0000	1.457
+++ netinet/tcp_input.c	4 Aug 2025 16:35:28 -0000
@@ -4385,7 +4385,7 @@ tcp_softlro_compare(struct ether_extract
 			return 0;
 
 		/* Check max. IPv4 length. */
-		if (head->iplen + tail->iplen > IP_MAXPACKET)
+		if (head->iplen + tail->iplen > IP_MAXPACKET - max_linkhdr)
 			return 0;
 	} else if (head->ip6 && tail->ip6) {
 		/* Check IPv6 addresses. */
@@ -4397,7 +4397,7 @@ tcp_softlro_compare(struct ether_extract
 
 		/* Check max. IPv6 length. */
 		if ((head->iplen - head->iphlen) +
-		    (tail->iplen - tail->iphlen) > IPV6_MAXPACKET)
+		    (tail->iplen - tail->iphlen) > IPV6_MAXPACKET - max_linkhdr)
 			return 0;
 	} else {
 		/* Address family does not match. */