Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Feb 2023 22:39:30 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: 6e756956ced5 - stable/13 - sctp: #ifdef INET-only and INET6-only variables.
Message-ID:  <202302012239.311MdUvn087965@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=6e756956ced50d30ec5ca433373de4d7a7c58d3c

commit 6e756956ced50d30ec5ca433373de4d7a7c58d3c
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-04-13 23:08:21 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2023-02-01 22:38:50 +0000

    sctp: #ifdef INET-only and INET6-only variables.
    
    Duplicating the SCTP_PCB_FLAGS_BOUND_V6 check made the #ifdef's
    simpler than applying #ifdef's directly to the original code.  Modern
    compilers should cache the result rather than testing the flag twice.
    
    (cherry picked from commit 29a843177e108c688d7daaccac6ada4d16f01dca)
---
 sys/netinet/sctp_sysctl.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/sys/netinet/sctp_sysctl.c b/sys/netinet/sctp_sysctl.c
index 1314b700b467..0d435a36d940 100644
--- a/sys/netinet/sctp_sysctl.c
+++ b/sys/netinet/sctp_sysctl.c
@@ -188,8 +188,15 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st
 {
 	struct sctp_ifn *sctp_ifn;
 	struct sctp_ifa *sctp_ifa;
-	int loopback_scope, ipv4_local_scope, local_scope, site_scope;
-	int ipv4_addr_legal, ipv6_addr_legal;
+	int loopback_scope;
+#ifdef INET
+	int ipv4_local_scope;
+	int ipv4_addr_legal;
+#endif
+#ifdef INET6
+	int local_scope, site_scope;
+	int ipv6_addr_legal;
+#endif
 	struct sctp_vrf *vrf;
 	struct xsctp_laddr xladdr;
 	struct sctp_laddr *laddr;
@@ -199,28 +206,34 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st
 	if (stcb) {
 		/* use association specific values */
 		loopback_scope = stcb->asoc.scope.loopback_scope;
+#ifdef INET
 		ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope;
+		ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
+#endif
+#ifdef INET6
 		local_scope = stcb->asoc.scope.local_scope;
 		site_scope = stcb->asoc.scope.site_scope;
-		ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
 		ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal;
+#endif
 	} else {
 		/* Use generic values for endpoints. */
 		loopback_scope = 1;
+#ifdef INET
 		ipv4_local_scope = 1;
+		if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6 &&
+		    SCTP_IPV6_V6ONLY(inp))
+			ipv4_addr_legal = 0;
+		else
+			ipv4_addr_legal = 1;
+#endif
+#ifdef INET6
 		local_scope = 1;
 		site_scope = 1;
-		if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
+		if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6)
 			ipv6_addr_legal = 1;
-			if (SCTP_IPV6_V6ONLY(inp)) {
-				ipv4_addr_legal = 0;
-			} else {
-				ipv4_addr_legal = 1;
-			}
-		} else {
+		else
 			ipv6_addr_legal = 0;
-			ipv4_addr_legal = 1;
-		}
+#endif
 	}
 
 	/* neither Mac OS X nor FreeBSD support multiple routing functions */



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