From nobody Fri Dec 10 10:24:51 2021 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 6B41018D2CD7; Fri, 10 Dec 2021 10:24:52 +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 4J9Rq818m6z4sVk; Fri, 10 Dec 2021 10:24:52 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0783718AE4; Fri, 10 Dec 2021 10:24:52 +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 1BAAOpZK091993; Fri, 10 Dec 2021 10:24:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BAAOpZg091992; Fri, 10 Dec 2021 10:24:51 GMT (envelope-from git) Date: Fri, 10 Dec 2021 10:24:51 GMT Message-Id: <202112101024.1BAAOpZg091992@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: 6f7ab8ac9e4f - stable/13 - sctp: cleanup, no functional change intended. 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: 6f7ab8ac9e4fbfdec036a02e4b7486bf8704e624 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639131892; 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=ORXRNe5m+aLNE/b6IHNWBGHMr7YEmvO4C5wyIDTjXLc=; b=sZI8VOa7ACOCCWjN7sf401IHVRJoIlhnavgYG2vmeKIkj2C2r+1rnKzXy/XoTqT405jjl1 zhKu4iAU4JzmD1qo1Mz3X1VxIAGD+Ie+MZawjOnkC28RCATBSSQP0g3NDPB/s3zwTfej0h h1aaa4ImG2v/XP0SZjT92iRN+y2DoY1p0D6gIcweZYtdIDIsH1Fzb5uTtSKcoasqyz/Tsv jRdOPnORFc3ch5mffORwt0wtvi3jGxcAImsRNuMCLeBKw/6NHtE+2rL2F1sqMA0MRCTMMw ujfcRdrx9diopwOH9YIrd3JufLjQPHcBEVK7D+cYFbnEVZQESppLW3yWby7NvQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639131892; a=rsa-sha256; cv=none; b=XF/tdYpLAOIwMR/KSB2uB7agJSOEIfNy833dQEFN15mwpzUD7hPNev6HZKjDu41BKlxHIa Rb2Qe5DTEzFHikV1itEn29ygfmevG5d0tlCAOUcHKZTqdFKnsGTNRqjfVmRJGfHsTxyEae BihSOIC87Xhhy7OK91w1jjJURa57JNYZA6ZDSs4oRa+YeDMe8YjqzuoCR7nHxdGBFf9CoT kxhVrxZjN/qvaepYRyUWe2L/NiyPPblqjvSlk3vUBjs8/vWCXMuP/DZcqdEGHCj7/NtaIb B159LaVKx/jdc8fux62AH0DNhV5nkaQlJOif3WvDoL2/OMoBRMppnV7+mGWPWg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=6f7ab8ac9e4fbfdec036a02e4b7486bf8704e624 commit 6f7ab8ac9e4fbfdec036a02e4b7486bf8704e624 Author: Michael Tuexen AuthorDate: 2021-12-01 08:19:40 +0000 Commit: Michael Tuexen CommitDate: 2021-12-10 10:23:42 +0000 sctp: cleanup, no functional change intended. MFC after: 1 week (cherry picked from commit a01b8859cbde9f2ded7b58a024d8fb46ada596bb) --- sys/netinet/sctp_usrreq.c | 59 ++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index 62d6996ab60d..2bc3cb457522 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -1228,7 +1228,7 @@ sctp_fill_up_addresses(struct sctp_inpcb *inp, size_t limit, struct sockaddr *addr) { - size_t size = 0; + size_t size; SCTP_IPI_ADDR_RLOCK(); /* fill up addresses for the endpoint's default vrf */ @@ -1238,17 +1238,17 @@ sctp_fill_up_addresses(struct sctp_inpcb *inp, return (size); } -static int -sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) +static size_t +sctp_max_size_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) { - int cnt = 0; - struct sctp_vrf *vrf = NULL; + struct sctp_vrf *vrf; + size_t size; /* - * In both sub-set bound an bound_all cases we return the MAXIMUM - * number of addresses that you COULD get. In reality the sub-set - * bound may have an exclusion list for a given TCB OR in the - * bound-all case a TCB may NOT include the loopback or other + * In both sub-set bound an bound_all cases we return the size of + * the maximum number of addresses that you could get. In reality + * the sub-set bound may have an exclusion list for a given TCB or + * in the bound-all case a TCB may NOT include the loopback or other * addresses as well. */ SCTP_IPI_ADDR_LOCK_ASSERT(); @@ -1256,6 +1256,7 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) if (vrf == NULL) { return (0); } + size = 0; if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { struct sctp_ifn *sctp_ifn; struct sctp_ifa *sctp_ifa; @@ -1268,17 +1269,17 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) case AF_INET: #ifdef INET6 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) - cnt += sizeof(struct sockaddr_in6); + size += sizeof(struct sockaddr_in6); else - cnt += sizeof(struct sockaddr_in); + size += sizeof(struct sockaddr_in); #else - cnt += sizeof(struct sockaddr_in); + size += sizeof(struct sockaddr_in); #endif break; #endif #ifdef INET6 case AF_INET6: - cnt += sizeof(struct sockaddr_in6); + size += sizeof(struct sockaddr_in6); break; #endif default: @@ -1295,17 +1296,17 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) case AF_INET: #ifdef INET6 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) - cnt += sizeof(struct sockaddr_in6); + size += sizeof(struct sockaddr_in6); else - cnt += sizeof(struct sockaddr_in); + size += sizeof(struct sockaddr_in); #else - cnt += sizeof(struct sockaddr_in); + size += sizeof(struct sockaddr_in); #endif break; #endif #ifdef INET6 case AF_INET6: - cnt += sizeof(struct sockaddr_in6); + size += sizeof(struct sockaddr_in6); break; #endif default: @@ -1313,19 +1314,19 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) } } } - return (cnt); + return (size); } -static int -sctp_count_max_addresses(struct sctp_inpcb *inp) +static size_t +sctp_max_size_addresses(struct sctp_inpcb *inp) { - int cnt = 0; + size_t size; SCTP_IPI_ADDR_RLOCK(); - /* count addresses for the endpoint's default VRF */ - cnt = sctp_count_max_addresses_vrf(inp, inp->def_vrf_id); + /* Maximum size of all addresses for the endpoint's default VRF */ + size = sctp_max_size_addresses_vrf(inp, inp->def_vrf_id); SCTP_IPI_ADDR_RUNLOCK(); - return (cnt); + return (size); } static int @@ -2145,7 +2146,7 @@ flags_out: SCTP_CHECK_AND_CAST(value, optval, uint32_t, *optsize); SCTP_INP_RLOCK(inp); - *value = sctp_count_max_addresses(inp); + *value = (uint32_t)sctp_max_size_addresses(inp); SCTP_INP_RUNLOCK(inp); *optsize = sizeof(uint32_t); break; @@ -2153,14 +2154,14 @@ flags_out: case SCTP_GET_REMOTE_ADDR_SIZE: { uint32_t *value; - size_t size; struct sctp_nets *net; + size_t size; SCTP_CHECK_AND_CAST(value, optval, uint32_t, *optsize); /* FIXME MT: change to sctp_assoc_value? */ SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t)*value); - if (stcb) { + if (stcb != NULL) { size = 0; /* Count the sizes */ TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { @@ -2210,7 +2211,7 @@ flags_out: SCTP_CHECK_AND_CAST(saddr, optval, struct sctp_getaddresses, *optsize); SCTP_FIND_STCB(inp, stcb, saddr->sget_assoc_id); - if (stcb) { + if (stcb != NULL) { left = *optsize - offsetof(struct sctp_getaddresses, addr); *optsize = offsetof(struct sctp_getaddresses, addr); addr = &saddr->addr[0].sa; @@ -2281,7 +2282,7 @@ flags_out: limit = *optsize - offsetof(struct sctp_getaddresses, addr); actual = sctp_fill_up_addresses(inp, stcb, limit, &saddr->addr[0].sa); - if (stcb) { + if (stcb != NULL) { SCTP_TCB_UNLOCK(stcb); } *optsize = offsetof(struct sctp_getaddresses, addr) + actual;