From nobody Mon Feb 28 15:39:09 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 80C3919EAF78; Mon, 28 Feb 2022 15:39:10 +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 4K6l0t1JrWz4sKM; Mon, 28 Feb 2022 15:39:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646062750; 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=zFm9L9Og6ct4YdPouuGrYP/B3GIgPLulkjAyKXGNa8E=; b=vkWo/ems1C/LlDWscauOR09lA+NWmvTCjt6XQImm+XKwVNVYWXtL7SWNCXe39XU25TThKM J8NU/N0yDFR6IukIwkrtqrNa0XGtLo4eJgBFKSu09xa0rzcm/jya7e4b6hJAAQTJ+ubkHV qOyNTOZGbSEWO0a3ZfKVYbggh7TGCAYVzGQkkJxQnfk04+64k4lnzKwaN0+b9ZeqT4aGE7 eceuTO7NUKz9HmppQ62t7CZAtyCfCmQwLyRoL5gxd195b5rF5v5sphcJAPSkz+mULu/S6x zl5Gdn7jw44vDk1rc+Xy0rpuLKRU7/n1lmfSGwknU5F6/hLqAJaK1njDIVrfXw== 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 E23851DE42; Mon, 28 Feb 2022 15:39:09 +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 21SFd91l085421; Mon, 28 Feb 2022 15:39:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21SFd9qi085420; Mon, 28 Feb 2022 15:39:09 GMT (envelope-from git) Date: Mon, 28 Feb 2022 15:39:09 GMT Message-Id: <202202281539.21SFd9qi085420@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: 2af412767144 - stable/12 - 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/12 X-Git-Reftype: branch X-Git-Commit: 2af412767144ecaaef970c10a146209e521d3dca Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646062750; 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=zFm9L9Og6ct4YdPouuGrYP/B3GIgPLulkjAyKXGNa8E=; b=ENYL012hnCEmE268SRIdoh9o0ZULq64n4IMd7Gow1GIvUh/OoJNDc7a5jbi2+gp2l/PN9M ZrhaaEm0M0Ir/kz46Cbyiu53J5TqMc6L3tUir7+XkAGjkdJ2WwpM2qrZaqd8WXyYNis3Ep oNKROxQd3ywrFDHiByvLOzBcrU5toKtsCvwhXcjF30RPCPvRfFZfj3JMg3rXPZmnCpmIsp iw+qjQjgrr29OcgcqWN99kOJnAQrXoDmRMPG9hX9Oevrau+5YamJ11XgTnBK8BI9aQ3OLa ctI8d9oKKIsPx29LWTLgrx7GabgWNLOeu+zqlPZ4iAIPJxyuSuo6I/mJO8aX2Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646062750; a=rsa-sha256; cv=none; b=ejovDSr4keWGlBdyKvOej/YBZYH8SfQn3bGZYAFb7vbQDhFwXL4/CvONO/pJ/Ihtn2YPpw MT3ErNYtcEsvbPZz+i+VOraS+hqUPiVIyshr1kt8iw6kd1NMxnSkutHETUp2qHdukYDMtk RqRQrtDDDnlGSps6xQMt9moLsma596zY8aCed5mj8NQyZRofYEJ7B1hUIkb5RIE8K45w81 2f8KQcJcX1PHpdmscWa8ttSNSwijgUU4QpvD+lNPeyv5ujA6if9vQk7izl4HvTOhkeyj/+ IIIWliRlQ8asFRik59bnnPk3I2sqN+ICFDfabwYcuvuv2uNFVhzjDySIVuwh5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2af412767144ecaaef970c10a146209e521d3dca commit 2af412767144ecaaef970c10a146209e521d3dca Author: Kristof Provost AuthorDate: 2022-02-15 10:49:39 +0000 Commit: Kristof Provost CommitDate: 2022-02-26 08:26:15 +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 f57a9059a7db..3c98fa005520 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1739,8 +1739,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); }