Florian Westphal
e80456d79e
netfilter: ipset: remove need to allocate memory on delete operations
...
Allocating mem via GFP_ATOMIC on delete is problematic, delete operations
should always succeed.
Do in-place substitution: When /cidr reaches 0 count (no more elements in
the range), move ranges stored later in the array forward and keep the
count 0 ones at the end.
INIT_CIDR() can then check count == 0 without a need to search next element
in the array.
To avoid problems on weakly ordered architectures, pack the structure so it
is only 32bit wide, then use READ/WRITE_ONCE to store both cidr and count.
atomically.
Also update comments to mention the possible presence of ignored
0-count-0-cidr structures at the end and need for seqcount.
seqcount is used to restart. This avoids bogus range misses.
Given: [0]: /29 [1]: /24
cpu1 reads slot 0. then, right after, cpu2 removes /29. count drops to 0,
so it updates array to: [0], /24, [1], /0 (count 0).
cpu1 then skips /28: slot 0 was already visited, but slot 1 already replaced.
Note that mtype_add() doesn't check mtype_add_cidr() return value.
Doing this here is useless noise as this code is extensively rewritten
in the rhashtable replacement patch.
Assisted-by: Claude:claude-sonnet-5
Fixes: 8e5fd2a55e ("netfilter: ipset: rework cidr bookkeeping")
Signed-off-by: Florian Westphal <fw@strlen.de >
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org >
2026-08-18 00:52:22 +02:00
..
2026-08-18 00:52:22 +02:00
2026-08-13 11:00:14 -07:00
2026-03-29 11:21:24 -07:00
2026-06-23 13:10:34 +02:00
2026-05-24 22:55:47 +02:00
2026-03-19 10:26:31 +01:00
2026-07-31 14:47:03 +02:00
2022-02-04 06:30:28 +01:00
2026-07-24 11:45:19 +02:00
2026-08-01 20:45:24 +02:00
2026-07-24 11:45:19 +02:00
2026-08-10 13:01:37 +02:00
2026-07-24 11:45:19 +02:00
2026-08-10 21:20:44 +02:00
2026-06-05 16:16:44 +02:00
2026-07-24 11:45:19 +02:00
2026-04-08 07:51:31 +02:00
2026-07-02 12:17:14 +02:00
2026-08-10 13:03:15 +02:00
2026-07-24 11:45:19 +02:00
2023-10-24 13:16:30 +02:00
2026-07-02 12:17:14 +02:00
2026-07-24 11:45:19 +02:00
2026-07-02 12:17:14 +02:00
2026-07-02 12:17:14 +02:00
2026-01-20 16:23:37 +01:00
2026-06-14 12:51:55 +02:00
2026-01-20 16:23:37 +01:00
2026-01-20 16:23:37 +01:00
2026-08-10 20:25:56 +02:00
2026-08-14 12:23:12 -07:00
2026-07-22 13:47:02 +02:00
2026-08-10 20:25:56 +02:00
2026-07-02 12:17:14 +02:00
2026-06-14 12:51:55 +02:00
2026-07-30 12:53:19 -07:00
2026-07-02 12:17:14 +02:00
2026-08-13 13:12:24 +02:00
2026-07-24 11:45:19 +02:00
2026-06-05 13:11:55 +02:00
2022-02-04 06:30:28 +01:00
2026-06-15 14:09:57 -07:00
2026-01-02 12:04:28 -08:00
2026-08-13 11:00:14 -07:00
2024-09-12 15:41:03 +02:00
2026-08-10 13:03:08 +02:00
2026-07-08 15:33:44 +02:00
2026-08-10 13:02:37 +02:00
2022-07-11 16:25:14 +02:00
2026-02-21 01:02:28 -08:00
2026-08-13 13:12:24 +02:00
2024-06-19 18:41:59 +02:00
2026-08-13 11:00:14 -07:00
2026-02-21 01:02:28 -08:00
2026-07-24 11:45:19 +02:00
2026-01-02 12:04:28 -08:00
2026-07-02 12:17:14 +02:00
2026-07-24 11:45:19 +02:00
2026-07-22 13:47:02 +02:00
2026-07-24 11:45:19 +02:00
2026-03-29 11:21:24 -07:00
2026-01-20 16:23:37 +01:00
2026-07-02 12:17:14 +02:00
2023-11-08 16:40:30 +01:00
2026-07-30 12:53:19 -07:00
2026-07-24 11:45:19 +02:00
2026-06-19 12:19:58 +02:00
2026-06-05 13:11:55 +02:00
2026-07-23 17:59:30 +02:00
2026-06-14 12:50:01 +02:00
2026-08-10 20:27:29 +02:00
2026-06-14 12:50:01 +02:00
2026-04-08 07:51:30 +02:00
2026-07-10 10:20:05 +02:00
2026-07-02 12:17:14 +02:00
2026-07-02 12:17:14 +02:00
2026-08-10 20:26:37 +02:00
2026-06-05 13:11:54 +02:00
2026-08-18 00:51:40 +02:00
2026-03-09 18:32:45 -07:00
2026-05-22 12:28:46 +02:00
2026-06-01 13:43:53 +02:00
2026-03-12 12:53:34 -07:00
2023-11-08 13:52:32 +01:00
2026-04-08 07:51:31 +02:00
2026-06-23 08:11:22 +02:00
2026-04-08 07:51:30 +02:00
2026-02-25 19:36:26 -08:00
2026-06-14 12:50:01 +02:00
2026-08-10 13:03:15 +02:00
2026-02-25 19:36:26 -08:00
2026-04-08 07:51:30 +02:00
2026-06-15 14:09:57 -07:00
2026-02-25 19:36:26 -08:00
2026-06-30 06:37:12 +02:00
2026-06-30 06:37:12 +02:00
2026-02-25 19:36:26 -08:00
2026-06-14 13:07:03 +02:00
2026-04-08 07:51:31 +02:00
2026-04-08 07:51:31 +02:00
2026-06-14 12:50:01 +02:00
2026-02-26 10:23:00 -08:00
2026-04-08 07:51:30 +02:00
2026-04-08 07:51:30 +02:00
2026-07-08 15:33:37 +02:00
2026-06-14 12:50:01 +02:00
2026-07-31 14:47:03 +02:00
2026-02-25 19:36:26 -08:00
2026-04-08 07:51:31 +02:00
2026-04-08 07:51:31 +02:00
2026-04-30 17:59:01 +02:00
2026-08-18 00:51:40 +02:00
2026-04-08 07:51:30 +02:00
2026-04-08 07:51:30 +02:00
2026-04-08 07:51:31 +02:00
2026-06-14 12:50:01 +02:00
2026-02-25 19:36:26 -08:00
2026-02-25 19:36:26 -08:00
2026-06-14 12:50:01 +02:00
2026-07-31 14:47:03 +02:00
2025-09-10 20:28:24 +02:00
2026-06-14 12:50:01 +02:00
2026-05-24 22:55:48 +02:00
2025-08-20 13:52:37 +02:00
2026-06-30 06:37:07 +02:00
2026-06-30 06:37:07 +02:00
2026-07-10 10:20:05 +02:00
2026-06-14 12:50:01 +02:00
2026-06-23 08:11:22 +02:00
2026-04-30 17:59:01 +02:00
2026-06-14 12:50:01 +02:00
2026-07-31 14:47:03 +02:00
2026-03-29 11:21:24 -07:00
2026-07-02 12:17:14 +02:00
2026-04-30 08:03:22 +02:00
2025-12-16 11:04:14 -05:00
2026-04-01 11:55:29 +02:00
2024-10-09 23:20:46 +02:00
2024-10-09 23:20:46 +02:00
2026-06-19 12:22:14 +02:00
2026-03-09 18:32:45 -07:00
2026-03-09 18:32:45 -07:00
2026-07-03 14:45:21 +02:00
2024-10-09 23:20:46 +02:00
2026-05-22 12:28:46 +02:00
2026-06-05 16:16:44 +02:00
2026-04-08 07:51:27 +02:00
2026-04-30 08:03:22 +02:00
2026-07-02 12:17:14 +02:00
2022-07-11 16:40:45 +02:00
2026-04-30 17:59:01 +02:00
2026-07-23 18:01:25 +02:00
2026-04-10 12:16:26 +02:00
2026-05-01 21:36:14 +02:00
2026-02-21 17:09:51 -08:00
2023-02-22 21:25:23 -08:00
2026-02-21 17:09:51 -08:00
2026-04-20 23:27:52 +02:00
2025-05-22 17:16:02 +02:00
2026-04-08 13:33:38 +02:00
2026-07-10 16:28:47 +02:00
2025-07-25 18:40:43 +02:00
2024-10-21 11:31:26 +02:00
2026-06-01 13:43:52 +02:00
2026-04-30 17:59:01 +02:00
2026-04-20 23:27:52 +02:00
2026-07-10 16:28:47 +02:00
2026-04-30 08:03:22 +02:00
2026-02-21 17:09:51 -08:00
2026-07-03 14:45:21 +02:00
2026-02-21 17:09:51 -08:00
2026-04-20 23:27:52 +02:00
2026-07-02 12:17:14 +02:00
2023-03-22 21:48:59 +01:00
2025-03-23 10:53:47 +01:00
2023-08-30 17:34:01 +02:00
2024-10-09 23:20:46 +02:00
2026-04-30 08:03:22 +02:00
2026-04-10 12:16:26 +02:00
2026-02-21 17:09:51 -08:00
2026-07-24 11:21:35 +02:00
2026-04-30 08:03:22 +02:00
2026-07-02 12:17:14 +02:00
2026-03-10 14:10:42 +01:00
2026-02-21 17:09:51 -08:00
2026-03-19 14:16:00 -07:00
2026-04-30 17:59:01 +02:00
2024-10-21 11:31:26 +02:00
2026-07-08 15:33:44 +02:00