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.
This commit is contained in:
yamaguchi 2021-06-01 03:51:33 +00:00
parent 0c5b42cf15
commit 4910df2e45
3 changed files with 36 additions and 23 deletions

View File

@ -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_BSDCOMP PPP_FILTER
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

View File

@ -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 mbuf *m)
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, struct sppp *sp, struct mbuf *m)
/* 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 lcp_header *h, int origlen,
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",

View File

@ -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 */