Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Jul 2021 20:40:50 GMT
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 7751a6b58512 - stable/13 - tcp: fix alternate stack build with LINT-NO{INET, INET6, IP}
Message-ID:  <202107132040.16DKeoot034972@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by tuexen:

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

commit 7751a6b5851274c774c63aafd4dca70b68f2464d
Author:     Andrew Gallatin <gallatin@FreeBSD.org>
AuthorDate: 2021-07-07 17:02:08 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2021-07-13 20:00:50 +0000

    tcp: fix alternate stack build with LINT-NO{INET,INET6,IP}
    
    When fixing another bug, I noticed that the alternate
    TCP stacks do not build when various combinations of
    ipv4 and ipv6 are disabled.
    
    Reviewed by:            rrs, tuexen
    Differential Revision:  https://reviews.freebsd.org/D31094
    Sponsored by:            Netflix
    
    (cherry picked from commit b1e806c0ed960e1eb9ee889c7d0df3c168290c4f)
---
 sys/netinet/tcp_stacks/bbr.c             |  9 ++++---
 sys/netinet/tcp_stacks/rack.c            | 45 ++++++++++++++++++++++++--------
 sys/netinet/tcp_stacks/rack_bbr_common.c |  6 ++++-
 3 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c
index 1877ad1a9efd..ac8e3423ebbb 100644
--- a/sys/netinet/tcp_stacks/bbr.c
+++ b/sys/netinet/tcp_stacks/bbr.c
@@ -3515,13 +3515,16 @@ bbr_get_header_oh(struct tcp_bbr *bbr)
 	if (bbr->r_ctl.rc_inc_ip_oh) {
 		/* Do we include IP overhead? */
 #ifdef INET6
-		if (bbr->r_is_v6)
+		if (bbr->r_is_v6) {
 			seg_oh += sizeof(struct ip6_hdr);
-		else
+		} else
 #endif
+		{
+
 #ifdef INET
 			seg_oh += sizeof(struct ip);
 #endif
+		}
 	}
 	if (bbr->r_ctl.rc_inc_enet_oh) {
 		/* Do we include the ethernet overhead?  */
@@ -11956,7 +11959,7 @@ bbr_output_wtime(struct tcpcb *tp, const struct timeval *tv)
 	uint32_t tot_len = 0;
 	uint32_t rtr_cnt = 0;
 	uint32_t maxseg, pace_max_segs, p_maxseg;
-	int32_t csum_flags;
+	int32_t csum_flags = 0;
  	int32_t hw_tls;
 #if defined(IPSEC) || defined(IPSEC_SUPPORT)
 	unsigned ipsec_optlen = 0;
diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c
index 0badc42d3914..2f4668b027da 100644
--- a/sys/netinet/tcp_stacks/rack.c
+++ b/sys/netinet/tcp_stacks/rack.c
@@ -12043,7 +12043,9 @@ rack_init_fsb_block(struct tcpcb *tp, struct tcp_rack *rack)
 #ifdef INET
 	struct ip *ip = NULL;
 #endif
+#if defined(INET) || defined(INET6)
 	struct udphdr *udp = NULL;
+#endif
 
 	/* Ok lets fill in the fast block, it can only be used with no IP options! */
 #ifdef INET6
@@ -12067,6 +12069,7 @@ rack_init_fsb_block(struct tcpcb *tp, struct tcp_rack *rack)
 				  ip6, rack->r_ctl.fsb.th);
 	} else
 #endif				/* INET6 */
+#ifdef INET
 	{
 		rack->r_ctl.fsb.tcp_ip_hdr_len = sizeof(struct tcpiphdr);
 		ip = (struct ip *)rack->r_ctl.fsb.tcp_ip_hdr;
@@ -12086,6 +12089,7 @@ rack_init_fsb_block(struct tcpcb *tp, struct tcp_rack *rack)
 				  tp->t_port,
 				  ip, rack->r_ctl.fsb.th);
 	}
+#endif
 	rack->r_fsb_inited = 1;
 }
 
@@ -15226,7 +15230,7 @@ rack_fast_rsm_output(struct tcpcb *tp, struct tcp_rack *rack, struct rack_sendma
 	struct tcpopt to;
 	u_char opt[TCP_MAXOLEN];
 	uint32_t hdrlen, optlen;
-	int32_t slot, segsiz, max_val, tso = 0, error, flags, ulen = 0;
+	int32_t slot, segsiz, max_val, tso = 0, error = 0, flags, ulen = 0;
 	uint32_t us_cts;
 	uint32_t if_hw_tsomaxsegcount = 0, startseq;
 	uint32_t if_hw_tsomaxsegsize;
@@ -15706,7 +15710,7 @@ rack_fast_output(struct tcpcb *tp, struct tcp_rack *rack, uint64_t ts_val,
 	u_char opt[TCP_MAXOLEN];
 	uint32_t hdrlen, optlen;
 	int cnt_thru = 1;
-	int32_t slot, segsiz, len, max_val, tso = 0, sb_offset, error, flags, ulen = 0;
+	int32_t slot, segsiz, len, max_val, tso = 0, sb_offset, error = 0, flags, ulen = 0;
 	uint32_t us_cts, s_soff;
 	uint32_t if_hw_tsomaxsegcount = 0, startseq;
 	uint32_t if_hw_tsomaxsegsize;
@@ -16119,9 +16123,9 @@ rack_output(struct tcpcb *tp)
 	long tot_len_this_send = 0;
 #ifdef INET
 	struct ip *ip = NULL;
-#endif
 #ifdef TCPDEBUG
 	struct ipovly *ipov = NULL;
+#endif
 #endif
 	struct udphdr *udp = NULL;
 	struct tcp_rack *rack;
@@ -16130,7 +16134,10 @@ rack_output(struct tcpcb *tp)
 	uint8_t mark = 0;
 	uint8_t wanted_cookie = 0;
 	u_char opt[TCP_MAXOLEN];
-	unsigned ipoptlen, optlen, hdrlen, ulen=0;
+	unsigned ipoptlen, optlen, hdrlen;
+#if defined(INET) || defined(INET6)
+	unsigned ulen=0;
+#endif
 	uint32_t rack_seq;
 
 #if defined(IPSEC) || defined(IPSEC_SUPPORT)
@@ -17830,21 +17837,29 @@ send:
 #endif
 	if ((ipoptlen == 0) && (rack->r_ctl.fsb.tcp_ip_hdr) &&  rack->r_fsb_inited) {
 #ifdef INET6
-		if (isipv6)
+		if (isipv6) {
 			ip6 = (struct ip6_hdr *)rack->r_ctl.fsb.tcp_ip_hdr;
-		else
+		} else
 #endif				/* INET6 */
+		{
+#ifdef INET
 			ip = (struct ip *)rack->r_ctl.fsb.tcp_ip_hdr;
+#endif
+		}
 		th = rack->r_ctl.fsb.th;
 		udp = rack->r_ctl.fsb.udp;
 		if (udp) {
 #ifdef INET6
-			if (isipv6)
+			if (isipv6) {
 				ulen = hdrlen + len - sizeof(struct ip6_hdr);
-			else
+			} else
 #endif				/* INET6 */
+			{
+#ifdef INET
 				ulen = hdrlen + len - sizeof(struct ip);
-			udp->uh_ulen = htons(ulen);
+				udp->uh_ulen = htons(ulen);
+#endif
+			}
 		}
 	} else {
 #ifdef INET6
@@ -17863,6 +17878,7 @@ send:
 		} else
 #endif				/* INET6 */
 		{
+#ifdef INET
 			ip = mtod(m, struct ip *);
 #ifdef TCPDEBUG
 			ipov = (struct ipovly *)ip;
@@ -17877,6 +17893,7 @@ send:
 			} else
 				th = (struct tcphdr *)(ip + 1);
 			tcpip_fillheaders(inp, tp->t_port, ip, th);
+#endif				/* INET */
 		}
 	}
 	/*
@@ -17915,11 +17932,15 @@ send:
 		if (len > 0 && SEQ_GEQ(tp->snd_nxt, tp->snd_max) &&
 		    (sack_rxmit == 0)) {
 #ifdef INET6
-			if (isipv6)
+			if (isipv6) {
 				ip6->ip6_flow |= htonl(IPTOS_ECN_ECT0 << 20);
-			else
+			} else
 #endif
+			{
+#ifdef INET
 				ip->ip_tos |= IPTOS_ECN_ECT0;
+#endif
+			}
 			KMOD_TCPSTAT_INC(tcps_ecn_ect0);
 			/*
 			 * Reply with proper ECN notifications.
@@ -18024,7 +18045,9 @@ send:
 			ip6 = mtod(m, struct ip6_hdr *);
 		else
 #endif				/* INET6 */
+#ifdef INET
 			ip = mtod(m, struct ip *);
+#endif				/* INET */
 		th = (struct tcphdr *)(cpto + ((uint8_t *)rack->r_ctl.fsb.th - rack->r_ctl.fsb.tcp_ip_hdr));
 		/* If we have a udp header lets set it into the mbuf as well */
 		if (udp)
diff --git a/sys/netinet/tcp_stacks/rack_bbr_common.c b/sys/netinet/tcp_stacks/rack_bbr_common.c
index 501d29ac48da..d9f48f733e93 100644
--- a/sys/netinet/tcp_stacks/rack_bbr_common.c
+++ b/sys/netinet/tcp_stacks/rack_bbr_common.c
@@ -166,17 +166,21 @@ static int
 ctf_get_enet_type(struct ifnet *ifp, struct mbuf *m)
 {
 	struct ether_header *eh;
-	struct tcphdr *th;
 #ifdef INET6
 	struct ip6_hdr *ip6 = NULL;	/* Keep compiler happy. */
 #endif
 #ifdef INET
 	struct ip *ip = NULL;		/* Keep compiler happy. */
 #endif
+#if defined(INET) || defined(INET6)
+	struct tcphdr *th;
 	int32_t tlen;
 	uint16_t drop_hdrlen;
+#endif
 	uint16_t etype;
+#ifdef INET
 	uint8_t iptos;
+#endif
 
 	/* Is it the easy way? */
 	if (m->m_flags & M_LRO_EHDRSTRP)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107132040.16DKeoot034972>