Source-Changes-HG archive

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

[src/trunk]: src/sys Add a parameter to change keepalive interval in each PPP...



details:   https://anonhg.NetBSD.org/src/rev/074089154450
branches:  trunk
changeset: 1021176:074089154450
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Fri May 14 08:41:25 2021 +0000

description:
Add a parameter to change keepalive interval in each PPPoE I/F

diffstat:

 sys/conf/files        |   3 ++-
 sys/net/if_sppp.h     |   3 ++-
 sys/net/if_spppsubr.c |  26 ++++++++++++++++++++++++--
 sys/net/if_spppvar.h  |   3 ++-
 4 files changed, 30 insertions(+), 5 deletions(-)

diffs (147 lines):

diff -r 4c476644de6b -r 074089154450 sys/conf/files
--- a/sys/conf/files    Fri May 14 08:31:14 2021 +0000
+++ b/sys/conf/files    Fri May 14 08:41:25 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.1281 2021/05/14 08:31:14 yamaguchi Exp $
+#      $NetBSD: files,v 1.1282 2021/05/14 08:41:25 yamaguchi Exp $
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
 version        20171118
@@ -292,6 +292,7 @@
 
 defparam opt_sppp.h            SPPP_KEEPALIVE_INTERVAL
                                SPPP_NORECV_TIME
+                               SPPP_ALIVE_INTERVAL
 
 # networking options
 #
diff -r 4c476644de6b -r 074089154450 sys/net/if_sppp.h
--- a/sys/net/if_sppp.h Fri May 14 08:31:14 2021 +0000
+++ b/sys/net/if_sppp.h Fri May 14 08:41:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sppp.h,v 1.35 2021/05/11 06:42:42 yamaguchi Exp $   */
+/*     $NetBSD: if_sppp.h,v 1.36 2021/05/14 08:41:25 yamaguchi Exp $   */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -153,6 +153,7 @@
        u_int   maxalive;               /* number of LCP echo req. w/o reply */
        time_t  max_noreceive;          /* (sec.) grace period before we start
                                           sending LCP echo requests. */
+       u_int   alive_interval;         /* number of keepalive between echo req. */
 };
 struct spppkeepalivesettings50 {
        char    ifname[IFNAMSIZ];       /* pppoe interface name */
diff -r 4c476644de6b -r 074089154450 sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c     Fri May 14 08:31:14 2021 +0000
+++ b/sys/net/if_spppsubr.c     Fri May 14 08:41:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_spppsubr.c,v 1.240 2021/05/14 08:31:14 yamaguchi Exp $       */
+/*     $NetBSD: if_spppsubr.c,v 1.241 2021/05/14 08:41:25 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.240 2021/05/14 08:31:14 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.241 2021/05/14 08:41:25 yamaguchi Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -98,6 +98,7 @@
 #endif
 
 #define DEFAULT_KEEPALIVE_INTERVAL     10      /* seconds between checks */
+#define DEFAULT_ALIVE_INTERVAL         1       /* count of sppp_keepalive */
 #define LOOPALIVECNT                   3       /* loopback detection tries */
 #define DEFAULT_MAXALIVECNT                    3       /* max. missed alive packets */
 #define        DEFAULT_NORECV_TIME             15      /* before we get worried */
@@ -111,6 +112,10 @@
 #define SPPP_NORECV_TIME       DEFAULT_NORECV_TIME
 #endif
 
+#ifndef SPPP_ALIVE_INTERVAL
+#define SPPP_ALIVE_INTERVAL            DEFAULT_ALIVE_INTERVAL
+#endif
+
 /*
  * Interface flags that can be set in an ifconfig command.
  *
@@ -289,6 +294,7 @@
 static struct sppp *spppq;
 static kmutex_t *spppq_lock = NULL;
 static callout_t keepalive_ch;
+static unsigned int sppp_keepalive_cnt = 0;
 
 #define SPPPQ_LOCK()   if (spppq_lock) \
                                mutex_enter(spppq_lock);
@@ -1102,6 +1108,7 @@
        sp->pp_cpq.ifq_maxlen = 20;
        sp->pp_loopcnt = 0;
        sp->pp_alivecnt = 0;
+       sp->pp_alive_interval = SPPP_ALIVE_INTERVAL;
        sp->pp_last_activity = 0;
        sp->pp_last_receive = 0;
        sp->pp_maxalive = DEFAULT_MAXALIVECNT;
@@ -5637,6 +5644,18 @@
                        continue;
                }
 
+               /* No echo request */
+               if (sp->pp_alive_interval == 0) {
+                       SPPP_UNLOCK(sp);
+                       continue;
+               }
+
+               /* send a ECHO_REQ once in sp->pp_alive_interval times */
+               if ((sppp_keepalive_cnt % sp->pp_alive_interval) != 0) {
+                       SPPP_UNLOCK(sp);
+                       continue;
+               }
+
                if (sp->pp_alivecnt >= sp->pp_maxalive) {
                        /* No keepalive packets got.  Stop the interface. */
                        sppp_wq_add(sp->wq_cp, &sp->work_ifdown);
@@ -5671,6 +5690,7 @@
                SPPP_UNLOCK(sp);
        }
        splx(s);
+       sppp_keepalive_cnt++;
        callout_reset(&keepalive_ch, hz * SPPP_KEEPALIVE_INTERVAL, sppp_keepalive, NULL);
 
        SPPPQ_UNLOCK();
@@ -6318,6 +6338,7 @@
                SPPP_LOCK(sp, RW_READER);
                settings->maxalive = sp->pp_maxalive;
                settings->max_noreceive = sp->pp_max_noreceive;
+               settings->alive_interval = sp->pp_alive_interval;
                SPPP_UNLOCK(sp);
            }
            break;
@@ -6329,6 +6350,7 @@
                SPPP_LOCK(sp, RW_WRITER);
                sp->pp_maxalive = settings->maxalive;
                sp->pp_max_noreceive = settings->max_noreceive;
+               sp->pp_alive_interval = settings->alive_interval;
                SPPP_UNLOCK(sp);
            }
            break;
diff -r 4c476644de6b -r 074089154450 sys/net/if_spppvar.h
--- a/sys/net/if_spppvar.h      Fri May 14 08:31:14 2021 +0000
+++ b/sys/net/if_spppvar.h      Fri May 14 08:41:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_spppvar.h,v 1.37 2021/05/11 01:27:45 yamaguchi Exp $        */
+/*     $NetBSD: if_spppvar.h,v 1.38 2021/05/14 08:41:25 yamaguchi Exp $        */
 
 #ifndef _NET_IF_SPPPVAR_H_
 #define _NET_IF_SPPPVAR_H_
@@ -144,6 +144,7 @@
        u_int   pp_ncpflags;    /* enable or disable each NCP */
        u_int   pp_framebytes;  /* number of bytes added by (hardware) framing */
        u_int   pp_alivecnt;    /* keepalive packets counter */
+       u_int   pp_alive_interval;      /* keepalive interval */
        u_int   pp_loopcnt;     /* loopback detection counter */
        u_int   pp_maxalive;    /* number or echo req. w/o reply */
        uint64_t        pp_saved_mtu;   /* saved MTU value */



Home | Main Index | Thread Index | Old Index