|
42 | 42 | #define AHASH_MAX_SIZE (6 * AHASH_INIT_SIZE)
|
43 | 43 | /* Max muber of elements in the array block when tuned */
|
44 | 44 | #define AHASH_MAX_TUNED 64
|
45 |
| - |
46 | 45 | #define AHASH_MAX(h) ((h)->bucketsize)
|
47 | 46 |
|
48 |
| -/* Max number of elements can be tuned */ |
49 |
| -#ifdef IP_SET_HASH_WITH_MULTI |
50 |
| -static u8 |
51 |
| -tune_bucketsize(u8 curr, u32 multi) |
52 |
| -{ |
53 |
| - u32 n; |
54 |
| - |
55 |
| - if (multi < curr) |
56 |
| - return curr; |
57 |
| - |
58 |
| - n = curr + AHASH_INIT_SIZE; |
59 |
| - /* Currently, at listing one hash bucket must fit into a message. |
60 |
| - * Therefore we have a hard limit here. |
61 |
| - */ |
62 |
| - return n > curr && n <= AHASH_MAX_TUNED ? n : curr; |
63 |
| -} |
64 |
| -#define TUNE_BUCKETSIZE(h, multi) \ |
65 |
| - ((h)->bucketsize = tune_bucketsize((h)->bucketsize, multi)) |
66 |
| -#else |
67 |
| -#define TUNE_BUCKETSIZE(h, multi) |
68 |
| -#endif |
69 |
| - |
70 | 47 | /* A hash bucket */
|
71 | 48 | struct hbucket {
|
72 | 49 | struct rcu_head rcu; /* for call_rcu */
|
@@ -936,7 +913,12 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,
|
936 | 913 | goto set_full;
|
937 | 914 | /* Create a new slot */
|
938 | 915 | if (n->pos >= n->size) {
|
939 |
| - TUNE_BUCKETSIZE(h, multi); |
| 916 | +#ifdef IP_SET_HASH_WITH_MULTI |
| 917 | + if (h->bucketsize >= AHASH_MAX_TUNED) |
| 918 | + goto set_full; |
| 919 | + else if (h->bucketsize < multi) |
| 920 | + h->bucketsize += AHASH_INIT_SIZE; |
| 921 | +#endif |
940 | 922 | if (n->size >= AHASH_MAX(h)) {
|
941 | 923 | /* Trigger rehashing */
|
942 | 924 | mtype_data_next(&h->next, d);
|
|
0 commit comments