From nobody Tue Jul 30 09:47:27 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 4WY9PX0skjz5Rdsn; Tue, 30 Jul 2024 09:47:28 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WY9PX0RmZz4LT7; Tue, 30 Jul 2024 09:47:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722332848; 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=FgcJugcpUA7AQa/ANn2EyphqS3l7OBs65d1Ba/xWitk=; b=pV/ZulVEncwU394AX/fPob+YGHEZjkhOEqqb6fq6MPzGBcShw1AsQVcv0ZngPZz0liXVqT YadEpk5RuyX2s6YIcHrYC2Fgx6TsRMfv18zEGH04WP9OmDjSYegRKj9ZLPR93ov7YBLJ/q 65niY0EonkNfgTb7yVN64vY+0fmQlTiONTD04mkpXyLXwQjHVfgOuAFHgUz1IuDsBApz3H mQcVHE1UfQn5687FknolXRf5NlA8WTF0J2xCaVTPKtOz1RLiacRhUg0l9N1QViS4vF7YzB f4me08/Y4Mmti8INn2Vt2yJHQaVT10VVVH9kDCcgffFvhgfi5YqNZa9wQyk63w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722332848; a=rsa-sha256; cv=none; b=ZqPG9PN4kN96eeHtRMdqyjPhF5SJxhNhqXIpUXnzUm3ubeehl/7U737yyVKSVj1yD+8Exs W1CiRD1ZGFjC5zpl7m9fGV0FYJWMxEX4THePNYZuMVZXZxmlwMUVEUoPO3fQvQkI/1W1j6 dcaq4a17t1xvytGrycwAMUCOptBaTCObYTbDYH1TtGMrJqy8QQfBiW5NkKVGAQdINVIx2s 8moCGqaGL8UOOY0vNdgK3ojTPTFEc8Tp61IzipmGmVecpl6bzvafmdzy9neHjacBTgjhs8 7B/olNumuLtGf28P0GWHNveJeYokheTD/DnUDekLNtgDXVXLnFsmv8FWwrVRRg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722332848; 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=FgcJugcpUA7AQa/ANn2EyphqS3l7OBs65d1Ba/xWitk=; b=XdQDWXBHkjaTcbsPlzYJCPK267kLhfh69RDPiqVUVhxjlpwEwxCU0oqIJDJWkYsmDA2lQs /2CZIOB0GrOyRGLZFvuXrrabYGojFd9x2Z4wwZJKL16Zyhj1Rq5T/sWe33mI16SC6lEg4x 8lWAVo9qVHGpjHJNuzs/pUBVtruXqdhKEtmvv/vZC3U5/HD3PzyTjw2dn/NcMNVE6wLfIR JdsFeMU2kiHf4+cMYIhbrsB1N9PqM/gXAL+SuIwUx50RFxWGEytSLrGSsdkXt0HYbNAJ+g UK+RlOw+aKuEkf0V54tuQRlzbu3+jvr+uH/xHJ0/IrQNybcEkAZRgkp/WX91xg== 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 4WY9PW71cPz1C85; Tue, 30 Jul 2024 09:47:27 +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 46U9lRP8052864; Tue, 30 Jul 2024 09:47:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46U9lRi4052861; Tue, 30 Jul 2024 09:47:27 GMT (envelope-from git) Date: Tue, 30 Jul 2024 09:47:27 GMT Message-Id: <202407300947.46U9lRi4052861@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: 4d32367a44e0 - main - Revert "udp: improve handling of cached route" 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/main X-Git-Reftype: branch X-Git-Commit: 4d32367a44e0cd46591c04f98e706696d997457a Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=4d32367a44e0cd46591c04f98e706696d997457a commit 4d32367a44e0cd46591c04f98e706696d997457a Author: Michael Tuexen AuthorDate: 2024-07-30 09:46:27 +0000 Commit: Michael Tuexen CommitDate: 2024-07-30 09:46:27 +0000 Revert "udp: improve handling of cached route" This reverts commit 71867653008ce17a66a9c935e9dc29c1320bf48b. Two tests of the test suite are failing. Reverting the change until it is improved. --- sys/netinet/udp_usrreq.c | 20 ++++++++------------ sys/netinet6/udp6_usrreq.c | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 1666d4bd3142..9dad79e95b04 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1087,6 +1087,7 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, uint16_t cscov = 0; uint32_t flowid = 0; uint8_t flowtype = M_HASHTYPE_NONE; + bool use_cached_route; inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp_send: inp == NULL")); @@ -1115,21 +1116,16 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, sin = (struct sockaddr_in *)addr; /* - * In the following cases we want a write lock on the inp for either - * local operations or for possible route cache updates in the IPv6 - * output path: - * - on connected sockets (sin6 is NULL) for route cache updates, - * - when we are not bound to an address and source port (it is - * in_pcbinshash() which will require the write lock). - * - when we are using a mapped address on an IPv6 socket (for - * updating inp_vflag). + * udp_send() may need to temporarily bind or connect the current + * inpcb. As such, we don't know up front whether we will need the + * pcbinfo lock or not. Do any work to decide what is needed up + * front before acquiring any locks. * * We will need network epoch in either case, to safely lookup into * pcb hash. */ - if (sin == NULL || - (inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0) || - (flags & PRUS_IPV6) != 0) + use_cached_route = sin == NULL || (inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0); + if (use_cached_route || (flags & PRUS_IPV6) != 0) INP_WLOCK(inp); else INP_RLOCK(inp); @@ -1480,7 +1476,7 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, else UDP_PROBE(send, NULL, inp, &ui->ui_i, inp, &ui->ui_u); error = ip_output(m, inp->inp_options, - sin == NULL ? &inp->inp_route : NULL, ipflags, + use_cached_route ? &inp->inp_route : NULL, ipflags, inp->inp_moptions, inp); INP_UNLOCK(inp); NET_EPOCH_EXIT(et); diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index d7d85c6b3d13..414be35b5bef 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -937,7 +937,7 @@ udp6_send(struct socket *so, int flags_arg, struct mbuf *m, else UDP_PROBE(send, NULL, inp, ip6, inp, udp6); error = ip6_output(m, optp, - sin6 == NULL ? &inp->inp_route6 : NULL, flags, + INP_WLOCKED(inp) ? &inp->inp_route6 : NULL, flags, inp->in6p_moptions, NULL, inp); INP_UNLOCK(inp); NET_EPOCH_EXIT(et);