From nobody Mon Feb 28 15:39:08 2022 X-Original-To: dev-commits-src-branches@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 6673A19EAF69; Mon, 28 Feb 2022 15:39:09 +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 4K6l0s1CC8z4s2Y; Mon, 28 Feb 2022 15:39:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646062749; 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=FrqtsvoFEoyQNnApSml3+qCFHj5J/KFlVe7Ux2OqQfU=; b=jknn7ALFL3U6AeL4Cr6vlH1Ufx2JZdzm9UJyLoU9W0JK0P62elMwFX/1OgESbAqslSnAbR I/YwhVDoYnk3AnekchDAyZGDoHSx+f3R38HgdsCDhkfFIa7vOXvMMmCjT/MPkgd2BvQIT3 5rAZM1ySHAtevesAvs8wvq/xPYVxobMTnh2O6cMxRm16d+FkPD8yDc/PYV/wbebKppYLLE zSg6KU/4WcjiFCV2m84Sc1uI+zRcp8/Ju6WEMkcSdjUpR8lOg2iEiYMoegdBX8GXm/f6m/ iFDCd9v4IPBjJjXZlQlj8hohU43DP5JtPYsopESXGJ1BeUXIkLa0b3vo0VEiKw== 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 E38641D8F0; Mon, 28 Feb 2022 15:39:08 +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 21SFd8Sq085397; Mon, 28 Feb 2022 15:39:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21SFd8aN085396; Mon, 28 Feb 2022 15:39:08 GMT (envelope-from git) Date: Mon, 28 Feb 2022 15:39:08 GMT Message-Id: <202202281539.21SFd8aN085396@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 4bca16a4fb52 - stable/13 - netinet: allow UDP tunnels to be removed List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4bca16a4fb521e7918be1d2d517aae32b8602faa Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646062749; 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=FrqtsvoFEoyQNnApSml3+qCFHj5J/KFlVe7Ux2OqQfU=; b=VNzFLFD8SD/wwNAu2j/7Rit8clhDmUYob3Fhmw3Ju2BdrJfGsKZA/2XhBp2DXS2BJ09PKv kz4z6eKcH0lZoajyW5WhW1ESoF+RnLiGnTgIWBunTZW3YTC0Rsfbonq7z3tariXEPrHSwg xgBQW6dajiYCxgqhZIXdpqitV/TP2gHsG02ZrSoWwFlAC/5vojc3CddHpCFcFWQvbHlHf1 e/VQVBNa+PCNdnf0TF72UebqKzPlbqS5p/02GEHdnpnKWHU9ouMafK6wPmJb/2ofVtnPeS SWZZPYPMolFfrNuGG4CpzSzsn45Ri61TDjgRRjdPUS56CC1kRmLddx3/VRdadw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646062749; a=rsa-sha256; cv=none; b=SfqMrXbEypQp9ECWbu8tOU+VjGGVuwodjFkpaI+e+Og0j6z2CvmMoEwCKpFz0wjL9d/+En BELOWMp5Y3IM0v63Oy4yEoSv1B60qR1M0wOEOHp1qRN6gdRw/8kthYr0T7qkX4huX5dren InJbeEYt1jZXmr8ea1XvKSlbvomh3ryOAeFGa1m7FZjEeNLuag2eShkjmTNZYSuoGRT5va 1sxvRu12P7nsZBOD265X/ZP9LQkg6DhhbmIlJPidCRkgZbziYgzxn5KiJGCae+f3yjb9NV 4VhiSydFFW72GOxzfnk8MZckpUGXgeD9vLU4fLSIKgwbAHRwtJCh4J83MOOtxA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=4bca16a4fb521e7918be1d2d517aae32b8602faa commit 4bca16a4fb521e7918be1d2d517aae32b8602faa Author: Kristof Provost AuthorDate: 2022-02-15 10:49:39 +0000 Commit: Kristof Provost CommitDate: 2022-02-28 15:38:05 +0000 netinet: allow UDP tunnels to be removed udp_set_kernel_tunneling() rejects new callbacks if one is already set. Allow callbacks to be cleared. The use case for this is OpenVPN DCO, where the socket is opened by userspace and then adopted by the kernel to run the tunnel. If the DCO interface is removed but userspace does not close the socket (something the kernel cannot prevent) the installed callbacks could be called with an invalidated context. Allow new functions to be set, but only if they're NULL (i.e. allow the callback functions to be cleared). Reviewed by: tuexen MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D34288 (cherry picked from commit 995cba5a0c9659e623b910429222ac2831a2ecca) --- sys/netinet/udp_usrreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 8ed7cefe6623..cb7d10f68c48 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1604,8 +1604,8 @@ udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f, udp_tun_icmp_t i, KASSERT(inp != NULL, ("udp_set_kernel_tunneling: inp == NULL")); INP_WLOCK(inp); up = intoudpcb(inp); - if ((up->u_tun_func != NULL) || - (up->u_icmp_func != NULL)) { + if ((f != NULL || i != NULL) && ((up->u_tun_func != NULL) || + (up->u_icmp_func != NULL))) { INP_WUNLOCK(inp); return (EBUSY); }