git: 6873fec25b54 - stable/15 - tcp: minor cleanup
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 23 Oct 2026 17:17:11 UTC
The branch stable/15 has been updated by tuexen:
URL: https://cgit.FreeBSD.org/src/commit/?id=6873fec25b542c1780bf1723e253856631b4b896
commit 6873fec25b542c1780bf1723e253856631b4b896
Author: Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2026-08-24 19:00:14 +0000
Commit: Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-10-23 17:15:56 +0000
tcp: minor cleanup
Several cleanups in tcp_input_with_port():
* Don't assign m twice.
* Don't reassign pointers without having done pullup().
* While there, change the type of isipv6 to bool, since it is used
that way.
No functional change intended.
Reported by: Hannes Elfert
Reviewed by: pouria, Timo Völker, Nick Banks
Differential Revision: https://reviews.freebsd.org/D59142
(cherry picked from commit 191dad334c646457c012d0d0963505a2f2d73a98)
---
sys/netinet/tcp_input.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 15035cc913ab..a1786952741e 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -593,7 +593,7 @@ tcp6_input(struct mbuf **mp, int *offp, int proto)
int
tcp_input_with_port(struct mbuf **mp, int *offp, int proto, uint16_t port)
{
- struct mbuf *m = *mp;
+ struct mbuf *m;
struct tcphdr *th = NULL;
struct ip *ip = NULL;
struct inpcb *inp = NULL;
@@ -614,7 +614,7 @@ tcp_input_with_port(struct mbuf **mp, int *offp, int proto, uint16_t port)
struct m_tag *fwd_tag = NULL;
#ifdef INET6
struct ip6_hdr *ip6 = NULL;
- int isipv6;
+ bool isipv6;
#else
const void *ip6 = NULL;
#endif /* INET6 */
@@ -624,10 +624,6 @@ tcp_input_with_port(struct mbuf **mp, int *offp, int proto, uint16_t port)
NET_EPOCH_ASSERT();
-#ifdef INET6
- isipv6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0;
-#endif
-
off0 = *offp;
m = *mp;
*mp = NULL;
@@ -636,6 +632,7 @@ tcp_input_with_port(struct mbuf **mp, int *offp, int proto, uint16_t port)
m->m_pkthdr.tcp_tun_port = port;
#ifdef INET6
+ isipv6 = mtod(m, struct ip *)->ip_v == 6;
if (isipv6) {
ip6 = mtod(m, struct ip6_hdr *);
th = (struct tcphdr *)((caddr_t)ip6 + off0);
@@ -774,9 +771,9 @@ tcp_input_with_port(struct mbuf **mp, int *offp, int proto, uint16_t port)
TCPSTAT_INC(tcps_rcvshort);
return (IPPROTO_DONE);
}
+ ip6 = mtod(m, struct ip6_hdr *);
+ th = (struct tcphdr *)((caddr_t)ip6 + off0);
}
- ip6 = mtod(m, struct ip6_hdr *);
- th = (struct tcphdr *)((caddr_t)ip6 + off0);
}
#endif
#if defined(INET) && defined(INET6)