From nobody Wed Feb 01 22:40:08 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P6cLc5R0nz3cDXL; Wed, 1 Feb 2023 22:40:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P6cLc4zlLz4Kmx; Wed, 1 Feb 2023 22:40:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675291208; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cVFlH22pUS2Jp2qZzG6s8iV3bFHpEYJS5P7GlcSZJMA=; b=pcqendmxLErPg129NnW5KOcFn9OiCo27B4Q8yBsZ+gHtMYVQOgZqfEb3n6LHkZrbgeIZjW M+FAyMSLdbFH4FBKaN5FL2t+wQMhGQ0dPKJkym4y6VPymFgtoc2908EsHUYwDiiNGfpn2H sZpg305a7Eu7IugmiacaLyJaXDemOR63yczoP37ueZ4vKnaFEi9rvspPiZldP7Ath1raxg boxNKqPH/ji7u/5aQYZyoh8zOQakKwt3xo21S8k4A0yd2a3YHmZ2umQ2psJK7vVByLWBIg k7E+lIU7/lc0ZSYGokhQn77017xV/feVAKXNHv1s1qVvQxgngTHTpwMbRgIIug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675291208; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cVFlH22pUS2Jp2qZzG6s8iV3bFHpEYJS5P7GlcSZJMA=; b=su3iaw1JCfYdGmd3Jd0aKJPR9ApBTf2LpzPM3Hs1DjdCQjlFaOP2PNI6NJqwE2sY9qb0D2 KNR1P9+/PDLrbhkcuvFDhXKMLaLDdiwKAnrJ2cwT3OUDAx8TQYWXkeohRlVPqs1Vb1r6HP 2FfXnVLR8rSKdD+/WiJlsE42goSr6SE5IFEVcJlIRdPlW7Xzmc2/DXNQbWDBmZWjt31Zwe U4WnIWmc7GlVc4i7UPTB7kHrA6UNS2TRVzWhmJsfXqwO9xCJ4ZS/6MLFf1ca8yjanBeSEe vCrRcATQZqUz2ElSbGGPxIMW7uQnLQJPl0Z+XP+QiLcDDiQhbx5A4A92OaMVAw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675291208; a=rsa-sha256; cv=none; b=GNGoYtEh+cEFHU3EcM56EgaNp05KmPB3iRU9EHoZHVHgB7SpzjxlLEDLlzt3Cxgw/MbdCE StbRKNWp2UIaHeeNVBC+yTm/qf9IIcs/X7OO/lSGVjxzrZvOas5cUVFYdpOazC8idgwfFq WqbrNOjW9RfdPZgH6kmD3JfZM41eGD71zJYA5kKkW/scnfTvGuNSEb8smcpKEUR1sQkj5U /vWkT230SdaMGw+HNA8lG/4fBVE44YdOjyLohibmrEzwoEEJW1xsY3tjeVPKOqxeaZT8qy FEKyH/L7i7XXSHLeop8aAjRzHgS+Ki5kxyntG2LLKKSJVHK0llH/a7YQMRjZNA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P6cLc42MjzWSj; Wed, 1 Feb 2023 22:40:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 311Me8JR091475; Wed, 1 Feb 2023 22:40:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 311Me8hM091472; Wed, 1 Feb 2023 22:40:08 GMT (envelope-from git) Date: Wed, 1 Feb 2023 22:40:08 GMT Message-Id: <202302012240.311Me8hM091472@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: b9c95fbd43d8 - stable/13 - sctp: cleanup List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b9c95fbd43d8ec020fbad5686c07c35b7a9fcf97 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=b9c95fbd43d8ec020fbad5686c07c35b7a9fcf97 commit b9c95fbd43d8ec020fbad5686c07c35b7a9fcf97 Author: Michael Tuexen AuthorDate: 2022-04-14 19:50:10 +0000 Commit: Michael Tuexen CommitDate: 2023-02-01 22:39:45 +0000 sctp: cleanup (cherry picked from commit 2486a7c0c733fb67636c2004aa3300f417eb5cfe) --- sys/netinet/sctp_sysctl.c | 67 +++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/sys/netinet/sctp_sysctl.c b/sys/netinet/sctp_sysctl.c index 0d435a36d940..fcc02f315a1b 100644 --- a/sys/netinet/sctp_sysctl.c +++ b/sys/netinet/sctp_sysctl.c @@ -203,7 +203,7 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st int error; /* Turn on all the appropriate scope */ - if (stcb) { + if (stcb != NULL) { /* use association specific values */ loopback_scope = stcb->asoc.scope.loopback_scope; #ifdef INET @@ -220,41 +220,53 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st 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) +#endif + if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { +#ifdef INET6 ipv6_addr_legal = 1; - else +#endif +#ifdef INET + if (SCTP_IPV6_V6ONLY(inp)) { + ipv4_addr_legal = 0; + } else { + ipv4_addr_legal = 1; + } +#endif + } else { +#ifdef INET6 ipv6_addr_legal = 0; #endif +#ifdef INET + ipv4_addr_legal = 1; +#endif + } } - /* neither Mac OS X nor FreeBSD support multiple routing functions */ + /* Neither Mac OS X nor FreeBSD support multiple routing functions. */ if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) { SCTP_INP_RUNLOCK(inp); SCTP_INP_INFO_RUNLOCK(); - return (-1); + return (ENOENT); } if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { - if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) - /* Skip loopback if loopback_scope not set */ + if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) { + /* Skip loopback if loopback_scope not set. */ continue; + } LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { - if (stcb) { + if (stcb != NULL) { /* - * ignore if blacklisted at - * association level + * Ignore if blacklisted at + * association level. */ - if (sctp_is_addr_restricted(stcb, sctp_ifa)) + if (sctp_is_addr_restricted(stcb, sctp_ifa)) { continue; + } } switch (sctp_ifa->address.sa.sa_family) { #ifdef INET @@ -263,14 +275,16 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st struct sockaddr_in *sin; sin = &sctp_ifa->address.sin; - if (sin->sin_addr.s_addr == 0) + if (sin->sin_addr.s_addr == 0) { continue; + } if (prison_check_ip4(inp->ip_inp.inp.inp_cred, &sin->sin_addr) != 0) { continue; } - if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr))) + if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr))) { continue; + } } else { continue; } @@ -282,18 +296,21 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st struct sockaddr_in6 *sin6; sin6 = &sctp_ifa->address.sin6; - if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) + if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { continue; + } if (prison_check_ip6(inp->ip_inp.inp.inp_cred, &sin6->sin6_addr) != 0) { continue; } if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { - if (local_scope == 0) + if (local_scope == 0) { continue; + } } - if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))) + if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))) { continue; + } } else { continue; } @@ -307,7 +324,7 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st SCTP_INP_RUNLOCK(inp); SCTP_INP_INFO_RUNLOCK(); error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr)); - if (error) { + if (error != 0) { return (error); } else { SCTP_INP_INFO_RLOCK(); @@ -318,7 +335,7 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st } else { LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { /* ignore if blacklisted at association level */ - if (stcb && sctp_is_addr_restricted(stcb, laddr->ifa)) + if (stcb != NULL && sctp_is_addr_restricted(stcb, laddr->ifa)) continue; memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr)); memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore)); @@ -327,7 +344,7 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st SCTP_INP_RUNLOCK(inp); SCTP_INP_INFO_RUNLOCK(); error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr)); - if (error) { + if (error != 0) { return (error); } else { SCTP_INP_INFO_RLOCK(); @@ -341,7 +358,7 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st SCTP_INP_INFO_RUNLOCK(); error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr)); - if (error) { + if (error != 0) { return (error); } else { SCTP_INP_INFO_RLOCK();