Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net wg: with no peers, the link status is DOWN, otherwis...



details:   https://anonhg.NetBSD.org/src/rev/aa93b941e92e
branches:  trunk
changeset: 940715:aa93b941e92e
user:      roy <roy%NetBSD.org@localhost>
date:      Thu Oct 15 10:09:49 2020 +0000

description:
wg: with no peers, the link status is DOWN, otherwise UP

This mirrors the recent changes to gif(4) where the link is UP when a
tunnel is set, otherwise DOWN.

diffstat:

 sys/net/if_wg.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (54 lines):

diff -r 7930d3605ac0 -r aa93b941e92e sys/net/if_wg.c
--- a/sys/net/if_wg.c   Thu Oct 15 09:54:22 2020 +0000
+++ b/sys/net/if_wg.c   Thu Oct 15 10:09:49 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wg.c,v 1.60 2020/09/14 04:57:20 riastradh Exp $     */
+/*     $NetBSD: if_wg.c,v 1.61 2020/10/15 10:09:49 roy Exp $   */
 
 /*
  * Copyright (C) Ryota Ozaki <ozaki.ryota%gmail.com@localhost>
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.60 2020/09/14 04:57:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.61 2020/10/15 10:09:49 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq_enabled.h"
@@ -3509,6 +3509,8 @@
                garbage_bypubkey = thmap_stage_gc(wg->wg_peers_bypubkey);
                WG_PEER_WRITER_REMOVE(wgp);
                wg->wg_npeers--;
+               if (wg->wg_npeers == 0)
+                       if_link_state_change(&wg->wg_if, LINK_STATE_DOWN);
                mutex_enter(wgp->wgp_lock);
                pserialize_perform(wgp->wgp_psz);
                mutex_exit(wgp->wgp_lock);
@@ -3536,8 +3538,7 @@
        wg->wg_if.if_addrlen = 0;
        wg->wg_if.if_mtu = WG_MTU;
        wg->wg_if.if_flags = IFF_MULTICAST;
-       wg->wg_if.if_extflags = IFEF_NO_LINK_STATE_CHANGE;
-       wg->wg_if.if_extflags |= IFEF_MPSAFE;
+       wg->wg_if.if_extflags = IFEF_MPSAFE;
        wg->wg_if.if_ioctl = wg_ioctl;
        wg->wg_if.if_output = wg_output;
        wg->wg_if.if_init = wg_init;
@@ -3556,6 +3557,7 @@
        if (error != 0)
                return error;
 
+       wg->wg_if.if_link_state = LINK_STATE_DOWN;
        if_alloc_sadl(&wg->wg_if);
        if_register(&wg->wg_if);
 
@@ -4381,6 +4383,8 @@
        wg->wg_npeers++;
        mutex_exit(wg->wg_lock);
 
+       if_link_state_change(&wg->wg_if, LINK_STATE_UP);
+
 out:
        kmem_free(buf, ifd->ifd_len + 1);
        return error;



Home | Main Index | Thread Index | Old Index