From nobody Thu Apr 14 19:52:35 2022 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 256391B377C0; Thu, 14 Apr 2022 19:52:36 +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 4KfVVX0bKcz4nqt; Thu, 14 Apr 2022 19:52:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649965956; 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=JnhXiDPi3DahvdbxmVNrL2jheoF4rFipTWUm1UUJ0Rg=; b=Y4Ijqi5XqDiREnBQ1ULi+VO+TpBfPx4/QQarTGYhT8+1hishTiwjhzW77jNFiDsnnQZZxG D/NypWkTySvJzFpE0t0ozSniNct/NO8mWqA7YkEyAVphvEJd6ACd72ZU6A4akJzh/H4z9T A2ZHE1gss4xPz9YJteR3grpjtD7zgZBrJfeq7cj9M7+IB03PpSPU/G10MoQNcZ8ohoXHFu DbFSnHSMr471CbuUJZzX19Xg/PELRnAzMG8sLj3WCOrk1T6hmq9wXR5qAumPx32UHYk5Tk QMECYzC4QuYgsubKx3xMhElAPM4L5TyhG/uuzbGq0JQOQmFXYO3vTebDj84Xvw== 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 E975326F1B; Thu, 14 Apr 2022 19:52:35 +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 23EJqZ1q067538; Thu, 14 Apr 2022 19:52:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23EJqZbp067537; Thu, 14 Apr 2022 19:52:35 GMT (envelope-from git) Date: Thu, 14 Apr 2022 19:52:35 GMT Message-Id: <202204141952.23EJqZbp067537@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 2486a7c0c733 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 2486a7c0c733fb67636c2004aa3300f417eb5cfe Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649965956; 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=JnhXiDPi3DahvdbxmVNrL2jheoF4rFipTWUm1UUJ0Rg=; b=Rl5hiiVnlsPeCdBvbXVgHZd4Q8StTVfS0l9048lyHgX5FLa+N6FotmV9Azpud/STBxQfq3 OMS1S3pTeMj99DRRjObGeu6fdHgnGIfCh9onQvGb3RtH/k/88YzXhkYZjs1oEU0mcV68F1 3GlzBDP9YiTNz0ALvUfq+XuSEEAIsoWvSvBC3fiBSq8fRNBeILYMyD3+QLYCni2W+2hEAa qe8UFEEVqylHKONbO2I57DV2cxOK6MHFVNXZh2t1zhK4FwuVXbvUxg4hgC9lt3ZdQPvhLn WnpATUueN/4yJLkrgSkxTDKczTXN2mq570tE/0rRPaiMJxBUDgb9VQ/a70GPlQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649965956; a=rsa-sha256; cv=none; b=XdnMfPOeKVEYMjCWB64FD/vDos6xZebxCbciRZqZvZFYg0WWoF6AcYrtgO7z2tbb6gs2TF fI8US8Sh/IKmyeYW0HXNAXo6wT8xJhSe8pVNKLVothlJlFoufr03rsRo91NgjMzN8S52M8 Op2ukQNJcb72wjj1s6hTx3giZJ/nXWgCq2G7yw5UelVU9/5z/KpBeIyxtI/2enAX8UyzxT +IeOjVATxCw+D3876pkEHGGenVdj0mM2PUXSurIR6Ymu/+xNL6mEsn7tiG9tEK24Zi8JUc W2/9622SRi6rf+FIyXbVf/11h6CdCIToiJGCLCOcHGiH41qiG9H/z42DBLmx4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=2486a7c0c733fb67636c2004aa3300f417eb5cfe commit 2486a7c0c733fb67636c2004aa3300f417eb5cfe Author: Michael Tuexen AuthorDate: 2022-04-14 19:50:10 +0000 Commit: Michael Tuexen CommitDate: 2022-04-14 19:52:25 +0000 sctp: cleanup MFC after: 3 days --- 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 34f727363b7b..e7e53e52b226 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();