Source-Changes-HG archive

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

[src/trunk]: src/sys/net call if_down() in workqueue instead of callout(9)



details:   https://anonhg.NetBSD.org/src/rev/a595134fae4e
branches:  trunk
changeset: 957349:a595134fae4e
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Wed Nov 25 09:38:39 2020 +0000

description:
call if_down() in workqueue instead of callout(9)

diffstat:

 sys/net/if_spppsubr.c |  23 ++++++++++++++++-------
 sys/net/if_spppvar.h  |   3 ++-
 2 files changed, 18 insertions(+), 8 deletions(-)

diffs (82 lines):

diff -r 0ba6db7a819a -r a595134fae4e sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c     Wed Nov 25 09:35:23 2020 +0000
+++ b/sys/net/if_spppsubr.c     Wed Nov 25 09:38:39 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_spppsubr.c,v 1.198 2020/11/25 09:35:23 yamaguchi Exp $       */
+/*     $NetBSD: if_spppsubr.c,v 1.199 2020/11/25 09:38:39 yamaguchi Exp $       */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.198 2020/11/25 09:35:23 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.199 2020/11/25 09:38:39 yamaguchi Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -341,6 +341,7 @@
 
 static void sppp_null(struct sppp *);
 static void sppp_sca_scn(const struct cp *, struct sppp *);
+static void sppp_ifdown(struct sppp *, void *);
 
 static void sppp_lcp_init(struct sppp *);
 static void sppp_lcp_up(struct sppp *, void *);
@@ -1016,6 +1017,7 @@
        sp->pp_phase = SPPP_PHASE_DEAD;
        sp->pp_up = sppp_notify_up;
        sp->pp_down = sppp_notify_down;
+       sppp_wq_set(&sp->work_ifdown, sppp_ifdown, NULL);
        memset(sp->scp, 0, sizeof(sp->scp));
        rw_init(&sp->pp_lock);
 
@@ -5486,11 +5488,7 @@
 
                if (sp->pp_alivecnt >= sp->pp_maxalive) {
                        /* No keepalive packets got.  Stop the interface. */
-                       SPPP_UNLOCK(sp);
-                       if_down (ifp);
-                       SPPP_LOCK(sp, RW_WRITER);
-
-                       IF_PURGE(&sp->pp_cpq);
+                       sppp_wq_add(sp->wq_cp, &sp->work_ifdown);
 
                        if (! (sp->pp_flags & PP_CISCO)) {
                                printf("%s: LCP keepalive timed out, going to restart the connection\n",
@@ -6498,6 +6496,17 @@
                kmem_free(buf, blen);
        }
 }
+
+static void
+sppp_ifdown(struct sppp *sp, void *xcp __unused)
+{
+
+       SPPP_UNLOCK(sp);
+       if_down(&sp->pp_if);
+       IF_PURGE(&sp->pp_cpq);
+       SPPP_LOCK(sp, RW_WRITER);
+}
+
 /*
  * This file is large.  Tell emacs to highlight it nevertheless.
  *
diff -r 0ba6db7a819a -r a595134fae4e sys/net/if_spppvar.h
--- a/sys/net/if_spppvar.h      Wed Nov 25 09:35:23 2020 +0000
+++ b/sys/net/if_spppvar.h      Wed Nov 25 09:38:39 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_spppvar.h,v 1.27 2020/11/25 09:35:23 yamaguchi Exp $        */
+/*     $NetBSD: if_spppvar.h,v 1.28 2020/11/25 09:38:39 yamaguchi Exp $        */
 
 #ifndef _NET_IF_SPPPVAR_H_
 #define _NET_IF_SPPPVAR_H_
@@ -160,6 +160,7 @@
        struct callout_handle pap_my_to_ch; /* PAP needs one more... */
 #endif
        struct workqueue *wq_cp;
+       struct sppp_work work_ifdown;
        struct sppp_cp scp[IDX_COUNT];
        struct slcp lcp;                /* LCP params */
        struct sipcp ipcp;              /* IPCP params */



Home | Main Index | Thread Index | Old Index