summaryrefslogtreecommitdiffstats
path: root/sys/netinet/udp_usrreq.c
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2020-06-21 05:17:15 +0000
committerdlg <dlg@openbsd.org>2020-06-21 05:17:15 +0000
commit63a788dae37771312ea8081c21a6a4bf68bd1bbb (patch)
tree4ef21b23f58d168d98003ae209843e35e8141954 /sys/netinet/udp_usrreq.c
parentThe onboard interfaces on T7/S7 machines don't provide a valid MAC address (diff)
downloadwireguard-openbsd-63a788dae37771312ea8081c21a6a4bf68bd1bbb.tar.xz
wireguard-openbsd-63a788dae37771312ea8081c21a6a4bf68bd1bbb.zip
if an inp_upcall is set, let it look at and maybe steal the udp packet.
i wrote the original version of this, but it was tweaked by Matt Dunwoodie and Jason A. Donenfeld for use with wireguard.
Diffstat (limited to '')
-rw-r--r--sys/netinet/udp_usrreq.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index a2cc53a92f8..ee65e5f8d1c 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.257 2019/12/06 14:43:14 tobhe Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.258 2020/06/21 05:17:15 dlg Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -583,12 +583,20 @@ bad:
void
udp_sbappend(struct inpcb *inp, struct mbuf *m, struct ip *ip,
- struct ip6_hdr *ip6, int iphlen, struct udphdr *uh,
+ struct ip6_hdr *ip6, int hlen, struct udphdr *uh,
struct sockaddr *srcaddr, u_int32_t ipsecflowinfo)
{
struct socket *so = inp->inp_socket;
struct mbuf *opts = NULL;
+ hlen += sizeof(*uh);
+
+ if (inp->inp_upcall != NULL) {
+ m = (*inp->inp_upcall)(inp->inp_upcall_arg, m, ip, ip6, uh, hlen);
+ if (m == NULL)
+ return;
+ }
+
#ifdef INET6
if (ip6 && (inp->inp_flags & IN6P_CONTROLOPTS ||
so->so_options & SO_TIMESTAMP))
@@ -625,7 +633,7 @@ udp_sbappend(struct inpcb *inp, struct mbuf *m, struct ip *ip,
sizeof(u_int32_t), IP_IPSECFLOWINFO, IPPROTO_IP);
}
#endif
- m_adj(m, iphlen + sizeof(struct udphdr));
+ m_adj(m, hlen);
if (sbappendaddr(so, &so->so_rcv, srcaddr, m, opts) == 0) {
udpstat_inc(udps_fullsock);
m_freem(m);