Module Name: src
Committed By: riastradh
Date: Thu Aug 20 21:21:33 UTC 2020
Modified Files:
src/sys/conf: files
src/sys/net: Makefile files.net if_types.h
src/sys/netinet: in.c in.h in_pcb.c in_pcb.h in_pcb_hdr.h ip_encap.c
udp_usrreq.c udp_var.h
src/sys/netinet6: in6_pcb.h udp6_usrreq.c
src/sys/rump/kern/lib/libcrypto: Makefile
src/sys/rump/net: Makefile.rumpnetcomp
src/tests/net: Makefile
src/usr.sbin: Makefile
Log Message:
[ozaki-r] Changes to the kernel core for wireguard
To generate a diff of this commit:
cvs rdiff -u -r1.1274 -r1.1275 src/sys/conf/files
cvs rdiff -u -r1.42 -r1.43 src/sys/net/Makefile
cvs rdiff -u -r1.25 -r1.26 src/sys/net/files.net
cvs rdiff -u -r1.29 -r1.30 src/sys/net/if_types.h
cvs rdiff -u -r1.236 -r1.237 src/sys/netinet/in.c
cvs rdiff -u -r1.109 -r1.110 src/sys/netinet/in.h
cvs rdiff -u -r1.183 -r1.184 src/sys/netinet/in_pcb.c
cvs rdiff -u -r1.66 -r1.67 src/sys/netinet/in_pcb.h
cvs rdiff -u -r1.13 -r1.14 src/sys/netinet/in_pcb_hdr.h
cvs rdiff -u -r1.72 -r1.73 src/sys/netinet/ip_encap.c
cvs rdiff -u -r1.258 -r1.259 src/sys/netinet/udp_usrreq.c
cvs rdiff -u -r1.45 -r1.46 src/sys/netinet/udp_var.h
cvs rdiff -u -r1.50 -r1.51 src/sys/netinet6/in6_pcb.h
cvs rdiff -u -r1.147 -r1.148 src/sys/netinet6/udp6_usrreq.c
cvs rdiff -u -r1.13 -r1.14 src/sys/rump/kern/lib/libcrypto/Makefile
cvs rdiff -u -r1.20 -r1.21 src/sys/rump/net/Makefile.rumpnetcomp
cvs rdiff -u -r1.34 -r1.35 src/tests/net/Makefile
cvs rdiff -u -r1.283 -r1.284 src/usr.sbin/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1274 src/sys/conf/files:1.1275
--- src/sys/conf/files:1.1274 Sat Aug 1 08:20:52 2020
+++ src/sys/conf/files Thu Aug 20 21:21:31 2020
@@ -1,4 +1,4 @@
-# $NetBSD: files,v 1.1274 2020/08/01 08:20:52 maxv Exp $
+# $NetBSD: files,v 1.1275 2020/08/20 21:21:31 riastradh Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
version 20171118
@@ -217,6 +217,12 @@ include "crypto/nist_hash_drbg/files.nis
# ChaCha-based fast PRNG
include "crypto/cprng_fast/files.cprng_fast"
+# BLAKE2s, a cryptographic hash function optimized for 8- to 32-bit
+include "crypto/blake2/files.blake2s"
+
+# Various cryptography functions
+include "crypto/sodium/files.sodium"
+
#
# Kernel history/tracing. Old UVMHIST depends upon this.
#
@@ -1427,6 +1433,7 @@ defpseudo carp: ifnet, ether, arp
defpseudodev l2tp: ifnet, ether, arp
defpseudo canloop: ifnet
defpseudo ipsecif: ifnet # avoid to confuse ipsec itself option
+defpseudo wg: ifnet, blake2s, libsodium
defpseudo sequencer
defpseudo clockctl
Index: src/sys/net/Makefile
diff -u src/sys/net/Makefile:1.42 src/sys/net/Makefile:1.43
--- src/sys/net/Makefile:1.42 Wed Jan 29 03:16:28 2020
+++ src/sys/net/Makefile Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.42 2020/01/29 03:16:28 thorpej Exp $
+# $NetBSD: Makefile,v 1.43 2020/08/20 21:21:32 riastradh Exp $
INCSDIR= /usr/include/net
@@ -6,7 +6,7 @@ INCS= bpf.h bpfjit.h bpfdesc.h dlt.h eth
if_bridgevar.h if_dl.h if_ether.h if_gif.h \
if_gre.h if_ieee1394.h if_ipsec.h if_llc.h if_media.h if_mpls.h \
if_pflog.h if_ppp.h if_pppoe.h if_l2tp.h if_sppp.h if_srt.h if_stats.h \
- if_stf.h if_tap.h if_tun.h if_types.h if_vlanvar.h net_stats.h \
+ if_stf.h if_tap.h if_tun.h if_types.h if_vlanvar.h if_wg.h net_stats.h \
netisr.h pfil.h pfkeyv2.h pfvar.h ppp-comp.h ppp_defs.h radix.h \
raw_cb.h route.h slcompress.h slip.h zlib.h
Index: src/sys/net/files.net
diff -u src/sys/net/files.net:1.25 src/sys/net/files.net:1.26
--- src/sys/net/files.net:1.25 Wed Jan 29 03:16:28 2020
+++ src/sys/net/files.net Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-# $NetBSD: files.net,v 1.25 2020/01/29 03:16:28 thorpej Exp $
+# $NetBSD: files.net,v 1.26 2020/08/20 21:21:32 riastradh Exp $
# XXX CLEANUP
define net
@@ -33,6 +33,7 @@ file net/if_tap.c tap
file net/if_tun.c tun
file net/if_vlan.c vlan needs-flag
file net/if_pppoe.c pppoe needs-flag
+file net/if_wg.c wg needs-flag
file net/pfil.c net
file net/ppp-deflate.c ppp & ppp_deflate
file net/ppp_tty.c ppp
Index: src/sys/net/if_types.h
diff -u src/sys/net/if_types.h:1.29 src/sys/net/if_types.h:1.30
--- src/sys/net/if_types.h:1.29 Tue Jul 31 16:44:30 2018
+++ src/sys/net/if_types.h Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_types.h,v 1.29 2018/07/31 16:44:30 khorben Exp $ */
+/* $NetBSD: if_types.h,v 1.30 2020/08/20 21:21:32 riastradh Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -267,5 +267,6 @@
#define IFT_CARP 0xf8 /* Common Address Redundancy Protocol */
#define IFT_IPSEC 0xf9 /* IPsec I/F */
#define IFT_MBIM 0xfa /* Mobile Broadband Interface Model */
+#define IFT_WIREGUARD 0xfb /* WireGuard */
#endif /* !_NET_IF_TYPES_H_ */
Index: src/sys/netinet/in.c
diff -u src/sys/netinet/in.c:1.236 src/sys/netinet/in.c:1.237
--- src/sys/netinet/in.c:1.236 Wed Dec 18 00:49:15 2019
+++ src/sys/netinet/in.c Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: in.c,v 1.236 2019/12/18 00:49:15 roy Exp $ */
+/* $NetBSD: in.c,v 1.237 2020/08/20 21:21:32 riastradh Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.236 2019/12/18 00:49:15 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.237 2020/08/20 21:21:32 riastradh Exp $");
#include "arp.h"
@@ -145,7 +145,6 @@ __KERNEL_RCSID(0, "$NetBSD: in.c,v 1.236
#endif
static u_int in_mask2len(struct in_addr *);
-static void in_len2mask(struct in_addr *, u_int);
static int in_lifaddr_ioctl(struct socket *, u_long, void *,
struct ifnet *);
@@ -380,7 +379,7 @@ in_mask2len(struct in_addr *mask)
return x * NBBY + y;
}
-static void
+void
in_len2mask(struct in_addr *mask, u_int len)
{
u_int i;
@@ -1232,9 +1231,11 @@ in_ifinit(struct ifnet *ifp, struct in_i
ia->ia_dstaddr = ia->ia_addr;
flags |= RTF_HOST;
} else if (ifp->if_flags & IFF_POINTOPOINT) {
- if (ia->ia_dstaddr.sin_family != AF_INET)
- return (0);
- flags |= RTF_HOST;
+ if (in_mask2len(&ia->ia_sockmask.sin_addr) == 32) {
+ if (ia->ia_dstaddr.sin_family != AF_INET)
+ return (0);
+ flags |= RTF_HOST;
+ }
}
/* Add the local route to the address */
Index: src/sys/netinet/in.h
diff -u src/sys/netinet/in.h:1.109 src/sys/netinet/in.h:1.110
--- src/sys/netinet/in.h:1.109 Wed Dec 18 00:49:16 2019
+++ src/sys/netinet/in.h Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: in.h,v 1.109 2019/12/18 00:49:16 roy Exp $ */
+/* $NetBSD: in.h,v 1.110 2020/08/20 21:21:32 riastradh Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@@ -437,6 +437,8 @@ int in4_cksum(struct mbuf *, u_int8_t, i
int in_localaddr(struct in_addr);
void in_socktrim(struct sockaddr_in *);
+void in_len2mask(struct in_addr *, u_int);
+
void in_if_link_up(struct ifnet *);
void in_if_link_down(struct ifnet *);
void in_if_up(struct ifnet *);
Index: src/sys/netinet/in_pcb.c
diff -u src/sys/netinet/in_pcb.c:1.183 src/sys/netinet/in_pcb.c:1.184
--- src/sys/netinet/in_pcb.c:1.183 Wed May 15 02:59:18 2019
+++ src/sys/netinet/in_pcb.c Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: in_pcb.c,v 1.183 2019/05/15 02:59:18 ozaki-r Exp $ */
+/* $NetBSD: in_pcb.c,v 1.184 2020/08/20 21:21:32 riastradh Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,7 +93,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.183 2019/05/15 02:59:18 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.184 2020/08/20 21:21:32 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -205,6 +205,8 @@ in_pcballoc(struct socket *so, void *v)
inp->inp_portalgo = PORTALGO_DEFAULT;
inp->inp_bindportonsend = false;
inp->inp_prefsrcip.s_addr = INADDR_ANY;
+ inp->inp_overudp_cb = NULL;
+ inp->inp_overudp_arg = NULL;
#if defined(IPSEC)
if (ipsec_enabled) {
int error = ipsec_init_pcbpolicy(so, &inp->inp_sp);
Index: src/sys/netinet/in_pcb.h
diff -u src/sys/netinet/in_pcb.h:1.66 src/sys/netinet/in_pcb.h:1.67
--- src/sys/netinet/in_pcb.h:1.66 Thu May 31 07:03:57 2018
+++ src/sys/netinet/in_pcb.h Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: in_pcb.h,v 1.66 2018/05/31 07:03:57 maxv Exp $ */
+/* $NetBSD: in_pcb.h,v 1.67 2020/08/20 21:21:32 riastradh Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -96,6 +96,8 @@ struct inpcb {
uint8_t inp_ip_minttl;
bool inp_bindportonsend;
struct in_addr inp_prefsrcip; /* preferred src IP when wild */
+ pcb_overudp_cb_t inp_overudp_cb;
+ void *inp_overudp_arg;
};
#define inp_faddr inp_ip.ip_dst
@@ -163,6 +165,14 @@ void in_setsockaddr(struct inpcb *, stru
struct rtentry *
in_pcbrtentry(struct inpcb *);
void in_pcbrtentry_unref(struct rtentry *, struct inpcb *);
+
+static inline void
+in_pcb_register_overudp_cb(struct inpcb *inp, pcb_overudp_cb_t cb, void *arg)
+{
+
+ inp->inp_overudp_cb = cb;
+ inp->inp_overudp_arg = arg;
+}
#endif
#endif /* !_NETINET_IN_PCB_H_ */
Index: src/sys/netinet/in_pcb_hdr.h
diff -u src/sys/netinet/in_pcb_hdr.h:1.13 src/sys/netinet/in_pcb_hdr.h:1.14
--- src/sys/netinet/in_pcb_hdr.h:1.13 Fri Jun 2 03:41:20 2017
+++ src/sys/netinet/in_pcb_hdr.h Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: in_pcb_hdr.h,v 1.13 2017/06/02 03:41:20 ozaki-r Exp $ */
+/* $NetBSD: in_pcb_hdr.h,v 1.14 2020/08/20 21:21:32 riastradh Exp $ */
/*
* Copyright (C) 2003 WIDE Project.
@@ -132,4 +132,7 @@ struct inpcbtable {
#define INP_BOUND 1
#define INP_CONNECTED 2
+typedef int (*pcb_overudp_cb_t)(struct mbuf **, int, struct socket *,
+ struct sockaddr *, void *);
+
#endif /* !_NETINET_IN_PCB_HDR_H_ */
Index: src/sys/netinet/ip_encap.c
diff -u src/sys/netinet/ip_encap.c:1.72 src/sys/netinet/ip_encap.c:1.73
--- src/sys/netinet/ip_encap.c:1.72 Thu Jan 23 09:09:59 2020
+++ src/sys/netinet/ip_encap.c Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_encap.c,v 1.72 2020/01/23 09:09:59 knakahara Exp $ */
+/* $NetBSD: ip_encap.c,v 1.73 2020/08/20 21:21:32 riastradh Exp $ */
/* $KAME: ip_encap.c,v 1.73 2001/10/02 08:30:58 itojun Exp $ */
/*
@@ -68,7 +68,7 @@
#define USE_RADIX
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.72 2020/01/23 09:09:59 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.73 2020/08/20 21:21:32 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_mrouting.h"
@@ -126,7 +126,7 @@ static struct encaptab *encap6_lookup(st
#endif
static int encap_add(struct encaptab *);
static int encap_remove(struct encaptab *);
-static int encap_afcheck(int, const struct sockaddr *, const struct sockaddr *);
+static void encap_afcheck(int, const struct sockaddr *, const struct sockaddr *);
#ifdef USE_RADIX
static struct radix_node_head *encap_rnh(int);
static int mask_matchlen(const struct sockaddr *);
@@ -601,39 +601,16 @@ encap_remove(struct encaptab *ep)
return error;
}
-static int
+static void
encap_afcheck(int af, const struct sockaddr *sp, const struct sockaddr *dp)
{
- if (sp && dp) {
- if (sp->sa_len != dp->sa_len)
- return EINVAL;
- if (af != sp->sa_family || af != dp->sa_family)
- return EINVAL;
- } else if (!sp && !dp)
- ;
- else
- return EINVAL;
- switch (af) {
- case AF_INET:
- if (sp && sp->sa_len != sizeof(struct sockaddr_in))
- return EINVAL;
- if (dp && dp->sa_len != sizeof(struct sockaddr_in))
- return EINVAL;
- break;
-#ifdef INET6
- case AF_INET6:
- if (sp && sp->sa_len != sizeof(struct sockaddr_in6))
- return EINVAL;
- if (dp && dp->sa_len != sizeof(struct sockaddr_in6))
- return EINVAL;
- break;
-#endif
- default:
- return EAFNOSUPPORT;
- }
+ KASSERT(sp != NULL && dp != NULL);
+ KASSERT(sp->sa_len == dp->sa_len);
+ KASSERT(af == sp->sa_family && af == dp->sa_family);
- return 0;
+ socklen_t len = sockaddr_getsize_by_family(af);
+ KASSERT(len != 0 && len == sp->sa_len && len == dp->sa_len);
}
/*
@@ -660,10 +637,11 @@ encap_attach(int af, int proto,
s = splsoftnet();
#endif
+
+ ASSERT_SLEEPABLE();
+
/* sanity check on args */
- error = encap_afcheck(af, sp, dp);
- if (error)
- goto fail;
+ encap_afcheck(af, sp, dp);
/* check if anyone have already attached with exactly same config */
pss = pserialize_read_enter();
@@ -709,21 +687,9 @@ encap_attach(int af, int proto,
}
/* M_NETADDR ok? */
- ep = kmem_zalloc(sizeof(*ep), KM_NOSLEEP);
- if (ep == NULL) {
- error = ENOBUFS;
- goto fail;
- }
- ep->addrpack = kmem_zalloc(l, KM_NOSLEEP);
- if (ep->addrpack == NULL) {
- error = ENOBUFS;
- goto gc;
- }
- ep->maskpack = kmem_zalloc(l, KM_NOSLEEP);
- if (ep->maskpack == NULL) {
- error = ENOBUFS;
- goto gc;
- }
+ ep = kmem_zalloc(sizeof(*ep), KM_SLEEP);
+ ep->addrpack = kmem_zalloc(l, KM_SLEEP);
+ ep->maskpack = kmem_zalloc(l, KM_SLEEP);
ep->af = af;
ep->proto = proto;
@@ -794,21 +760,18 @@ encap_attach_func(int af, int proto,
s = splsoftnet();
#endif
- /* sanity check on args */
- if (!func) {
- error = EINVAL;
- goto fail;
- }
- error = encap_afcheck(af, NULL, NULL);
- if (error)
- goto fail;
+ ASSERT_SLEEPABLE();
- ep = kmem_alloc(sizeof(*ep), KM_NOSLEEP); /*XXX*/
- if (ep == NULL) {
- error = ENOBUFS;
- goto fail;
- }
+ /* sanity check on args */
+ KASSERT(func != NULL);
+ KASSERT(af == AF_INET
+#ifdef INET6
+ || af == AF_INET6
+#endif
+ );
+
+ ep = kmem_alloc(sizeof(*ep), KM_SLEEP);
memset(ep, 0, sizeof(*ep));
ep->af = af;
@@ -830,7 +793,6 @@ encap_attach_func(int af, int proto,
gc:
kmem_free(ep, sizeof(*ep));
-fail:
#ifndef ENCAP_MPSAFE
splx(s);
#endif
Index: src/sys/netinet/udp_usrreq.c
diff -u src/sys/netinet/udp_usrreq.c:1.258 src/sys/netinet/udp_usrreq.c:1.259
--- src/sys/netinet/udp_usrreq.c:1.258 Thu Dec 27 16:59:17 2018
+++ src/sys/netinet/udp_usrreq.c Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: udp_usrreq.c,v 1.258 2018/12/27 16:59:17 maxv Exp $ */
+/* $NetBSD: udp_usrreq.c,v 1.259 2020/08/20 21:21:32 riastradh Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.258 2018/12/27 16:59:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.259 2020/08/20 21:21:32 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -597,6 +597,30 @@ udp4_realinput(struct sockaddr_in *src,
}
}
#endif
+ if (inp->inp_overudp_cb != NULL) {
+ int ret;
+ ret = inp->inp_overudp_cb(mp, off, inp->inp_socket,
+ sintosa(src), inp->inp_overudp_arg);
+ switch (ret) {
+ case -1: /* Error, m was freed */
+ rcvcnt = -1;
+ goto bad;
+
+ case 1: /* Foo over UDP */
+ KASSERT(*mp == NULL);
+ rcvcnt++;
+ goto bad;
+
+ case 0: /* plain UDP */
+ default: /* Unexpected */
+ /*
+ * Normal UDP processing will take place,
+ * m may have changed.
+ */
+ m = *mp;
+ break;
+ }
+ }
/*
* Check the minimum TTL for socket.
@@ -1048,7 +1072,7 @@ udp_recvoob(struct socket *so, struct mb
return EOPNOTSUPP;
}
-static int
+int
udp_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
struct mbuf *control, struct lwp *l)
{
Index: src/sys/netinet/udp_var.h
diff -u src/sys/netinet/udp_var.h:1.45 src/sys/netinet/udp_var.h:1.46
--- src/sys/netinet/udp_var.h:1.45 Fri Sep 14 05:09:51 2018
+++ src/sys/netinet/udp_var.h Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: udp_var.h,v 1.45 2018/09/14 05:09:51 maxv Exp $ */
+/* $NetBSD: udp_var.h,v 1.46 2020/08/20 21:21:32 riastradh Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -87,6 +87,8 @@ void udp_init(void);
void udp_init_common(void);
void udp_input(struct mbuf *, int, int);
int udp_output(struct mbuf *, struct inpcb *, struct mbuf *, struct lwp *);
+int udp_send(struct socket *, struct mbuf *, struct sockaddr *,
+ struct mbuf *, struct lwp *);
int udp_input_checksum(int af, struct mbuf *, const struct udphdr *, int, int);
void udp_statinc(u_int);
#endif /* _KERNEL */
Index: src/sys/netinet6/in6_pcb.h
diff -u src/sys/netinet6/in6_pcb.h:1.50 src/sys/netinet6/in6_pcb.h:1.51
--- src/sys/netinet6/in6_pcb.h:1.50 Thu Nov 22 04:48:34 2018
+++ src/sys/netinet6/in6_pcb.h Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_pcb.h,v 1.50 2018/11/22 04:48:34 knakahara Exp $ */
+/* $NetBSD: in6_pcb.h,v 1.51 2020/08/20 21:21:32 riastradh Exp $ */
/* $KAME: in6_pcb.h,v 1.45 2001/02/09 05:59:46 itojun Exp $ */
/*
@@ -102,6 +102,8 @@ struct in6pcb {
int in6p_cksum; /* IPV6_CHECKSUM setsockopt */
bool in6p_bindportonsend;
struct ip_moptions *in6p_v4moptions;/* IP4 multicast options */
+ pcb_overudp_cb_t in6p_overudp_cb;
+ void *in6p_overudp_arg;
};
#define in6p_faddr in6p_ip6.ip6_dst
@@ -192,6 +194,14 @@ extern struct in6pcb *in6_pcblookup_conn
struct vestigial_inpcb *);
extern struct in6pcb *in6_pcblookup_bind(struct inpcbtable *,
const struct in6_addr *, u_int, int);
+
+static inline void
+in6_pcb_register_overudp_cb(struct in6pcb *in6p, pcb_overudp_cb_t cb, void *arg)
+{
+
+ in6p->in6p_overudp_cb = cb;
+ in6p->in6p_overudp_arg = arg;
+}
#endif /* _KERNEL */
#endif /* !_NETINET6_IN6_PCB_H_ */
Index: src/sys/netinet6/udp6_usrreq.c
diff -u src/sys/netinet6/udp6_usrreq.c:1.147 src/sys/netinet6/udp6_usrreq.c:1.148
--- src/sys/netinet6/udp6_usrreq.c:1.147 Mon Feb 25 07:31:32 2019
+++ src/sys/netinet6/udp6_usrreq.c Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: udp6_usrreq.c,v 1.147 2019/02/25 07:31:32 maxv Exp $ */
+/* $NetBSD: udp6_usrreq.c,v 1.148 2020/08/20 21:21:32 riastradh Exp $ */
/* $KAME: udp6_usrreq.c,v 1.86 2001/05/27 17:33:00 itojun Exp $ */
/* $KAME: udp6_output.c,v 1.43 2001/10/15 09:19:52 itojun Exp $ */
@@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.147 2019/02/25 07:31:32 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.148 2020/08/20 21:21:32 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -547,6 +547,30 @@ udp6_realinput(int af, struct sockaddr_i
}
#endif
+ if (in6p->in6p_overudp_cb != NULL) {
+ int ret;
+ ret = in6p->in6p_overudp_cb(mp, off, in6p->in6p_socket,
+ sin6tosa(src), in6p->in6p_overudp_arg);
+ switch (ret) {
+ case -1: /* Error, m was freed */
+ rcvcnt = -1;
+ goto bad;
+
+ case 1: /* Foo over UDP */
+ KASSERT(*mp == NULL);
+ rcvcnt++;
+ goto bad;
+
+ case 0: /* plain UDP */
+ default: /* Unexpected */
+ /*
+ * Normal UDP processing will take place,
+ * m may have changed.
+ */
+ break;
+ }
+ }
+
udp6_sendup(m, off, sin6tosa(src), in6p->in6p_socket);
rcvcnt++;
}
Index: src/sys/rump/kern/lib/libcrypto/Makefile
diff -u src/sys/rump/kern/lib/libcrypto/Makefile:1.13 src/sys/rump/kern/lib/libcrypto/Makefile:1.14
--- src/sys/rump/kern/lib/libcrypto/Makefile:1.13 Tue Jul 28 20:15:07 2020
+++ src/sys/rump/kern/lib/libcrypto/Makefile Thu Aug 20 21:21:32 2020
@@ -1,13 +1,29 @@
-# $NetBSD: Makefile,v 1.13 2020/07/28 20:15:07 riastradh Exp $
+# $NetBSD: Makefile,v 1.14 2020/08/20 21:21:32 riastradh Exp $
#
+SODIUM_IMPORTDIR=${.CURDIR}/../../../../external/isc/libsodium
+SODIUM_DIR=${.CURDIR}/../../../../external/isc/libsodium/dist/src/libsodium
+
.PATH: ${.CURDIR}/../../../../crypto/adiantum \
${.CURDIR}/../../../../crypto/aes \
${.CURDIR}/../../../../crypto/blowfish \
${.CURDIR}/../../../../crypto/camellia \
${.CURDIR}/../../../../crypto/cast128 \
${.CURDIR}/../../../../crypto/des \
- ${.CURDIR}/../../../../crypto/skipjack
+ ${.CURDIR}/../../../../crypto/skipjack \
+ ${.CURDIR}/../../../../external/cc0/libb2/dist/src \
+ ${SODIUM_DIR}/crypto_scalarmult/curve25519/ref10 \
+ ${SODIUM_DIR}/crypto_scalarmult/curve25519 \
+ ${SODIUM_DIR}/crypto_scalarmult \
+ ${SODIUM_DIR}/crypto_onetimeauth/poly1305/donna \
+ ${SODIUM_DIR}/crypto_onetimeauth/poly1305 \
+ ${SODIUM_DIR}/crypto_onetimeauth \
+ ${SODIUM_DIR}/crypto_stream/chacha20/ref \
+ ${SODIUM_DIR}/crypto_stream/chacha20 \
+ ${SODIUM_DIR}/crypto_aead/xchacha20poly1305/sodium \
+ ${SODIUM_DIR}/crypto_aead/chacha20poly1305/sodium \
+ ${SODIUM_DIR}/crypto_core/hchacha20 \
+ ${SODIUM_DIR}/crypto_core/ed25519/ref10
LIB= rumpkern_crypto
COMMENT=Cryptographic routines
@@ -41,5 +57,35 @@ SRCS+= des_ecb.c des_setkey.c des_enc.c
# skipjack
SRCS+= skipjack.c
+# BLAKE2
+SRCS+= blake2s-ref.c
+CPPFLAGS.blake2s-ref.c+= -I${.CURDIR}/../../../../external/cc0/libb2/include \
+ -Wno-cast-qual -DSUFFIX=
+
+# Various cryptography functions
+SODIUM_CPPFLAGS=
+SODIUM_CPPFLAGS+= -I${SODIUM_IMPORTDIR}/include
+SODIUM_CPPFLAGS+= -I${SODIUM_IMPORTDIR}/dist/src/libsodium/include/sodium
+SODIUM_CPPFLAGS+= -Wno-unused-function -Wno-unused-variable -DHAVE_TI_MODE
+
+CPPFLAGS.x25519_ref10.c+= ${SODIUM_CPPFLAGS}
+CPPFLAGS.scalarmult_curve25519.c+= ${SODIUM_CPPFLAGS}
+CPPFLAGS.crypto_scalarmult.c+= ${SODIUM_CPPFLAGS}
+CPPFLAGS.poly1305_donna.c+= ${SODIUM_CPPFLAGS}
+CPPFLAGS.onetimeauth_poly1305.c+= ${SODIUM_CPPFLAGS}
+CPPFLAGS.crypto_onetimeauth.c+= ${SODIUM_CPPFLAGS}
+CPPFLAGS.chacha20_ref.c+= ${SODIUM_CPPFLAGS}
+CPPFLAGS.stream_chacha20.c+= ${SODIUM_CPPFLAGS}
+CPPFLAGS.aead_xchacha20poly1305.c+= ${SODIUM_CPPFLAGS}
+CPPFLAGS.aead_chacha20poly1305.c+= ${SODIUM_CPPFLAGS}
+CPPFLAGS.core_hchacha20.c+= ${SODIUM_CPPFLAGS}
+CPPFLAGS.ed25519_ref10.c+= ${SODIUM_CPPFLAGS}
+
+SRCS+= x25519_ref10.c scalarmult_curve25519.c crypto_scalarmult.c
+SRCS+= poly1305_donna.c onetimeauth_poly1305.c
+SRCS+= crypto_onetimeauth.c chacha20_ref.c stream_chacha20.c
+SRCS+= aead_xchacha20poly1305.c aead_chacha20poly1305.c
+SRCS+= core_hchacha20.c ed25519_ref10.c
+
.include <bsd.lib.mk>
.include <bsd.klinks.mk>
Index: src/sys/rump/net/Makefile.rumpnetcomp
diff -u src/sys/rump/net/Makefile.rumpnetcomp:1.20 src/sys/rump/net/Makefile.rumpnetcomp:1.21
--- src/sys/rump/net/Makefile.rumpnetcomp:1.20 Wed Jan 10 11:02:42 2018
+++ src/sys/rump/net/Makefile.rumpnetcomp Thu Aug 20 21:21:32 2020
@@ -1,10 +1,11 @@
-# $NetBSD: Makefile.rumpnetcomp,v 1.20 2018/01/10 11:02:42 knakahara Exp $
+# $NetBSD: Makefile.rumpnetcomp,v 1.21 2020/08/20 21:21:32 riastradh Exp $
#
.include <bsd.own.mk>
RUMPNETCOMP= agr bridge net net80211 netbt netcan netinet netinet6 netipsec
RUMPNETCOMP+= gif ipsec netmpls npf l2tp local pppoe shmif tap tun vlan
+RUMPNETCOMP+= wireguard
.if ${MKSLJIT} != "no" || make(rumpdescribe)
RUMPNETCOMP+= bpfjit
Index: src/tests/net/Makefile
diff -u src/tests/net/Makefile:1.34 src/tests/net/Makefile:1.35
--- src/tests/net/Makefile:1.34 Wed Jan 10 11:06:06 2018
+++ src/tests/net/Makefile Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.34 2018/01/10 11:06:06 knakahara Exp $
+# $NetBSD: Makefile,v 1.35 2020/08/20 21:21:32 riastradh Exp $
.include <bsd.own.mk>
@@ -8,7 +8,7 @@ TESTS_SUBDIRS= fdpass in_cksum net sys
.if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE)
TESTS_SUBDIRS+= arp bpf bpfilter can carp icmp if if_bridge if_gif
TESTS_SUBDIRS+= if_ipsec if_l2tp if_loop if_pppoe if_tap if_tun ipsec
-TESTS_SUBDIRS+= mcast mpls ndp npf route if_vlan
+TESTS_SUBDIRS+= mcast mpls ndp npf route if_vlan wireguard
.if (${MKSLJIT} != "no")
TESTS_SUBDIRS+= bpfjit
.endif
Index: src/usr.sbin/Makefile
diff -u src/usr.sbin/Makefile:1.283 src/usr.sbin/Makefile:1.284
--- src/usr.sbin/Makefile:1.283 Sun Jan 19 06:55:24 2020
+++ src/usr.sbin/Makefile Thu Aug 20 21:21:32 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.283 2020/01/19 06:55:24 thorpej Exp $
+# $NetBSD: Makefile,v 1.284 2020/08/20 21:21:32 riastradh Exp $
# from: @(#)Makefile 5.20 (Berkeley) 6/12/93
.include <bsd.own.mk>
@@ -30,8 +30,8 @@ SUBDIR= ac accton acpitools altq apm apm
tadpolectl tcpdchk tcpdmatch tcpdrop timed tpctl tprof traceroute trpt \
unlink usbdevs user \
videomode vipw veriexecgen vnconfig \
- wakeonlan wiconfig wlanctl wsconscfg wsfontload wsmoused wsmuxctl \
- zdump zic
+ wakeonlan wg-keygen wgconfig wiconfig wlanctl wsconscfg wsfontload wsmoused \
+ wsmuxctl zdump zic
.if ${MKMAKEMANDB} != "no"
SUBDIR+= makemandb