Skip to content

Commit a8a8a09

Browse files
Jozsef Kadlecsikkaber
authored andcommitted
netfilter: ipset: Fix the order of listing of sets
A restoreable saving of sets requires that list:set type of sets come last and the code part which should have taken into account the ordering was broken. The patch fixes the listing order. Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent eafbd3f commit a8a8a09

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

‎net/netfilter/ipset/ip_set_core.c‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,8 +1022,9 @@ ip_set_dump_start(struct sk_buff *skb, struct netlink_callback *cb)
10221022
if (cb->args[1] >= ip_set_max)
10231023
goto out;
10241024

1025-
pr_debug("args[0]: %ld args[1]: %ld\n", cb->args[0], cb->args[1]);
10261025
max = cb->args[0] == DUMP_ONE ? cb->args[1] + 1 : ip_set_max;
1026+
dump_last:
1027+
pr_debug("args[0]: %ld args[1]: %ld\n", cb->args[0], cb->args[1]);
10271028
for (; cb->args[1] < max; cb->args[1]++) {
10281029
index = (ip_set_id_t) cb->args[1];
10291030
set = ip_set_list[index];
@@ -1038,8 +1039,8 @@ ip_set_dump_start(struct sk_buff *skb, struct netlink_callback *cb)
10381039
* so that lists (unions of sets) are dumped last.
10391040
*/
10401041
if (cb->args[0] != DUMP_ONE &&
1041-
!((cb->args[0] == DUMP_ALL) ^
1042-
(set->type->features & IPSET_DUMP_LAST)))
1042+
((cb->args[0] == DUMP_ALL) ==
1043+
!!(set->type->features & IPSET_DUMP_LAST)))
10431044
continue;
10441045
pr_debug("List set: %s\n", set->name);
10451046
if (!cb->args[2]) {
@@ -1083,6 +1084,12 @@ ip_set_dump_start(struct sk_buff *skb, struct netlink_callback *cb)
10831084
goto release_refcount;
10841085
}
10851086
}
1087+
/* If we dump all sets, continue with dumping last ones */
1088+
if (cb->args[0] == DUMP_ALL) {
1089+
cb->args[0] = DUMP_LAST;
1090+
cb->args[1] = 0;
1091+
goto dump_last;
1092+
}
10861093
goto out;
10871094

10881095
nla_put_failure:
@@ -1093,11 +1100,6 @@ ip_set_dump_start(struct sk_buff *skb, struct netlink_callback *cb)
10931100
pr_debug("release set %s\n", ip_set_list[index]->name);
10941101
ip_set_put_byindex(index);
10951102
}
1096-
1097-
/* If we dump all sets, continue with dumping last ones */
1098-
if (cb->args[0] == DUMP_ALL && cb->args[1] >= max && !cb->args[2])
1099-
cb->args[0] = DUMP_LAST;
1100-
11011103
out:
11021104
if (nlh) {
11031105
nlmsg_end(skb, nlh);

0 commit comments

Comments
 (0)