git: c984c7593e11 - main - tcp: cleanup

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Sun, 22 Feb 2026 17:46:09 UTC
The branch main has been updated by tuexen:

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

commit c984c7593e11aa95f21f79bb5425a9d5e9181945
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2026-02-22 17:44:10 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-02-22 17:44:10 +0000

    tcp: cleanup
    
    No functional change intended.
    
    Reviewed by:            pouria, rrs, Timo Völker
    MFC after:              1 week
    Sponsored by:           Netflix, Inc.
    Differential Revision:  https://reviews.freebsd.org/D55415
---
 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 6a6eef32e777..c759e9a1cd6b 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -582,13 +582,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);
@@ -598,7 +599,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);
@@ -620,9 +621,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);
@@ -633,9 +635,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);
@@ -643,13 +647,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);
 }