Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Feb 2022 10:02:54 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 995cba5a0c96 - main - netinet: allow UDP tunnels to be removed
Message-ID:  <202202161002.21GA2sVK020868@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=995cba5a0c9659e623b910429222ac2831a2ecca

commit 995cba5a0c9659e623b910429222ac2831a2ecca
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-02-15 10:49:39 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
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);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202202161002.21GA2sVK020868>