git: de69cf1dfd23 - stable/15 - tcp: cleanup

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Tue, 19 May 2026 14:44:50 UTC
The branch stable/15 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=de69cf1dfd2353c0af8023a094f985ea8a4cf15d

commit de69cf1dfd2353c0af8023a094f985ea8a4cf15d
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2026-02-22 17:44:10 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-05-19 14:43:46 +0000

    tcp: cleanup
    
    No functional change intended.
    
    Reviewed by:            pouria, rrs, Timo Völker
    Sponsored by:           Netflix, Inc.
    Differential Revision:  https://reviews.freebsd.org/D55415
    
    (cherry picked from commit c984c7593e11aa95f21f79bb5425a9d5e9181945)
---
 sys/netinet/tcp_subr.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 9a227218c525..371158ea4190 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -586,13 +586,14 @@ tcp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *inp,
 	if ((m->m_flags & M_PKTHDR) == 0) {
 		/* Can't handle one that is not a pkt hdr */
 		TCPSTAT_INC(tcps_tunneled_errs);
-		goto out;
+		m_freem(m);
+		return (true);
 	}
 	thlen = sizeof(struct tcphdr);
 	if (m->m_len < off + sizeof(struct udphdr) + thlen &&
 	    (m =  m_pullup(m, off + sizeof(struct udphdr) + thlen)) == NULL) {
 		TCPSTAT_INC(tcps_tunneled_errs);
-		goto out;
+		return (true);
 	}
 	iph = mtod(m, struct ip *);
 	uh = (struct udphdr *)((caddr_t)iph + off);
@@ -602,7 +603,7 @@ tcp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *inp,
 		m =  m_pullup(m, off + sizeof(struct udphdr) + thlen);
 		if (m == NULL) {
 			TCPSTAT_INC(tcps_tunneled_errs);
-			goto out;
+			return (true);
 		} else {
 			iph = mtod(m, struct ip *);
 			uh = (struct udphdr *)((caddr_t)iph + off);
@@ -624,9 +625,10 @@ tcp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *inp,
 #ifdef INET
 	case IPVERSION:
 		len = ntohs(iph->ip_len) - sizeof(struct udphdr);
-		if (len != m->m_pkthdr.len) {
+		if (__predict_false(len != m->m_pkthdr.len)) {
 			TCPSTAT_INC(tcps_tunneled_errs);
-			goto out;
+			m_freem(m);
+			return (true);
 		} else {
 			iph->ip_len = htons(len);
 			tcp_input_with_port(&m, &off, IPPROTO_TCP, port);
@@ -637,9 +639,11 @@ tcp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *inp,
 	case IPV6_VERSION >> 4:
 		ip6 = mtod(m, struct ip6_hdr *);
 		len = ntohs(ip6->ip6_plen) - sizeof(struct udphdr);
-		if (len + sizeof(struct ip6_hdr) != m->m_pkthdr.len) {
+		if (__predict_false(len + sizeof(struct ip6_hdr) !=
+		    m->m_pkthdr.len)) {
 			TCPSTAT_INC(tcps_tunneled_errs);
-			goto out;
+			m_freem(m);
+			return (true);
 		} else {
 			ip6->ip6_plen = htons(len);
 			tcp6_input_with_port(&m, &off, IPPROTO_TCP, port);
@@ -647,13 +651,9 @@ tcp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *inp,
 		break;
 #endif
 	default:
-		goto out;
+		m_freem(m);
 		break;
 	}
-	return (true);
-out:
-	m_freem(m);
-
 	return (true);
 }