Module Name:    src
Committed By:   yamaguchi
Date:           Wed Nov 25 09:38:39 UTC 2020

Modified Files:
        src/sys/net: if_spppsubr.c if_spppvar.h

Log Message:
call if_down() in workqueue instead of callout(9)


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/sys/net/if_spppsubr.c
cvs rdiff -u -r1.27 -r1.28 src/sys/net/if_spppvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.198 src/sys/net/if_spppsubr.c:1.199
--- src/sys/net/if_spppsubr.c:1.198	Wed Nov 25 09:35:23 2020
+++ src/sys/net/if_spppsubr.c	Wed Nov 25 09:38:39 2020
@@ -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_event(struct sppp 
 
 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 @@ sppp_attach(struct ifnet *ifp)
 	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 @@ sppp_keepalive(void *dummy)
 
 		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 @@ sppp_sca_scn(const struct cp *cp, struct
 		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.
  *

Index: src/sys/net/if_spppvar.h
diff -u src/sys/net/if_spppvar.h:1.27 src/sys/net/if_spppvar.h:1.28
--- src/sys/net/if_spppvar.h:1.27	Wed Nov 25 09:35:23 2020
+++ src/sys/net/if_spppvar.h	Wed Nov 25 09:38:39 2020
@@ -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 sppp {
 	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 */

Reply via email to