The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=191dad334c646457c012d0d0963505a2f2d73a98
commit 191dad334c646457c012d0d0963505a2f2d73a98 Author: Michael Tuexen <[email protected]> AuthorDate: 2026-08-24 19:00:14 +0000 Commit: Michael Tuexen <[email protected]> CommitDate: 2026-08-24 19:05: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 MFC after: 1 week MFC to: stable/15 Differential Revision: https://reviews.freebsd.org/D59142 --- 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 1e60774b3fb0..17d20e5e6401 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -596,7 +596,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; @@ -617,7 +617,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 */ @@ -627,10 +627,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; @@ -639,6 +635,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); @@ -777,9 +774,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)
