diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -363,7 +363,7 @@ const union vxlan_sockaddr *, struct mbuf *); static int vxlan_transmit(struct ifnet *, struct mbuf *); static void vxlan_qflush(struct ifnet *); -static void vxlan_rcv_udp_packet(struct mbuf *, int, struct inpcb *, +static bool vxlan_rcv_udp_packet(struct mbuf *, int, struct inpcb *, const struct sockaddr *, void *); static int vxlan_input(struct vxlan_socket *, uint32_t, struct mbuf **, const struct sockaddr *); @@ -2758,7 +2758,7 @@ { } -static void +static bool vxlan_rcv_udp_packet(struct mbuf *m, int offset, struct inpcb *inpcb, const struct sockaddr *srcsa, void *xvso) { @@ -2802,6 +2802,8 @@ out: if (m != NULL) m_freem(m); + + return (true); } static int diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c --- a/sys/netinet/ip_gre.c +++ b/sys/netinet/ip_gre.c @@ -219,7 +219,7 @@ } } -static void +static bool in_gre_udp_input(struct mbuf *m, int off, struct inpcb *inp, const struct sockaddr *sa, void *ctx) { @@ -237,9 +237,11 @@ } if (sc != NULL && (GRE2IFP(sc)->if_flags & IFF_UP) != 0){ gre_input(m, off + sizeof(struct udphdr), IPPROTO_UDP, sc); - return; + return (true); } m_freem(m); + + return (true); } static int diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -7094,7 +7094,7 @@ } #endif -static void +static bool sctp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *inp, const struct sockaddr *sa SCTP_UNUSED, void *ctx SCTP_UNUSED) { @@ -7172,9 +7172,11 @@ goto out; break; } - return; + return (true); out: m_freem(m); + + return (true); } #ifdef INET diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -590,7 +590,7 @@ } } -static void +static bool tcp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *inp, const struct sockaddr *sa, void *ctx) { @@ -659,9 +659,11 @@ goto out; break; } - return; + return (true); out: m_freem(m); + + return (true); } static int diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -278,6 +278,7 @@ struct sockaddr_in6 udp_in6; #endif struct udpcb *up; + bool filtered; INP_LOCK_ASSERT(inp); @@ -288,10 +289,11 @@ if (up->u_tun_func != NULL) { in_pcbref(inp); INP_RUNLOCK(inp); - (*up->u_tun_func)(n, off, inp, (struct sockaddr *)&udp_in[0], + filtered = (*up->u_tun_func)(n, off, inp, (struct sockaddr *)&udp_in[0], up->u_tun_ctx); INP_RLOCK(inp); - return (in_pcbrele_rlocked(inp)); + if (filtered) + return (in_pcbrele_rlocked(inp)); } off += sizeof(struct udphdr); diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h --- a/sys/netinet/udp_var.h +++ b/sys/netinet/udp_var.h @@ -36,6 +36,7 @@ #ifndef _NETINET_UDP_VAR_H_ #define _NETINET_UDP_VAR_H_ +#include #include #include @@ -60,7 +61,8 @@ struct inpcb; struct mbuf; -typedef void(*udp_tun_func_t)(struct mbuf *, int, struct inpcb *, +#ifdef _KERNEL +typedef bool(*udp_tun_func_t)(struct mbuf *, int, struct inpcb *, const struct sockaddr *, void *); typedef void(*udp_tun_icmp_t)(int, struct sockaddr *, void *, void *); @@ -78,6 +80,7 @@ #define intoudpcb(ip) ((struct udpcb *)(ip)->inp_ppcb) #define sotoudpcb(so) (intoudpcb(sotoinpcb(so))) +#endif /* IPsec: ESP in UDP tunneling: */ #define UF_ESPINUDP_NON_IKE 0x00000001 /* w/ non-IKE marker .. */ diff --git a/sys/netinet6/ip6_gre.c b/sys/netinet6/ip6_gre.c --- a/sys/netinet6/ip6_gre.c +++ b/sys/netinet6/ip6_gre.c @@ -212,7 +212,7 @@ } } -static void +static bool in6_gre_udp_input(struct mbuf *m, int off, struct inpcb *inp, const struct sockaddr *sa, void *ctx) { @@ -226,7 +226,7 @@ dst = *(const struct sockaddr_in6 *)sa; if (sa6_embedscope(&dst, 0)) { m_freem(m); - return; + return (true); } CK_LIST_FOREACH(sc, &gs->list, chain) { if (IN6_ARE_ADDR_EQUAL(&sc->gre_oip6.ip6_dst, &dst.sin6_addr)) @@ -234,9 +234,11 @@ } if (sc != NULL && (GRE2IFP(sc)->if_flags & IFF_UP) != 0){ gre_input(m, off + sizeof(struct udphdr), IPPROTO_UDP, sc); - return; + return (true); } m_freem(m); + + return (true); } static int