From nobody Thu Oct 31 14:04:53 2024 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 4XfQjd22cMz5blyT; Thu, 31 Oct 2024 14:04:53 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XfQjd1VRsz43gs; Thu, 31 Oct 2024 14:04:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730383493; 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=RP3Y+SpXZC56VBuosBmXCb/fMMx4L6bdBvJlW/fE6FA=; b=dJ/LnwDrspWk5lqQft4nHQppTN7xa058S7z17FXzgMbX7UvOpYeYnCYcHm4yztFqXsGpvM 8SkytSktuvIWmHapYlJCnq7imTncgpRYZiSRHj7l21Li3XcXXyZK2SSMsTIG9cd6PZ+jCx yWoJDs0eK19XDquy2W2gFZsgIumD/bOFUWAfqbnG3kBzeYrBL6Q1r+/+Oty3BGktBznL04 iX6Guer4Ziku4nrI1DaEgSHo8eGvp7xn+7mC8f1JF9EJitj/Lu8KjPf6+8uegbB+/fa6qR wRc9QP/RnUoKnfIPBmfaDiVa9LdQpSdmfs26AE5EDUKS4OhQj1r2T1DVRqauOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730383493; 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=RP3Y+SpXZC56VBuosBmXCb/fMMx4L6bdBvJlW/fE6FA=; b=HPxW8WRj6rEf6bZsAAd2ju4Yve5EoTLKRAIvJEJOqJzT/LXJoj9CT6vZa/ILQhm85/NHDa a3iTms5c2PWrOKOaNTn1A+Uf3AYyAd9robcEGWSTzQG7eXpbCUtIHgaxh8UY2EdpEMU59+ EkvCgEkakVIJtQ4TcyrsAa100SY68mJUONJfCqfwTqn4GDz58KAkGIMb/93+IPWDbISIf5 3SLsdqZyIZWgOc8HK1747zw7wEHN5Ut+H9onppaDPh4YS/PULwDx7M2scR7OYKEQYG+xZ3 qfo1AS65aR+4+VUTipyxwIp2CTTV1MjRJbVtxBvNrWdyN0OgM9CKAMN3Qda5RA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730383493; a=rsa-sha256; cv=none; b=No6cTvMO18zPwP/mWtEnF5dLdu4qg4G15wveG6nMdDzunaDH0PQEvlWqBv3+8MhMk0eb86 b4CP9v8TvDp8XdH6O6aedbDK5q4KI/CKMfMo+thWgTn5MEVxmfIcqYBvHzZqo8yg0dMdFB nUdmCfpXdHuYbIdQEp2AYpG+IbMlj+lwyASuYqAkaBwa9o4hYBPKrNoDTnFACFGTE2pcpT rETr2I3iu5DVlL4b//TXlsl6Usb8N3poD+FNUAojBwMfZo4YcLQnvUwbwPeC81Kjp7e9Eu u9MrAKStxdgD5OLKreTzCqKbcYVJLw9W3mKDGuEKAwvrd+2BIIU+VjKRFPbLyg== 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 4XfQjd16fvzfY3; Thu, 31 Oct 2024 14:04:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49VE4rlT050116; Thu, 31 Oct 2024 14:04:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49VE4rse050111; Thu, 31 Oct 2024 14:04:53 GMT (envelope-from git) Date: Thu, 31 Oct 2024 14:04:53 GMT Message-Id: <202410311404.49VE4rse050111@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: abbfa0cb48b3 - stable/14 - sctp: cleanup the addition of addresses which are already known 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/14 X-Git-Reftype: branch X-Git-Commit: abbfa0cb48b36ecc8c1acf6bd61f7c9364919b2b Auto-Submitted: auto-generated The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=abbfa0cb48b36ecc8c1acf6bd61f7c9364919b2b commit abbfa0cb48b36ecc8c1acf6bd61f7c9364919b2b Author: Michael Tuexen AuthorDate: 2024-10-25 12:11:09 +0000 Commit: Michael Tuexen CommitDate: 2024-10-31 11:43:29 +0000 sctp: cleanup the addition of addresses which are already known No functional change intended. (cherry picked from commit a05620b0f67fe526350bf386882262ca8005533f) --- sys/netinet/sctp_pcb.c | 83 ++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index d32be9c791a9..90eb5822cbb7 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -520,56 +520,61 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, atomic_add_int(&SCTP_BASE_INFO(ipi_count_ifns), 1); } sctp_ifap = sctp_find_ifa_by_addr(addr, vrf->vrf_id, SCTP_ADDR_LOCKED); - if (sctp_ifap) { - /* Hmm, it already exists? */ - if ((sctp_ifap->ifn_p) && - (sctp_ifap->ifn_p->ifn_index == ifn_index)) { - SCTPDBG(SCTP_DEBUG_PCB4, "Using existing ifn %s (0x%x) for ifa %p\n", - sctp_ifap->ifn_p->ifn_name, ifn_index, - (void *)sctp_ifap); - if (new_sctp_ifnp == NULL) { - /* Remove the created one that we don't want */ - sctp_delete_ifn(sctp_ifnp); - } - if (sctp_ifap->localifa_flags & SCTP_BEING_DELETED) { - /* easy to solve, just switch back to active */ - SCTPDBG(SCTP_DEBUG_PCB4, "Clearing deleted ifa flag\n"); - sctp_ifap->localifa_flags = SCTP_ADDR_VALID; - sctp_ifap->ifn_p = sctp_ifnp; - atomic_add_int(&sctp_ifap->ifn_p->refcount, 1); - } - exit_stage_left: - SCTP_IPI_ADDR_WUNLOCK(); - if (new_sctp_ifnp != NULL) { - SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN); - } - SCTP_FREE(new_sctp_ifap, SCTP_M_IFA); - return (sctp_ifap); - } else { - if (sctp_ifap->ifn_p) { + if (sctp_ifap != NULL) { + /* The address being added is already or still known. */ + if (sctp_ifap->ifn_p != NULL) { + if (sctp_ifap->ifn_p->ifn_index == ifn_index) { + SCTPDBG(SCTP_DEBUG_PCB4, + "Using existing ifn %s (0x%x) for ifa %p\n", + sctp_ifap->ifn_p->ifn_name, ifn_index, + (void *)sctp_ifap); + if (new_sctp_ifnp == NULL) { + /* Remove the created one not used. */ + sctp_delete_ifn(sctp_ifnp); + } + if (sctp_ifap->localifa_flags & SCTP_BEING_DELETED) { + /* Switch back to active. */ + SCTPDBG(SCTP_DEBUG_PCB4, + "Clearing deleted ifa flag\n"); + sctp_ifap->localifa_flags = SCTP_ADDR_VALID; + sctp_ifap->ifn_p = sctp_ifnp; + atomic_add_int(&sctp_ifap->ifn_p->refcount, 1); + } + } else { /* * The last IFN gets the address, remove the * old one */ - SCTPDBG(SCTP_DEBUG_PCB4, "Moving ifa %p from %s (0x%x) to %s (0x%x)\n", - (void *)sctp_ifap, sctp_ifap->ifn_p->ifn_name, + SCTPDBG(SCTP_DEBUG_PCB4, + "Moving ifa %p from %s (0x%x) to %s (0x%x)\n", + (void *)sctp_ifap, + sctp_ifap->ifn_p->ifn_name, sctp_ifap->ifn_p->ifn_index, if_name, ifn_index); /* remove the address from the old ifn */ sctp_remove_ifa_from_ifn(sctp_ifap); /* move the address over to the new ifn */ sctp_add_ifa_to_ifn(sctp_ifnp, sctp_ifap); - goto exit_stage_left; - } else { - /* repair ifnp which was NULL ? */ - sctp_ifap->localifa_flags = SCTP_ADDR_VALID; - SCTPDBG(SCTP_DEBUG_PCB4, "Repairing ifn %p for ifa %p\n", - (void *)sctp_ifnp, (void *)sctp_ifap); - sctp_add_ifa_to_ifn(sctp_ifnp, sctp_ifap); } - goto exit_stage_left; - } - } + } else { + /* Repair ifn_p, which was NULL... */ + sctp_ifap->localifa_flags = SCTP_ADDR_VALID; + SCTPDBG(SCTP_DEBUG_PCB4, + "Repairing ifn %p for ifa %p\n", + (void *)sctp_ifnp, (void *)sctp_ifap); + sctp_add_ifa_to_ifn(sctp_ifnp, sctp_ifap); + } + SCTP_IPI_ADDR_WUNLOCK(); + if (new_sctp_ifnp != NULL) { + SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN); + } + SCTP_FREE(new_sctp_ifap, SCTP_M_IFA); + return (sctp_ifap); + } + KASSERT(sctp_ifnp != NULL, + ("sctp_add_addr_to_vrf: sctp_ifnp == NULL")); + KASSERT(sctp_ifap == NULL, + ("sctp_add_addr_to_vrf: sctp_ifap (%p) != NULL", sctp_ifap)); sctp_ifap = new_sctp_ifap; memset(sctp_ifap, 0, sizeof(struct sctp_ifa)); sctp_ifap->ifn_p = sctp_ifnp;