Source-Changes-HG archive

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

[src/trunk]: src/sys Fix not to do if_down() before reconnect



details:   https://anonhg.NetBSD.org/src/rev/d5007136930e
branches:  trunk
changeset: 1021478:d5007136930e
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Tue Jun 01 03:51:33 2021 +0000

description:
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.

diffstat:

 sys/conf/files        |   3 ++-
 sys/net/if_spppsubr.c |  34 ++++++++++++++++++++++------------
 sys/net/if_spppvar.h  |  22 ++++++++++++----------
 3 files changed, 36 insertions(+), 23 deletions(-)

diffs (136 lines):

diff -r ad64747d9258 -r d5007136930e sys/conf/files
--- a/sys/conf/files    Tue Jun 01 03:27:23 2021 +0000
+++ b/sys/conf/files    Tue Jun 01 03:51:33 2021 +0000
@@ -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_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
diff -r ad64747d9258 -r d5007136930e sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c     Tue Jun 01 03:27:23 2021 +0000
+++ b/sys/net/if_spppsubr.c     Tue Jun 01 03:51:33 2021 +0000
@@ -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 @@
        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 @@
                                        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 @@
                        /* 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 @@
                                        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 @@
 
                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",
diff -r ad64747d9258 -r d5007136930e sys/net/if_spppvar.h
--- a/sys/net/if_spppvar.h      Tue Jun 01 03:27:23 2021 +0000
+++ b/sys/net/if_spppvar.h      Tue Jun 01 03:51:33 2021 +0000
@@ -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 @@
        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 */



Home | Main Index | Thread Index | Old Index