Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys pullup (approved by releng-1-5)



details:   https://anonhg.NetBSD.org/src/rev/1cfbfcd69c61
branches:  netbsd-1-5
changeset: 489123:1cfbfcd69c61
user:      itojun <itojun%NetBSD.org@localhost>
date:      Wed Aug 16 01:22:21 2000 +0000

description:
pullup (approved by releng-1-5)

switch from net.inet*.*.*ratelimit to net.inet*.*.ppslimit.

(tags are rough estimate - we had some try-and-error in main trunc)
sys/netinet/icmp6.h             1.9 -> 1.11
sys/netinet/icmp_var.h          1.15 -> 1.17
sys/netinet/in_proto.c          1.39 -> 1.42
sys/netinet/ip_icmp.c           1.50 -> 1.51, 1.52 -> 1.54
sys/netinet/tcp_input.c         1.111 -> 1.112, 1.115 -> 1.117
sys/netinet/tcp_usrreq.c        1.52 -> 1.53
sys/netinet/tcp_var.h           1.72 -> 1.75
sys/netinet6/icmp6.c            1.34 -> 1.35, 1.36 -> 1.38
sys/netinet6/in6_proto.c        1.17 -> 1.19

diffstat:

 sys/netinet/icmp6.h      |  10 ++++----
 sys/netinet/icmp_var.h   |  10 ++++++--
 sys/netinet/in_proto.c   |   6 ++--
 sys/netinet/ip_icmp.c    |  52 +++++++++++++++--------------------------------
 sys/netinet/tcp_input.c  |  10 +++++---
 sys/netinet/tcp_usrreq.c |  24 +---------------------
 sys/netinet/tcp_var.h    |  15 +++++++++----
 sys/netinet6/icmp6.c     |  49 ++++++++++++++++----------------------------
 sys/netinet6/in6_proto.c |  10 ++++----
 9 files changed, 72 insertions(+), 114 deletions(-)

diffs (truncated from 454 to 300 lines):

diff -r ba4086ec09aa -r 1cfbfcd69c61 sys/netinet/icmp6.h
--- a/sys/netinet/icmp6.h       Wed Aug 16 01:20:29 2000 +0000
+++ b/sys/netinet/icmp6.h       Wed Aug 16 01:22:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: icmp6.h,v 1.9.2.3 2000/08/04 15:11:58 itojun Exp $     */
+/*     $NetBSD: icmp6.h,v 1.9.2.4 2000/08/16 01:22:21 itojun Exp $     */
 /*     $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $  */
 
 /*
@@ -509,7 +509,9 @@
 #define ICMPV6CTL_STATS                1
 #define ICMPV6CTL_REDIRACCEPT  2       /* accept/process redirects */
 #define ICMPV6CTL_REDIRTIMEOUT 3       /* redirect cache time */
+#if 0  /*obsoleted*/
 #define ICMPV6CTL_ERRRATELIMIT 5       /* ICMPv6 error rate limitation */
+#endif
 #define ICMPV6CTL_ND6_PRUNE    6
 #define ICMPV6CTL_ND6_DELAY    8
 #define ICMPV6CTL_ND6_UMAXTRIES        9
@@ -517,9 +519,7 @@
 #define ICMPV6CTL_ND6_USELOOPBACK      11
 /*#define ICMPV6CTL_ND6_PROXYALL       12      obsoleted, do not reuse here */
 #define ICMPV6CTL_NODEINFO     13
-#if 0  /*notyet*/
 #define ICMPV6CTL_ERRPPSLIMIT  14      /* ICMPv6 error pps limitation */
-#endif
 #define ICMPV6CTL_ND6_MAXNUDHINT       15
 #define ICMPV6CTL_MAXID                16
 
@@ -529,7 +529,7 @@
        { "rediraccept", CTLTYPE_INT }, \
        { "redirtimeout", CTLTYPE_INT }, \
        { 0, 0 }, \
-       { "errratelimit", CTLTYPE_INT }, \
+       { 0, 0 }, \
        { "nd6_prune", CTLTYPE_INT }, \
        { 0, 0 }, \
        { "nd6_delay", CTLTYPE_INT }, \
@@ -538,7 +538,7 @@
        { "nd6_useloopback", CTLTYPE_INT }, \
        { 0, 0 }, \
        { "nodeinfo", CTLTYPE_INT }, \
-       { 0, 0 }, \
+       { "errppslimit", CTLTYPE_INT }, \
        { "nd6_maxnudhint", CTLTYPE_INT }, \
 }
 
diff -r ba4086ec09aa -r 1cfbfcd69c61 sys/netinet/icmp_var.h
--- a/sys/netinet/icmp_var.h    Wed Aug 16 01:20:29 2000 +0000
+++ b/sys/netinet/icmp_var.h    Wed Aug 16 01:22:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: icmp_var.h,v 1.15 2000/06/10 12:39:20 darrenr Exp $    */
+/*     $NetBSD: icmp_var.h,v 1.15.2.1 2000/08/16 01:22:22 itojun Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -61,15 +61,19 @@
  * Names for ICMP sysctl objects
  */
 #define        ICMPCTL_MASKREPL        1       /* allow replies to netmask requests */
+#if 0  /*obsoleted*/
 #define ICMPCTL_ERRRATELIMIT   2       /* error rate limit */
+#endif
 #define ICMPCTL_RETURNDATABYTES        3       /* # of bytes to include in errors */
-#define ICMPCTL_MAXID          4
+#define ICMPCTL_ERRPPSLIMIT    4       /* ICMP error pps limitation */
+#define ICMPCTL_MAXID          5
 
 #define ICMPCTL_NAMES { \
        { 0, 0 }, \
        { "maskrepl", CTLTYPE_INT }, \
-       { "errratelimit", CTLTYPE_INT }, \
+       { 0, 0 }, \
        { "returndatabytes", CTLTYPE_INT }, \
+       { "errppslimit", CTLTYPE_INT }, \
 }
 
 #ifdef _KERNEL
diff -r ba4086ec09aa -r 1cfbfcd69c61 sys/netinet/in_proto.c
--- a/sys/netinet/in_proto.c    Wed Aug 16 01:20:29 2000 +0000
+++ b/sys/netinet/in_proto.c    Wed Aug 16 01:22:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_proto.c,v 1.39 2000/04/19 06:30:54 itojun Exp $     */
+/*     $NetBSD: in_proto.c,v 1.39.4.1 2000/08/16 01:22:22 itojun Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -301,6 +301,6 @@
 struct syn_cache_head tcp_syn_cache[TCP_SYN_HASH_SIZE];
 int    tcp_syn_cache_interval = 1;     /* runs timer twice a second */
 
-struct timeval tcp_rst_ratelim = { 0, 10000 }; /* 10000usec = 10msec */
+int tcp_rst_ppslim = 100;                      /* 100pps */
 
-struct timeval icmperrratelim = { 0, 1000 };   /* 1000usec = 1msec */
+int icmperrppslim = 100;                       /* 100pps */
diff -r ba4086ec09aa -r 1cfbfcd69c61 sys/netinet/ip_icmp.c
--- a/sys/netinet/ip_icmp.c     Wed Aug 16 01:20:29 2000 +0000
+++ b/sys/netinet/ip_icmp.c     Wed Aug 16 01:22:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_icmp.c,v 1.47.2.2 2000/07/28 16:58:09 sommerfeld Exp $      */
+/*     $NetBSD: ip_icmp.c,v 1.47.2.3 2000/08/16 01:22:22 itojun Exp $  */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -154,7 +154,9 @@
 /*static*/ int ip_next_mtu __P((int, int));
 #endif
 
-extern struct timeval icmperrratelim;
+extern int icmperrppslim;
+static int icmperrpps_count = 0;
+static struct timeval icmperrppslim_last;
 
 static void icmp_mtudisc __P((struct icmp *));
 static void icmp_mtudisc_timeout __P((struct rtentry *, struct rttimer *));
@@ -831,7 +833,7 @@
        void *newp;
        size_t newlen;
 {
-       int arg, error, s;
+       int arg, error;
 
        /* All sysctl names at this level are terminal. */
        if (namelen != 1)
@@ -842,24 +844,6 @@
        case ICMPCTL_MASKREPL:
                error = sysctl_int(oldp, oldlenp, newp, newlen, &icmpmaskrepl);
                break;
-       case ICMPCTL_ERRRATELIMIT:
-               /*
-                * The sysctl specifies the rate in usec-between-icmp,
-                * so we must convert from/to a timeval.
-                */
-               arg = (icmperrratelim.tv_sec * 1000000) +
-                   icmperrratelim.tv_usec;
-               error = sysctl_int(oldp, oldlenp, newp, newlen, &arg);
-               if (error)
-                       break;
-               if (arg >= 0) {
-                       s = splsoftnet();
-                       icmperrratelim.tv_sec = arg / 1000000;
-                       icmperrratelim.tv_usec = arg % 1000000;
-                       splx(s);
-               } else
-                       error = EINVAL;
-               break;
        case ICMPCTL_RETURNDATABYTES:
                arg = icmpreturndatabytes;
                error = sysctl_int(oldp, oldlenp, newp, newlen, &arg);
@@ -870,6 +854,9 @@
                else
                        error = EINVAL;
                break;
+       case ICMPCTL_ERRPPSLIMIT:
+               error = sysctl_int(oldp, oldlenp, newp, newlen, &icmperrppslim);
+               break;
        default:
                error = ENOPROTOOPT;
                break;
@@ -1035,19 +1022,14 @@
        const int type;                 /* not used at this moment */
        const int code;                 /* not used at this moment */
 {
-       static struct timeval icmperrratelim_last;
-       struct in_ifaddr *ia;
 
-       /*
-        * Don't rate-limit if it's for us!  
-        */
-       INADDR_TO_IA(*dst, ia);
-       if (ia != NULL)
-               return 0;
-       
-       /*
-        * ratecheck() returns true if it is okay to send.  We return
-        * true if it is not okay to send.
-        */
-       return (ratecheck(&icmperrratelim_last, &icmperrratelim) == 0);
+       /* PPS limit */
+       if (!ppsratecheck(&icmperrppslim_last, &icmperrpps_count,
+           icmperrppslim)) {
+               /* The packet is subject to rate limit */
+               return 1;
+       }
+
+       /*okay to send*/
+       return 0;
 }
diff -r ba4086ec09aa -r 1cfbfcd69c61 sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c   Wed Aug 16 01:20:29 2000 +0000
+++ b/sys/netinet/tcp_input.c   Wed Aug 16 01:22:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_input.c,v 1.108.4.6 2000/07/28 02:31:08 itojun Exp $       */
+/*     $NetBSD: tcp_input.c,v 1.108.4.7 2000/08/16 01:22:22 itojun Exp $       */
 
 /*
 %%% portions-copyright-nrl-95
@@ -182,7 +182,6 @@
 #ifdef IPSEC
 #include <netinet6/ipsec.h>
 #include <netkey/key.h>
-#include <netkey/key_debug.h>
 #endif /*IPSEC*/
 #ifdef INET6
 #include "faith.h"
@@ -191,7 +190,8 @@
 int    tcprexmtthresh = 3;
 int    tcp_log_refused;
 
-struct timeval tcp_rst_ratelim_last;
+static int tcp_rst_ppslim_count = 0;
+static struct timeval tcp_rst_ppslim_last;
 
 #define TCP_PAWS_IDLE  (24 * 24 * 60 * 60 * PR_SLOWHZ)
 
@@ -2144,7 +2144,8 @@
         * an attempt to connect to or otherwise communicate with
         * a port for which we have no socket.
         */
-       if (ratecheck(&tcp_rst_ratelim_last, &tcp_rst_ratelim) == 0) {
+       if (ppsratecheck(&tcp_rst_ppslim_last, &tcp_rst_ppslim_count,
+           tcp_rst_ppslim) == 0) {
                /* XXX stat */
                goto drop;
        }
@@ -2483,6 +2484,7 @@
        return 0;
 }
 
+#include <netkey/key_debug.h>
 
 /*
  * TCP compressed state engine.  Currently used to hold compressed
diff -r ba4086ec09aa -r 1cfbfcd69c61 sys/netinet/tcp_usrreq.c
--- a/sys/netinet/tcp_usrreq.c  Wed Aug 16 01:20:29 2000 +0000
+++ b/sys/netinet/tcp_usrreq.c  Wed Aug 16 01:22:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_usrreq.c,v 1.51 2000/06/05 06:38:22 itojun Exp $   */
+/*     $NetBSD: tcp_usrreq.c,v 1.51.2.1 2000/08/16 01:22:24 itojun Exp $       */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -901,28 +901,6 @@
        if (namelen != 1)
                return (ENOTDIR);
 
-       /*
-        * The sysctl specifies usec-between-RST, so we must
-        * convert from/to a timeval.
-        */
-       if (name[0] == TCPCTL_RSTRATELIMIT) {
-               int rate_usec, error, s;
-
-               rate_usec = (tcp_rst_ratelim.tv_sec * 1000000) +
-                   tcp_rst_ratelim.tv_usec;
-               error = sysctl_int(oldp, oldlenp, newp, newlen, &rate_usec);
-               if (error)
-                       return (error);
-               if (rate_usec < 0)
-                       return (EINVAL);
-               s = splsoftnet();
-               tcp_rst_ratelim.tv_sec = rate_usec / 1000000;
-               tcp_rst_ratelim.tv_usec = rate_usec % 1000000;
-               splx(s);
-
-               return (0);
-       }
-
        if (name[0] < sizeof(tcp_ctlvars)/sizeof(tcp_ctlvars[0])
            && tcp_ctlvars[name[0]].valid) {
                if (tcp_ctlvars[name[0]].rdonly)
diff -r ba4086ec09aa -r 1cfbfcd69c61 sys/netinet/tcp_var.h
--- a/sys/netinet/tcp_var.h     Wed Aug 16 01:20:29 2000 +0000
+++ b/sys/netinet/tcp_var.h     Wed Aug 16 01:22:21 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_var.h,v 1.72 2000/02/15 19:54:12 thorpej Exp $     */
+/*     $NetBSD: tcp_var.h,v 1.72.4.1 2000/08/16 01:22:24 itojun Exp $  */
 
 /*
 %%% portions-copyright-nrl-98
@@ -534,8 +534,11 @@
 #define        TCPCTL_SLOWHZ           20      /* PR_SLOWHZ (read-only) */
 #define        TCPCTL_NEWRENO          21      /* NewReno Congestion Control */
 #define TCPCTL_LOG_REFUSED     22      /* Log refused connections */
+#if 0  /*obsoleted*/
 #define        TCPCTL_RSTRATELIMIT     23      /* RST rate limit */
-#define        TCPCTL_MAXID            24
+#endif
+#define        TCPCTL_RSTPPSLIMIT      24      /* RST pps limit */
+#define        TCPCTL_MAXID            25
 
 #define        TCPCTL_NAMES { \
        { 0, 0 }, \
@@ -561,7 +564,8 @@
        { "slowhz",     CTLTYPE_INT }, \
        { "newreno",    CTLTYPE_INT }, \
        { "log_refused",CTLTYPE_INT }, \
-       { "rstratelimit", CTLTYPE_INT }, \
+       { 0, 0 }, \



Home | Main Index | Thread Index | Old Index