From nobody Tue Jan 02 06:50:29 2024 X-Original-To: dev-commits-src-main@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 4T43QF5v4Pz56QjZ; Tue, 2 Jan 2024 06:50:29 +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 4T43QF5R9Bz3Ps5; Tue, 2 Jan 2024 06:50:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704178229; 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=YZq6M4HsSDg9TcEtgR6cAs6KconDIBU3FcNzXGUQ4V0=; b=PSXHMWc1NDHwRaRvZpp8G1YIqv8a623GY1gEJWOGQW7OTE3xbYvB8o/AttxGgbbfIQ9L1H mJv0pSQKmInWUtAyg87p2imobnC7TITZ1u2kpwPaLckxY2BqmzwqMFkV2MiWYMXFTmA16D HJ81TFZEGRFdnqmmYWEx7c55+ZhhKIqa9LNVQczv5Hgmigx+b5DRxH8GuPhw9p47XKxRug uY+gGBs669zb1UrifPNMbLryvDxozoON+Gmmk8RGSurGaCOnceJ7MV3QaUqsd01yafO5VJ +UOnnM/bIzPJx1RxX/a4IncZNBTC3IHdp/eOM6OINUEB0fm5ieEBYYFgK6uFvQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704178229; a=rsa-sha256; cv=none; b=gwbk/Yc7g00l9BcPpqe4KaNGznVmXYQaJ05ezTaFHBUfi8EgZMA2+KnSWp8bPG2BoimuSh Zkk2LDp0pdB2MkomGJexSzncyy42Y39zaeQKhv9F6lgU72JbdxmzQ2jwoJLqOJP8whViY3 FgDXyXMjmqXG38+gSPUXvp6Uge5GASzSoVq0pTO6Ix1HcecNg55JbQrXxUJIoq6BV/i4Ug RDR98l6Ktwj/nOv4QVksnMgqorUF9BEHyGfyI2ntnwb4K0y/avUHAQb3qlBhp4Rulc13fM t5FO9OQ4GpYV0MKfMepmpQdu6R1k4hXaT2wvPf9j7Cg2mqX+Tyy9uU9ab1oXDA== 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=1704178229; 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=YZq6M4HsSDg9TcEtgR6cAs6KconDIBU3FcNzXGUQ4V0=; b=gN+6a2GEvVSEEUoFDUZKPrZeotPZF8iScvCxSGYIHzDAx/Wd+mo5xXjC7KKq+zu0l64bYu FILFYOk2p6mhKrlRs4T3D7fVBc5+/livAOjkgrCHerZBbSZzeU1OQ0InBZRr3Ve8pCkNNr vZ0vvvG4/AXAQYgUbcK68a1L0vFuniKhz2ZofGbzV/jOwKeBl1YxwXW0dLebGOwVuwQZX1 s7PMxK+BW4X0KwhRlYEYEonq+lwxVoICOcA5LlGc/sTcuUtWdywPVnShBDLWaBw4MUssF5 NeeT1us6CChRT6ma5sEMF5MKLFh4H9TuI3jJDOpf6cl5vhwJ8j4gOolcDR2mZg== 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 4T43QF4Vlpzqbw; Tue, 2 Jan 2024 06:50:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4026oT7d020044; Tue, 2 Jan 2024 06:50:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4026oTCA020041; Tue, 2 Jan 2024 06:50:29 GMT (envelope-from git) Date: Tue, 2 Jan 2024 06:50:29 GMT Message-Id: <202401020650.4026oTCA020041@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 7df9da47e8f0 - main - Fix udp IPv4-mapped address List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7df9da47e8f04267330e1baa751f07c0c4aaf2ac Auto-Submitted: auto-generated The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=7df9da47e8f04267330e1baa751f07c0c4aaf2ac commit 7df9da47e8f04267330e1baa751f07c0c4aaf2ac Author: Richard Kümmel AuthorDate: 2023-12-15 11:49:45 +0000 Commit: Emmanuel Vadot CommitDate: 2024-01-02 06:49:12 +0000 Fix udp IPv4-mapped address Do not use the cached route if the destination isn't the same. This fix a problem where an UDP packet will be sent via the wrong route and interface if a previous one was sent via them. PR: 275774 Reviewed by: glebius, tuexen Sponsored by: Beckhoff Automation GmbH & Co. KG --- sys/netinet/udp_usrreq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index f7e0f7417818..affdb3b1f4c7 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1061,6 +1061,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")); @@ -1097,9 +1098,8 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, * 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); @@ -1450,7 +1450,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, - INP_WLOCKED(inp) ? &inp->inp_route : NULL, ipflags, + use_cached_route ? &inp->inp_route : NULL, ipflags, inp->inp_moptions, inp); INP_UNLOCK(inp); NET_EPOCH_EXIT(et);