Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108441685
D44475.id136159.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D44475.id136159.diff
View Options
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1091,28 +1091,26 @@
* the 'final' error, but it doesn't make sense to solve the printing
* delay with more complex code.
*/
-struct icmp_rate {
- const char *descr;
- struct counter_rate cr;
-};
-VNET_DEFINE_STATIC(struct icmp_rate, icmp_rates[BANDLIM_MAX]) = {
- { "icmp unreach response" },
- { "icmp ping response" },
- { "icmp tstamp response" },
- { "closed port RST response" },
- { "open port RST response" },
- { "icmp6 unreach response" },
- { "sctp ootb response" }
-};
+VNET_DEFINE_STATIC(struct counter_rate, icmp_rates[BANDLIM_MAX]);
#define V_icmp_rates VNET(icmp_rates)
+static const char *icmp_rate_descrs[BANDLIM_MAX] = {
+ [BANDLIM_ICMP_UNREACH] = "icmp unreach",
+ [BANDLIM_ICMP_ECHO] = "icmp ping",
+ [BANDLIM_ICMP_TSTAMP] = "icmp tstamp",
+ [BANDLIM_RST_CLOSEDPORT] = "closed port RST",
+ [BANDLIM_RST_OPENPORT] = "open port RST",
+ [BANDLIM_ICMP6_UNREACH] = "icmp6 unreach",
+ [BANDLIM_SCTP_OOTB] = "sctp ootb",
+};
+
static void
icmp_bandlimit_init(void)
{
for (int i = 0; i < BANDLIM_MAX; i++) {
- V_icmp_rates[i].cr.cr_rate = counter_u64_alloc(M_WAITOK);
- V_icmp_rates[i].cr.cr_ticks = ticks;
+ V_icmp_rates[i].cr_rate = counter_u64_alloc(M_WAITOK);
+ V_icmp_rates[i].cr_ticks = ticks;
}
}
VNET_SYSINIT(icmp_bandlimit, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY,
@@ -1123,7 +1121,7 @@
{
for (int i = 0; i < BANDLIM_MAX; i++)
- counter_u64_free(V_icmp_rates[i].cr.cr_rate);
+ counter_u64_free(V_icmp_rates[i].cr_rate);
}
VNET_SYSUNINIT(icmp_bandlimit, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD,
icmp_bandlimit_uninit, NULL);
@@ -1142,7 +1140,7 @@
if ((V_icmplim + V_icmplim_curr_jitter) <= 0)
V_icmplim_curr_jitter = -V_icmplim + 1;
- pps = counter_ratecheck(&V_icmp_rates[which].cr, V_icmplim +
+ pps = counter_ratecheck(&V_icmp_rates[which], V_icmplim +
V_icmplim_curr_jitter);
if (pps > 0) {
/*
@@ -1160,8 +1158,9 @@
if (pps == -1)
return (-1);
if (pps > 0 && V_icmplim_output)
- log(LOG_NOTICE, "Limiting %s from %jd to %d packets/sec\n",
- V_icmp_rates[which].descr, (intmax_t )pps, V_icmplim +
+ log(LOG_NOTICE,
+ "Limiting %s response from %jd to %d packets/sec\n",
+ icmp_rate_descrs[which], (intmax_t )pps, V_icmplim +
V_icmplim_curr_jitter);
return (0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 25, 7:26 PM (18 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16161048
Default Alt Text
D44475.id136159.diff (2 KB)
Attached To
Mode
D44475: icmp: do not store per-VNET identical array of strings
Attached
Detach File
Event Timeline
Log In to Comment