Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Sep 2018 21:11:41 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r338527 - head/sys/netinet
Message-ID:  <201809072111.w87LBfpJ066419@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Fri Sep  7 21:11:41 2018
New Revision: 338527
URL: https://svnweb.freebsd.org/changeset/base/338527

Log:
  Use ratecheck(9) in in_pcbinslbgrouphash().
  
  Reviewed by:	bz, Johannes Lundberg <johalun0@gmail.com>
  Approved by:	re (kib)
  Sponsored by:	The FreeBSD Foundation
  Differential revision:	https://reviews.freebsd.org/D17065

Modified:
  head/sys/netinet/in_pcb.c

Modified: head/sys/netinet/in_pcb.c
==============================================================================
--- head/sys/netinet/in_pcb.c	Fri Sep  7 18:05:09 2018	(r338526)
+++ head/sys/netinet/in_pcb.c	Fri Sep  7 21:11:41 2018	(r338527)
@@ -301,13 +301,14 @@ in_pcblbgroup_reorder(struct inpcblbgrouphead *hdr, st
 static int
 in_pcbinslbgrouphash(struct inpcb *inp)
 {
+	const static struct timeval interval = { 60, 0 };
+	static struct timeval lastprint;
 	struct inpcbinfo *pcbinfo;
 	struct inpcblbgrouphead *hdr;
 	struct inpcblbgroup *grp;
 	uint16_t hashmask, lport;
 	uint32_t group_index;
 	struct ucred *cred;
-	static int limit_logged = 0;
 
 	pcbinfo = inp->inp_pcbinfo;
 
@@ -364,11 +365,9 @@ in_pcbinslbgrouphash(struct inpcb *inp)
 			return (ENOBUFS);
 	} else if (grp->il_inpcnt == grp->il_inpsiz) {
 		if (grp->il_inpsiz >= INPCBLBGROUP_SIZMAX) {
-			if (!limit_logged) {
-				limit_logged = 1;
+			if (ratecheck(&lastprint, &interval))
 				printf("lb group port %d, limit reached\n",
 				    ntohs(grp->il_lport));
-			}
 			return (0);
 		}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201809072111.w87LBfpJ066419>