From nobody Wed Feb 16 10:02:54 2022 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 7522219DE5DA; Wed, 16 Feb 2022 10:02:54 +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 4JzD6Q2c5Bz4m7Q; Wed, 16 Feb 2022 10:02:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645005774; 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=avWNv9JpuazHzqrng4tPwC5He+EArhxDK1xoMIUqyYQ=; b=xEYmnECfEddQfrnIFkoT+NEhy+rRt+HNB6irMthjlmJTrc6IGG6hhsZHPAQ9Mfctvv3ZM8 XCP4mSDDjlQUbrEaNFyKp5Cvt5SDwpfv965UKBwPDFtABRj4LcxpBM9whglzMlfzUENEPA ILwxxcidHSHG5qZqwXjB3F7cWVVCtg2q5gz2VafYU/uLl/BajjFH/XjfgPOTnFDMtitxeb 678QSqGM25mD5aT8MsRK7dbWmM/YB9rItrPpFe9b7bhqJhmPCyUfKTWlfC1FyFUrLIeg6y /mQFvONHqtzzfSsR9mHqF1Kro9Vv7evsavy8+JZo5PQuAkA5ITTizxIzL9fZXw== 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 3991314622; Wed, 16 Feb 2022 10:02:54 +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 21GA2sgq020869; Wed, 16 Feb 2022 10:02:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21GA2sVK020868; Wed, 16 Feb 2022 10:02:54 GMT (envelope-from git) Date: Wed, 16 Feb 2022 10:02:54 GMT Message-Id: <202202161002.21GA2sVK020868@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 995cba5a0c96 - main - netinet: allow UDP tunnels to be removed 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 995cba5a0c9659e623b910429222ac2831a2ecca Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645005774; 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=avWNv9JpuazHzqrng4tPwC5He+EArhxDK1xoMIUqyYQ=; b=Hxe1ekvXWIP0hjY9wgy9EEiusuODhTJjr22kkqkSF6lEXa4xoUuPHg55MXkK1My325s/NW T3UlFOX14DA0J3i7SXR33OQC4KRBMqLVjdWa+TZdfnxYH1FbdLbgmS4o1XIH+9E7ZaFkQU +yxd78Dxs5jDFBP/pgE+aD2QY08Wlrg2xEyYBJTNjwFjZNYgju9Io83mXaOAwGnA13xysO 3X0zMpj7qccskgiNp0gLU4XAcsR8sDEuGxv2hwEFGA+aTDNUwpFXtHy+KJ+P1lpNuV93DD gyRDPUBVw8bDUzRpkrzIw7IHRsOUa+uaUrVDF3VfEBrDbcLIGTa4Tzi3Z6avtw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645005774; a=rsa-sha256; cv=none; b=wrkpvUoCntnDmIkiSZ1qkUeB8FSfGM7nHdcBt5ahy/xQOpsbtq4IZrAS636Kko1bKumJ2Z 8WppRysGXH1UMZfKhtdV2tj6WpgAjIeJX30I7uwiaux9mSocEtTDaYb4sB+qDtyCGPP1/q I2TBD1TDn62f42iUDxq5d6n31S5a5DyHxAUhUFTf1PQKVO01943z85KzsQ+6GzYa4Ngei/ hETeepgvsnVssvmYeTtkGf6L5dvoZ6JC9Ra1qWbcOyM/3OXO6r8Q+c1fcmvmp+76Q6mj0N /ZtZowQG6ZAsiCdBOPj+H/1lV8UA91pl8PhjBB9ylpLeOif+bvR1GHPnrLBZuQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=995cba5a0c9659e623b910429222ac2831a2ecca commit 995cba5a0c9659e623b910429222ac2831a2ecca Author: Kristof Provost AuthorDate: 2022-02-15 10:49:39 +0000 Commit: Kristof Provost CommitDate: 2022-02-16 09:59:04 +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 --- 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 ad5a2df7d4aa..f216e993b4f3 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1555,8 +1555,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); }