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>

authored by Jozsef Kadlecsik and committed by Patrick McHardy a8a8a093 eafbd3fd

+10 -8
+10 -8
net/netfilter/ipset/ip_set_core.c
··· 1022 1022 if (cb->args[1] >= ip_set_max) 1023 1023 goto out; 1024 1024 1025 - pr_debug("args[0]: %ld args[1]: %ld\n", cb->args[0], cb->args[1]); 1026 1025 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]); 1027 1028 for (; cb->args[1] < max; cb->args[1]++) { 1028 1029 index = (ip_set_id_t) cb->args[1]; 1029 1030 set = ip_set_list[index]; ··· 1039 1038 * so that lists (unions of sets) are dumped last. 1040 1039 */ 1041 1040 if (cb->args[0] != DUMP_ONE && 1042 - !((cb->args[0] == DUMP_ALL) ^ 1043 - (set->type->features & IPSET_DUMP_LAST))) 1041 + ((cb->args[0] == DUMP_ALL) == 1042 + !!(set->type->features & IPSET_DUMP_LAST))) 1044 1043 continue; 1045 1044 pr_debug("List set: %s\n", set->name); 1046 1045 if (!cb->args[2]) { ··· 1084 1083 goto release_refcount; 1085 1084 } 1086 1085 } 1086 + /* If we dump all sets, continue with dumping last ones */ 1087 + if (cb->args[0] == DUMP_ALL) { 1088 + cb->args[0] = DUMP_LAST; 1089 + cb->args[1] = 0; 1090 + goto dump_last; 1091 + } 1087 1092 goto out; 1088 1093 1089 1094 nla_put_failure: ··· 1100 1093 pr_debug("release set %s\n", ip_set_list[index]->name); 1101 1094 ip_set_put_byindex(index); 1102 1095 } 1103 - 1104 - /* If we dump all sets, continue with dumping last ones */ 1105 - if (cb->args[0] == DUMP_ALL && cb->args[1] >= max && !cb->args[2]) 1106 - cb->args[0] = DUMP_LAST; 1107 - 1108 1096 out: 1109 1097 if (nlh) { 1110 1098 nlmsg_end(skb, nlh);