@@ -1,4 +1,4 @@
-/* $NetBSD: if_wg.c,v 1.27 2020/08/27 02:54:31 riastradh Exp $ */
+/* $NetBSD: if_wg.c,v 1.28 2020/08/27 02:55:04 riastradh Exp $ */
/*
* Copyright (C) Ryota Ozaki <ozaki.ryota@gmail.com>
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.27 2020/08/27 02:54:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.28 2020/08/27 02:55:04 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -2934,6 +2934,7 @@
/* Verify the mbuf chain is long enough to have a wg msg header. */
KASSERT(offset <= m_length(m));
if (__predict_false(m_length(m) - offset < sizeof(struct wg_msg))) {
+ /* drop on the floor */
m_freem(m);
return -1;
}
@@ -2952,15 +2953,21 @@
*/
switch (wgm.wgm_type) {
case WG_MSG_TYPE_DATA:
+ /* handle immediately */
m_adj(m, offset);
wg_handle_msg_data(wg, m, src);
*mp = NULL;
return 1;
+ case WG_MSG_TYPE_INIT:
+ case WG_MSG_TYPE_RESP:
+ case WG_MSG_TYPE_COOKIE:
+ /* pass through to so_receive in wg_receive_packets */
+ return 0;
default:
- break;
+ /* drop on the floor */
+ m_freem(m);
+ return -1;
}
-
- return 0;
}
static int