Module Name:    src
Committed By:   yamaguchi
Date:           Wed Nov 25 10:18:50 UTC 2020

Modified Files:
        src/sys/net: if_pppoe.c if_spppsubr.c

Log Message:
Close lcp when the lower layer down if the interface is passive or on-demand

reivewed by knakahara@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/net/if_pppoe.c
cvs rdiff -u -r1.208 -r1.209 src/sys/net/if_spppsubr.c

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_pppoe.c
diff -u src/sys/net/if_pppoe.c:1.153 src/sys/net/if_pppoe.c:1.154
--- src/sys/net/if_pppoe.c:1.153	Fri Sep 25 06:22:33 2020
+++ src/sys/net/if_pppoe.c	Wed Nov 25 10:18:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.153 2020/09/25 06:22:33 yamaguchi Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.154 2020/11/25 10:18:49 yamaguchi Exp $ */
 
 /*
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.153 2020/09/25 06:22:33 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.154 2020/11/25 10:18:49 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pppoe.h"
@@ -1886,9 +1886,16 @@ pppoe_tlf(struct sppp *sp)
 	PPPOE_LOCK(sc, RW_WRITER);
 
 	if (sc->sc_state < PPPOE_STATE_SESSION) {
+		callout_stop(&sc->sc_timeout);
+		sc->sc_state = PPPOE_STATE_INITIAL;
+		sc->sc_padi_retried = 0;
+		sc->sc_padr_retried = 0;
+		memcpy(&sc->sc_dest, etherbroadcastaddr,
+		    sizeof(sc->sc_dest));
 		PPPOE_UNLOCK(sc);
 		return;
 	}
+
 	/*
 	 * Do not call pppoe_disconnect here, the upper layer state
 	 * machine gets confused by this. We must return from this

Index: src/sys/net/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.208 src/sys/net/if_spppsubr.c:1.209
--- src/sys/net/if_spppsubr.c:1.208	Wed Nov 25 10:12:03 2020
+++ src/sys/net/if_spppsubr.c	Wed Nov 25 10:18:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.208 2020/11/25 10:12:03 yamaguchi Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.209 2020/11/25 10:18:49 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.208 2020/11/25 10:12:03 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.209 2020/11/25 10:18:49 yamaguchi Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -68,6 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr.
 #include <sys/workqueue.h>
 #include <sys/atomic.h>
 #include <sys/compat_stub.h>
+#include <sys/cpu.h>
 
 #include <net/if.h>
 #include <net/netisr.h>
@@ -2466,10 +2467,6 @@ sppp_lcp_up(struct sppp *sp, void *xcp)
 			sppp_wq_add(sp->wq_cp, &sp->scp[pidx].work_open);
 		} else if (debug)
 			addlog("\n");
-	} else if ((ifp->if_flags & (IFF_AUTO | IFF_PASSIVE)) == 0 &&
-		   (sp->scp[IDX_LCP].state == STATE_INITIAL)) {
-			ifp->if_flags |= IFF_RUNNING;
-			sppp_wq_add(sp->wq_cp, &sp->scp[pidx].work_open);
 	}
 
 	sppp_up_event(sp, xcp);
@@ -2510,12 +2507,13 @@ sppp_lcp_down(struct sppp *sp, void *xcp
 			log(LOG_DEBUG,
 			    "%s: Down event (carrier loss)\n",
 			    ifp->if_xname);
+
+		sp->pp_flags &= ~PP_CALLIN;
+		if (sp->scp[pidx].state != STATE_INITIAL)
+			sppp_wq_add(sp->wq_cp, &sp->scp[pidx].work_close);
+		ifp->if_flags &= ~IFF_RUNNING;
 	}
 	sp->scp[pidx].fail_counter = 0;
-	sp->pp_flags &= ~PP_CALLIN;
-	if (sp->scp[pidx].state != STATE_INITIAL)
-		sppp_wq_add(sp->wq_cp, &sp->scp[IDX_LCP].work_close);
-	ifp->if_flags &= ~IFF_RUNNING;
 }
 
 static void

Reply via email to