Skip to content

Commit 0b0dc0f

Browse files
committed
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6
2 parents 0553c89 + a8a8a09 commit 0b0dc0f

3 files changed

Lines changed: 30 additions & 10 deletions

File tree

‎net/netfilter/ipset/ip_set_bitmap_ipmac.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ bitmap_ipmac_kadt(struct ip_set *set, const struct sk_buff *skb,
343343
ipset_adtfn adtfn = set->variant->adt[adt];
344344
struct ipmac data;
345345

346+
/* MAC can be src only */
347+
if (!(flags & IPSET_DIM_TWO_SRC))
348+
return 0;
349+
346350
data.id = ntohl(ip4addr(skb, flags & IPSET_DIM_ONE_SRC));
347351
if (data.id < map->first_ip || data.id > map->last_ip)
348352
return -IPSET_ERR_BITMAP_RANGE;

‎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);

‎net/netfilter/xt_set.c‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ set_match_v0_checkentry(const struct xt_mtchk_param *par)
8181
if (info->match_set.u.flags[IPSET_DIM_MAX-1] != 0) {
8282
pr_warning("Protocol error: set match dimension "
8383
"is over the limit!\n");
84+
ip_set_nfnl_put(info->match_set.index);
8485
return -ERANGE;
8586
}
8687

@@ -135,13 +136,19 @@ set_target_v0_checkentry(const struct xt_tgchk_param *par)
135136
if (index == IPSET_INVALID_ID) {
136137
pr_warning("Cannot find del_set index %u as target\n",
137138
info->del_set.index);
139+
if (info->add_set.index != IPSET_INVALID_ID)
140+
ip_set_nfnl_put(info->add_set.index);
138141
return -ENOENT;
139142
}
140143
}
141144
if (info->add_set.u.flags[IPSET_DIM_MAX-1] != 0 ||
142145
info->del_set.u.flags[IPSET_DIM_MAX-1] != 0) {
143146
pr_warning("Protocol error: SET target dimension "
144147
"is over the limit!\n");
148+
if (info->add_set.index != IPSET_INVALID_ID)
149+
ip_set_nfnl_put(info->add_set.index);
150+
if (info->del_set.index != IPSET_INVALID_ID)
151+
ip_set_nfnl_put(info->del_set.index);
145152
return -ERANGE;
146153
}
147154

@@ -192,6 +199,7 @@ set_match_checkentry(const struct xt_mtchk_param *par)
192199
if (info->match_set.dim > IPSET_DIM_MAX) {
193200
pr_warning("Protocol error: set match dimension "
194201
"is over the limit!\n");
202+
ip_set_nfnl_put(info->match_set.index);
195203
return -ERANGE;
196204
}
197205

@@ -219,7 +227,7 @@ set_target(struct sk_buff *skb, const struct xt_action_param *par)
219227
if (info->del_set.index != IPSET_INVALID_ID)
220228
ip_set_del(info->del_set.index,
221229
skb, par->family,
222-
info->add_set.dim,
230+
info->del_set.dim,
223231
info->del_set.flags);
224232

225233
return XT_CONTINUE;
@@ -245,13 +253,19 @@ set_target_checkentry(const struct xt_tgchk_param *par)
245253
if (index == IPSET_INVALID_ID) {
246254
pr_warning("Cannot find del_set index %u as target\n",
247255
info->del_set.index);
256+
if (info->add_set.index != IPSET_INVALID_ID)
257+
ip_set_nfnl_put(info->add_set.index);
248258
return -ENOENT;
249259
}
250260
}
251261
if (info->add_set.dim > IPSET_DIM_MAX ||
252-
info->del_set.flags > IPSET_DIM_MAX) {
262+
info->del_set.dim > IPSET_DIM_MAX) {
253263
pr_warning("Protocol error: SET target dimension "
254264
"is over the limit!\n");
265+
if (info->add_set.index != IPSET_INVALID_ID)
266+
ip_set_nfnl_put(info->add_set.index);
267+
if (info->del_set.index != IPSET_INVALID_ID)
268+
ip_set_nfnl_put(info->del_set.index);
255269
return -ERANGE;
256270
}
257271

0 commit comments

Comments
 (0)