Thu Aug 27 19:21:14 2020 UTC ()
Summary: let wg interfaces carry multicast traffic

Once a wg interface is up and running, it is useful to be able to run
a routing protocol over it.  Marking the interface multicast capable
enables this.  (One must also use the wgconfig --allowed-ips option to
explicitly permit the group one needs, e.g. 224.0.0.5/32 for OSPF.)


(tih)
diff -r1.30 -r1.31 src/sys/net/if_wg.c

cvs diff -r1.30 -r1.31 src/sys/net/if_wg.c (expand / switch to unified diff)

--- src/sys/net/if_wg.c 2020/08/27 13:44:41 1.30
+++ src/sys/net/if_wg.c 2020/08/27 19:21:14 1.31
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_wg.c,v 1.30 2020/08/27 13:44:41 riastradh Exp $ */ 1/* $NetBSD: if_wg.c,v 1.31 2020/08/27 19:21:14 tih Exp $ */
2 2
3/* 3/*
4 * Copyright (C) Ryota Ozaki <ozaki.ryota@gmail.com> 4 * Copyright (C) Ryota Ozaki <ozaki.ryota@gmail.com>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -31,27 +31,27 @@ @@ -31,27 +31,27 @@
31 31
32/* 32/*
33 * This network interface aims to implement the WireGuard protocol. 33 * This network interface aims to implement the WireGuard protocol.
34 * The implementation is based on the paper of WireGuard as of 34 * The implementation is based on the paper of WireGuard as of
35 * 2018-06-30 [1]. The paper is referred in the source code with label 35 * 2018-06-30 [1]. The paper is referred in the source code with label
36 * [W]. Also the specification of the Noise protocol framework as of 36 * [W]. Also the specification of the Noise protocol framework as of
37 * 2018-07-11 [2] is referred with label [N]. 37 * 2018-07-11 [2] is referred with label [N].
38 * 38 *
39 * [1] https://www.wireguard.com/papers/wireguard.pdf 39 * [1] https://www.wireguard.com/papers/wireguard.pdf
40 * [2] http://noiseprotocol.org/noise.pdf 40 * [2] http://noiseprotocol.org/noise.pdf
41 */ 41 */
42 42
43#include <sys/cdefs.h> 43#include <sys/cdefs.h>
44__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.30 2020/08/27 13:44:41 riastradh Exp $"); 44__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.31 2020/08/27 19:21:14 tih Exp $");
45 45
46#ifdef _KERNEL_OPT 46#ifdef _KERNEL_OPT
47#include "opt_inet.h" 47#include "opt_inet.h"
48#endif 48#endif
49 49
50#include <sys/param.h> 50#include <sys/param.h>
51#include <sys/systm.h> 51#include <sys/systm.h>
52#include <sys/kernel.h> 52#include <sys/kernel.h>
53#include <sys/mbuf.h> 53#include <sys/mbuf.h>
54#include <sys/socket.h> 54#include <sys/socket.h>
55#include <sys/sockio.h> 55#include <sys/sockio.h>
56#include <sys/errno.h> 56#include <sys/errno.h>
57#include <sys/ioctl.h> 57#include <sys/ioctl.h>
@@ -3371,27 +3371,27 @@ wg_destroy_peer_name(struct wg_softc *wg @@ -3371,27 +3371,27 @@ wg_destroy_peer_name(struct wg_softc *wg
3371 3371
3372 wg_destroy_peer(wgp); 3372 wg_destroy_peer(wgp);
3373 3373
3374 return 0; 3374 return 0;
3375} 3375}
3376 3376
3377static int 3377static int
3378wg_if_attach(struct wg_softc *wg) 3378wg_if_attach(struct wg_softc *wg)
3379{ 3379{
3380 int error; 3380 int error;
3381 3381
3382 wg->wg_if.if_addrlen = 0; 3382 wg->wg_if.if_addrlen = 0;
3383 wg->wg_if.if_mtu = WG_MTU; 3383 wg->wg_if.if_mtu = WG_MTU;
3384 wg->wg_if.if_flags = IFF_POINTOPOINT; 3384 wg->wg_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
3385 wg->wg_if.if_extflags = IFEF_NO_LINK_STATE_CHANGE; 3385 wg->wg_if.if_extflags = IFEF_NO_LINK_STATE_CHANGE;
3386 wg->wg_if.if_extflags |= IFEF_MPSAFE; 3386 wg->wg_if.if_extflags |= IFEF_MPSAFE;
3387 wg->wg_if.if_ioctl = wg_ioctl; 3387 wg->wg_if.if_ioctl = wg_ioctl;
3388 wg->wg_if.if_output = wg_output; 3388 wg->wg_if.if_output = wg_output;
3389 wg->wg_if.if_init = wg_init; 3389 wg->wg_if.if_init = wg_init;
3390 wg->wg_if.if_stop = wg_stop; 3390 wg->wg_if.if_stop = wg_stop;
3391 wg->wg_if.if_type = IFT_OTHER; 3391 wg->wg_if.if_type = IFT_OTHER;
3392 wg->wg_if.if_dlt = DLT_NULL; 3392 wg->wg_if.if_dlt = DLT_NULL;
3393 wg->wg_if.if_softc = wg; 3393 wg->wg_if.if_softc = wg;
3394 IFQ_SET_READY(&wg->wg_if.if_snd); 3394 IFQ_SET_READY(&wg->wg_if.if_snd);
3395 3395
3396 error = if_initialize(&wg->wg_if); 3396 error = if_initialize(&wg->wg_if);
3397 if (error != 0) 3397 if (error != 0)