diff options
author | ume <ume@FreeBSD.org> | 2003-10-22 19:23:51 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2003-10-22 19:23:51 +0000 |
commit | e0831e433fdd0ab2bf8adf68624e7327572f28d2 (patch) | |
tree | 3cd811de27f2e06f2ed22ca586940cf6ec35636c /sys/netinet6 | |
parent | e4d75ae386949744f8649da151e4737f04402e98 (diff) | |
download | FreeBSD-src-e0831e433fdd0ab2bf8adf68624e7327572f28d2.zip FreeBSD-src-e0831e433fdd0ab2bf8adf68624e7327572f28d2.tar.gz |
we have ppsratecheck().
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/icmp6.c | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 5b4c5d8..aa96326 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -129,10 +129,6 @@ static int icmp6_rip6_input __P((struct mbuf **, int)); static int icmp6_ratelimit __P((const struct in6_addr *, const int, const int)); static const char *icmp6_redirect_diag __P((struct in6_addr *, struct in6_addr *, struct in6_addr *)); -#define HAVE_PPSRATECHECK -#ifndef HAVE_PPSRATECHECK -static int ppsratecheck __P((struct timeval *, int *, int)); -#endif static struct mbuf *ni6_input __P((struct mbuf *, int)); static struct mbuf *ni6_nametodns __P((const char *, int, int)); static int ni6_dnsmatch __P((const char *, int, const char *, int)); @@ -2738,76 +2734,6 @@ icmp6_ctloutput(so, sopt) return (error); } -#ifndef HAVE_PPSRATECHECK -#ifndef timersub -#define timersub(tvp, uvp, vvp) \ - do { \ - (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ - (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ - if ((vvp)->tv_usec < 0) { \ - (vvp)->tv_sec--; \ - (vvp)->tv_usec += 1000000; \ - } \ - } while (0) -#endif - -/* - * ppsratecheck(): packets (or events) per second limitation. - */ -static int -ppsratecheck(lasttime, curpps, maxpps) - struct timeval *lasttime; - int *curpps; - int maxpps; /* maximum pps allowed */ -{ - struct timeval tv, delta; - int s, rv; - - s = splclock(); - microtime(&tv); - splx(s); - - timersub(&tv, lasttime, &delta); - - /* - * Check for 0,0 so that the message will be seen at least once. - * If more than one second has passed since the last update of - * lasttime, reset the counter. - * - * We do increment *curpps even in *curpps < maxpps case, as some may - * try to use *curpps for stat purposes as well. - */ - if ((lasttime->tv_sec == 0 && lasttime->tv_usec == 0) || - delta.tv_sec >= 1) { - *lasttime = tv; - *curpps = 0; - rv = 1; - } else if (maxpps < 0) - rv = 1; - else if (*curpps < maxpps) - rv = 1; - else - rv = 0; - -#if 1 /* DIAGNOSTIC? */ - /* be careful about wrap-around */ - if (*curpps + 1 > *curpps) - *curpps = *curpps + 1; -#else - /* - * assume that there's not too many calls to this function. - * not sure if the assumption holds, as it depends on *caller's* - * behavior, not the behavior of this function. - * IMHO it is wrong to make assumption on the caller's behavior, - * so the above #if is #if 1, not #ifdef DIAGNOSTIC. - */ - *curpps = *curpps + 1; -#endif - - return (rv); -} -#endif - /* * Perform rate limit check. * Returns 0 if it is okay to send the icmp6 packet. |