Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111606816
D32826.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D32826.diff
View Options
diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c
--- a/sys/netipsec/key.c
+++ b/sys/netipsec/key.c
@@ -5019,7 +5019,7 @@
key_do_getnewspi(struct sadb_spirange *spirange, struct secasindex *saidx)
{
uint32_t min, max, newspi, t;
- int count = V_key_spi_trycnt;
+ int tries, limit;
/* set spi range to allocate */
if (spirange != NULL) {
@@ -5047,21 +5047,22 @@
return 0;
}
- count--; /* taking one cost. */
+ tries = 1;
newspi = min;
} else {
/* init SPI */
newspi = 0;
+ limit = atomic_load_int(&V_key_spi_trycnt);
/* when requesting to allocate spi ranged */
- while (count--) {
+ for (tries = 0; tries < limit; tries++) {
/* generate pseudo-random SPI value ranged. */
newspi = min + (key_random() % (max - min + 1));
if (!key_checkspidup(htonl(newspi)))
break;
}
- if (count == 0 || newspi == 0) {
+ if (tries == limit || newspi == 0) {
ipseclog((LOG_DEBUG,
"%s: failed to allocate SPI.\n", __func__));
return 0;
@@ -5070,7 +5071,7 @@
/* statistics */
keystat.getspi_count =
- (keystat.getspi_count + V_key_spi_trycnt - count) / 2;
+ (keystat.getspi_count + tries) / 2;
return (htonl(newspi));
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 6, 10:41 PM (15 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17020911
Default Alt Text
D32826.diff (1 KB)
Attached To
Mode
D32826: ipsec: serialize SPI allocation
Attached
Detach File
Event Timeline
Log In to Comment