patch-2.1.89 linux/net/core/utils.c
Next file: linux/net/ipv4/af_inet.c
Previous file: linux/net/core/sysctl_net_core.c
Back to the patch index
Back to the overall index
- Lines: 38
- Date:
Sun Mar 1 14:40:40 1998
- Orig file:
v2.1.88/linux/net/core/utils.c
- Orig date:
Mon Jan 12 15:28:25 1998
diff -u --recursive --new-file v2.1.88/linux/net/core/utils.c linux/net/core/utils.c
@@ -35,6 +35,8 @@
net_random();
}
+int net_msg_cost = 5*HZ;
+int net_msg_burst = 10*5*HZ;
/*
* This enforces a rate limit: not more than one kernel message
@@ -44,16 +46,21 @@
*/
int net_ratelimit(void)
{
+ static unsigned long toks = 10*5*HZ;
static unsigned long last_msg;
static int missed;
-
- if ((jiffies - last_msg) >= 5*HZ) {
- if (missed)
- printk(KERN_WARNING "ipv4: (%d messages suppressed. Flood?)\n", missed);
- missed = 0;
- last_msg = jiffies;
+ unsigned long now = jiffies;
+
+ toks += now - xchg(&last_msg, now);
+ if (toks > net_msg_burst)
+ toks = net_msg_burst;
+ if (toks >= net_msg_cost) {
+ toks -= net_msg_cost;
+ if (missed)
+ printk(KERN_WARNING "NET: %d messages suppressed.\n", missed);
+ missed = 0;
return 1;
}
missed++;
- return 0;
+ return 0;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov