Source-Changes-HG archive

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

[src/trunk]: src/sys/net l2tp: call if_link_state_change rather then directly...



details:   https://anonhg.NetBSD.org/src/rev/f7f2dad2945e
branches:  trunk
changeset: 941602:f7f2dad2945e
user:      roy <roy%NetBSD.org@localhost>
date:      Sun Oct 25 08:18:39 2020 +0000

description:
l2tp: call if_link_state_change rather then directly setting it.

This allows protocols to do their thing.

diffstat:

 sys/net/if_l2tp.c |  23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diffs (63 lines):

diff -r 68356faa363f -r f7f2dad2945e sys/net/if_l2tp.c
--- a/sys/net/if_l2tp.c Sun Oct 25 08:15:54 2020 +0000
+++ b/sys/net/if_l2tp.c Sun Oct 25 08:18:39 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_l2tp.c,v 1.45 2020/10/25 08:15:54 roy Exp $ */
+/*     $NetBSD: if_l2tp.c,v 1.46 2020/10/25 08:18:39 roy Exp $ */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.45 2020/10/25 08:15:54 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.46 2020/10/25 08:18:39 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -324,6 +324,7 @@
        rv = if_attach(&sc->l2tp_ec.ec_if);
        if (rv != 0)
                return rv;
+       if_link_state_change(&sc->l2tp_ec.ec_if, LINK_STATE_DOWN);
        if_alloc_sadl(&sc->l2tp_ec.ec_if);
        bpf_attach(&sc->l2tp_ec.ec_if, DLT_EN10MB, sizeof(struct ether_header));
 
@@ -1354,6 +1355,7 @@
 {
        struct ifnet *ifp = &sc->l2tp_ec.ec_if;
        struct l2tp_variant *nvar;
+       int ostate;
 
        nvar = kmem_alloc(sizeof(*nvar), KM_SLEEP);
 
@@ -1361,17 +1363,22 @@
 
        *nvar = *sc->l2tp_var;
        psref_target_init(&nvar->lv_psref, lv_psref_class);
+       ostate = nvar->lv_state;
        nvar->lv_state = state;
        l2tp_variant_update(sc, nvar);
+       mutex_exit(&sc->l2tp_lock);
 
-       if (nvar->lv_state == L2TP_STATE_UP) {
-               ifp->if_link_state = LINK_STATE_UP;
-       } else {
-               ifp->if_link_state = LINK_STATE_DOWN;
+       if (ostate != state) {
+               int lstate;
+
+               if (state == L2TP_STATE_UP)
+                       lstate = LINK_STATE_UP;
+               else
+                       lstate = LINK_STATE_DOWN;
+
+               if_link_state_change(ifp, lstate);
        }
 
-       mutex_exit(&sc->l2tp_lock);
-
 #ifdef NOTYET
        vlan_linkstate_notify(ifp, ifp->if_link_state);
 #endif



Home | Main Index | Thread Index | Old Index