From 797b94504f4fd457aef694c236705c1bd850f2f7 Mon Sep 17 00:00:00 2001 From: Kristof Provost Date: Fri, 22 Apr 2022 16:11:31 +0200 Subject: [PATCH] udp6: allow udp_tun_func_t() to indicate it did not eat the packet Implement the same filter feature we implemented for UDP over IPv6 in 742e7210d. This was missed in that commit. Pointed out by: markj Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netinet6/udp6_usrreq.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 2f463da9b01b..20b78009854e 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -146,6 +146,7 @@ udp6_append(struct inpcb *inp, struct mbuf *n, int off, struct socket *so; struct mbuf *opts = NULL, *tmp_opts; struct udpcb *up; + bool filtered; INP_LOCK_ASSERT(inp); @@ -156,10 +157,11 @@ udp6_append(struct inpcb *inp, struct mbuf *n, int off, if (up->u_tun_func != NULL) { in_pcbref(inp); INP_RUNLOCK(inp); - (*up->u_tun_func)(n, off, inp, (struct sockaddr *)&fromsa[0], - up->u_tun_ctx); + filtered = (*up->u_tun_func)(n, off, inp, + (struct sockaddr *)&fromsa[0], up->u_tun_ctx); INP_RLOCK(inp); - return (in_pcbrele_rlocked(inp)); + if (filtered) + return (in_pcbrele_rlocked(inp)); } #if defined(IPSEC) || defined(IPSEC_SUPPORT) /* Check AH/ESP integrity. */