Module Name: src Committed By: yamaguchi Date: Tue Jun 1 03:51:33 UTC 2021
Modified Files: src/sys/conf: files src/sys/net: if_spppsubr.c if_spppvar.h Log Message: Fix not to do if_down() before reconnect Almost network interface do not use if_down() even when there is no connectivity. So, pppoe(4) is also made be not used it. This behavior can be rollbacked by SPPP_IFDOWN_RECONNECT option. To generate a diff of this commit: cvs rdiff -u -r1.1285 -r1.1286 src/sys/conf/files cvs rdiff -u -r1.247 -r1.248 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.39 -r1.40 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/conf/files diff -u src/sys/conf/files:1.1285 src/sys/conf/files:1.1286 --- src/sys/conf/files:1.1285 Sat May 29 12:03:34 2021 +++ src/sys/conf/files Tue Jun 1 03:51:33 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.1285 2021/05/29 12:03:34 simonb Exp $ +# $NetBSD: files,v 1.1286 2021/06/01 03:51:33 yamaguchi Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 version 20171118 @@ -292,6 +292,7 @@ defflag opt_ppp.h PPP_DEFLATE PPP_BSDCO defflag opt_pppoe.h PPPOE_SERVER PPPOE_DEBUG defparam opt_pppoe.h PPPOE_DEQUEUE_MAXLEN +defflag opt_sppp.h SPPP_IFDOWN_RECONNECT defparam opt_sppp.h SPPP_KEEPALIVE_INTERVAL SPPP_NORECV_TIME SPPP_ALIVE_INTERVAL Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.247 src/sys/net/if_spppsubr.c:1.248 --- src/sys/net/if_spppsubr.c:1.247 Tue Jun 1 03:27:23 2021 +++ src/sys/net/if_spppsubr.c Tue Jun 1 03:51:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.247 2021/06/01 03:27:23 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.248 2021/06/01 03:51:33 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.247 2021/06/01 03:27:23 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.248 2021/06/01 03:51:33 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1136,6 +1136,9 @@ sppp_attach(struct ifnet *ifp) sp->pp_up = sppp_notify_up; sp->pp_down = sppp_notify_down; sp->pp_ncpflags = SPPP_NCP_IPCP | SPPP_NCP_IPV6CP; +#ifdef SPPP_IFDOWN_RECONNECT + sp->pp_flags |= PP_LOOPBACK_IFDOWN | PP_KEEPALIVE_IFDOWN; +#endif sppp_wq_set(&sp->work_ifdown, sppp_ifdown, NULL); memset(sp->scp, 0, sizeof(sp->scp)); rw_init(&sp->pp_lock); @@ -1481,9 +1484,11 @@ sppp_cisco_input(struct sppp *sp, struct ifp->if_xname); sp->pp_loopcnt = 0; - sp->pp_flags |= PP_LOOPBACK; - sppp_wq_add(sp->wq_cp, - &sp->work_ifdown); + if (sp->pp_flags & PP_LOOPBACK_IFDOWN) { + sp->pp_flags |= PP_LOOPBACK; + sppp_wq_add(sp->wq_cp, + &sp->work_ifdown); + } sppp_wq_add(sp->wq_cp, &sp->scp[IDX_LCP].work_close); @@ -1951,9 +1956,11 @@ sppp_cp_input(const struct cp *cp, struc /* Line loopback mode detected. */ printf("%s: loopback\n", ifp->if_xname); - sp->pp_flags |= PP_LOOPBACK; - sppp_wq_add(sp->wq_cp, - &sp->work_ifdown); + if (sp->pp_flags & PP_LOOPBACK_IFDOWN) { + sp->pp_flags |= PP_LOOPBACK; + sppp_wq_add(sp->wq_cp, + &sp->work_ifdown); + } /* Shut down the PPP link. */ sppp_wq_add(sp->wq_cp, @@ -3001,9 +3008,11 @@ sppp_lcp_confreq(struct sppp *sp, struct ifp->if_xname); sp->pp_loopcnt = 0; - sp->pp_flags |= PP_LOOPBACK; - sppp_wq_add(sp->wq_cp, - &sp->work_ifdown); + if (sp->pp_flags & PP_LOOPBACK_IFDOWN) { + sp->pp_flags |= PP_LOOPBACK; + sppp_wq_add(sp->wq_cp, + &sp->work_ifdown); + } sppp_wq_add(sp->wq_cp, &sp->scp[IDX_LCP].work_close); @@ -5768,7 +5777,8 @@ sppp_keepalive(void *dummy) if (sp->pp_alivecnt >= sp->pp_maxalive) { /* No keepalive packets got. Stop the interface. */ - sppp_wq_add(sp->wq_cp, &sp->work_ifdown); + if (sp->pp_flags & PP_KEEPALIVE_IFDOWN) + 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", Index: src/sys/net/if_spppvar.h diff -u src/sys/net/if_spppvar.h:1.39 src/sys/net/if_spppvar.h:1.40 --- src/sys/net/if_spppvar.h:1.39 Tue Jun 1 03:27:23 2021 +++ src/sys/net/if_spppvar.h Tue Jun 1 03:51:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppvar.h,v 1.39 2021/06/01 03:27:23 yamaguchi Exp $ */ +/* $NetBSD: if_spppvar.h,v 1.40 2021/06/01 03:51:33 yamaguchi Exp $ */ #ifndef _NET_IF_SPPPVAR_H_ #define _NET_IF_SPPPVAR_H_ @@ -203,15 +203,17 @@ struct sppp { void (*pp_chg)(struct sppp *, int); }; -#define PP_KEEPALIVE 0x01 /* use keepalive protocol */ -#define PP_CISCO 0x02 /* use Cisco protocol instead of PPP */ - /* 0x04 was PP_TIMO */ -#define PP_CALLIN 0x08 /* we are being called */ -#define PP_NEEDAUTH 0x10 /* remote requested authentication */ -#define PP_NOFRAMING 0x20 /* do not add/expect encapsulation - around PPP frames (i.e. the serial - HDLC like encapsulation, RFC1662) */ -#define PP_LOOPBACK 0x40 /* in line loopback mode */ +#define PP_KEEPALIVE 0x01 /* use keepalive protocol */ +#define PP_CISCO 0x02 /* use Cisco protocol instead of PPP */ + /* 0x04 was PP_TIMO */ +#define PP_CALLIN 0x08 /* we are being called */ +#define PP_NEEDAUTH 0x10 /* remote requested authentication */ +#define PP_NOFRAMING 0x20 /* do not add/expect encapsulation + around PPP frames (i.e. the serial + HDLC like encapsulation, RFC1662) */ +#define PP_LOOPBACK 0x40 /* in line loopback mode */ +#define PP_LOOPBACK_IFDOWN 0x80 /* if_down() when loopback detected */ +#define PP_KEEPALIVE_IFDOWN 0x100 /* if_down() when no ECHO_REPLY received */ #define PP_MTU 1500 /* default/minimal MRU */