summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2011-01-26 22:26:01 +0100
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2011-01-26 22:26:01 +0100
commitfa7f70f8042c5fd8b64821cbfd66fdea5c1a2a67 (patch)
tree1c085313c8e52bfe64efd5f34579ea1a3eac201a /kernel
parent16cfb322781f4555a2a385a3a9df8edbe5f58fe9 (diff)
Correct the error codes: use ENOENT and EMSGSIZE
Use correct error codes (Patrick McHardy's review)
Diffstat (limited to 'kernel')
-rw-r--r--kernel/include/linux/netfilter/ipset/ip_set_ahash.h12
-rw-r--r--kernel/ip_set_bitmap_ip.c20
-rw-r--r--kernel/ip_set_bitmap_ipmac.c16
-rw-r--r--kernel/ip_set_bitmap_port.c20
-rw-r--r--kernel/ip_set_core.c34
-rw-r--r--kernel/ip_set_list_set.c10
6 files changed, 69 insertions, 43 deletions
diff --git a/kernel/include/linux/netfilter/ipset/ip_set_ahash.h b/kernel/include/linux/netfilter/ipset/ip_set_ahash.h
index 8d4f259..ac98c2a 100644
--- a/kernel/include/linux/netfilter/ipset/ip_set_ahash.h
+++ b/kernel/include/linux/netfilter/ipset/ip_set_ahash.h
@@ -525,7 +525,7 @@ type_pf_head(struct ip_set *set, struct sk_buff *skb)
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
/* Reply a LIST/SAVE request: dump the elements of the specified set */
@@ -545,7 +545,7 @@ type_pf_list(const struct ip_set *set,
atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
if (!atd)
- return -EFAULT;
+ return -EMSGSIZE;
pr_debug("list hash set %s\n", set->name);
for (; cb->args[2] < jhash_size(t->htable_bits); cb->args[2]++) {
incomplete = skb_tail_pointer(skb);
@@ -559,7 +559,7 @@ type_pf_list(const struct ip_set *set,
if (!nested) {
if (cb->args[2] == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
@@ -581,6 +581,7 @@ nla_put_failure:
pr_warning("Can't list set %s: one bucket does not fit into "
"a message. Please report it!\n", set->name);
cb->args[2] = 0;
+ return -EMSGSIZE;
}
return 0;
}
@@ -946,7 +947,7 @@ type_pf_tlist(const struct ip_set *set,
atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
if (!atd)
- return -EFAULT;
+ return -EMSGSIZE;
for (; cb->args[2] < jhash_size(t->htable_bits); cb->args[2]++) {
incomplete = skb_tail_pointer(skb);
n = hbucket(t, cb->args[2]);
@@ -960,7 +961,7 @@ type_pf_tlist(const struct ip_set *set,
if (!nested) {
if (cb->args[2] == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
@@ -982,6 +983,7 @@ nla_put_failure:
pr_warning("Can't list set %s: one bucket does not fit into "
"a message. Please report it!\n", set->name);
cb->args[2] = 0;
+ return -EMSGSIZE;
}
return 0;
}
diff --git a/kernel/ip_set_bitmap_ip.c b/kernel/ip_set_bitmap_ip.c
index 4fbb360..f97dee2 100644
--- a/kernel/ip_set_bitmap_ip.c
+++ b/kernel/ip_set_bitmap_ip.c
@@ -217,7 +217,7 @@ bitmap_ip_head(struct ip_set *set, struct sk_buff *skb)
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
static int
@@ -230,7 +230,7 @@ bitmap_ip_list(const struct ip_set *set,
atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
if (!atd)
- return -EFAULT;
+ return -EMSGSIZE;
for (; cb->args[2] < map->elements; cb->args[2]++) {
id = cb->args[2];
if (!bitmap_ip_test(map, id))
@@ -239,7 +239,7 @@ bitmap_ip_list(const struct ip_set *set,
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
@@ -255,6 +255,10 @@ bitmap_ip_list(const struct ip_set *set,
nla_put_failure:
nla_nest_cancel(skb, nested);
ipset_nest_end(skb, atd);
+ if (unlikely(id == first)) {
+ cb->args[2] = 0;
+ return -EMSGSIZE;
+ }
return 0;
}
@@ -461,7 +465,7 @@ bitmap_ip_timeout_head(struct ip_set *set, struct sk_buff *skb)
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
static int
@@ -475,7 +479,7 @@ bitmap_ip_timeout_list(const struct ip_set *set,
adt = ipset_nest_start(skb, IPSET_ATTR_ADT);
if (!adt)
- return -EFAULT;
+ return -EMSGSIZE;
for (; cb->args[2] < map->elements; cb->args[2]++) {
id = cb->args[2];
if (!bitmap_ip_timeout_test(map, id))
@@ -484,7 +488,7 @@ bitmap_ip_timeout_list(const struct ip_set *set,
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, adt);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
@@ -504,6 +508,10 @@ bitmap_ip_timeout_list(const struct ip_set *set,
nla_put_failure:
nla_nest_cancel(skb, nested);
ipset_nest_end(skb, adt);
+ if (unlikely(id == first)) {
+ cb->args[2] = 0;
+ return -EMSGSIZE;
+ }
return 0;
}
diff --git a/kernel/ip_set_bitmap_ipmac.c b/kernel/ip_set_bitmap_ipmac.c
index 65cd1ea..68fec19 100644
--- a/kernel/ip_set_bitmap_ipmac.c
+++ b/kernel/ip_set_bitmap_ipmac.c
@@ -175,7 +175,7 @@ bitmap_ipmac_list(const struct ip_set *set,
atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
if (!atd)
- return -EFAULT;
+ return -EMSGSIZE;
for (; cb->args[2] <= last; cb->args[2]++) {
id = cb->args[2];
elem = bitmap_ipmac_elem(map, id);
@@ -185,7 +185,7 @@ bitmap_ipmac_list(const struct ip_set *set,
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
@@ -205,6 +205,10 @@ bitmap_ipmac_list(const struct ip_set *set,
nla_put_failure:
nla_nest_cancel(skb, nested);
ipset_nest_end(skb, atd);
+ if (unlikely(id == first)) {
+ cb->args[2] = 0;
+ return -EMSGSIZE;
+ }
return 0;
}
@@ -298,7 +302,7 @@ bitmap_ipmac_tlist(const struct ip_set *set,
atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
if (!atd)
- return -EFAULT;
+ return -EMSGSIZE;
for (; cb->args[2] <= last; cb->args[2]++) {
id = cb->args[2];
elem = bitmap_ipmac_elem(map, id);
@@ -308,7 +312,7 @@ bitmap_ipmac_tlist(const struct ip_set *set,
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
@@ -331,7 +335,7 @@ bitmap_ipmac_tlist(const struct ip_set *set,
nla_put_failure:
nla_nest_cancel(skb, nested);
ipset_nest_end(skb, atd);
- return 0;
+ return -EMSGSIZE;
}
static int
@@ -457,7 +461,7 @@ bitmap_ipmac_head(struct ip_set *set, struct sk_buff *skb)
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
static bool
diff --git a/kernel/ip_set_bitmap_port.c b/kernel/ip_set_bitmap_port.c
index fbd0aaf..3fb7c92 100644
--- a/kernel/ip_set_bitmap_port.c
+++ b/kernel/ip_set_bitmap_port.c
@@ -197,7 +197,7 @@ bitmap_port_head(struct ip_set *set, struct sk_buff *skb)
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
static int
@@ -211,7 +211,7 @@ bitmap_port_list(const struct ip_set *set,
atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
if (!atd)
- return -EFAULT;
+ return -EMSGSIZE;
for (; cb->args[2] <= last; cb->args[2]++) {
id = cb->args[2];
if (!test_bit(id, map->members))
@@ -220,7 +220,7 @@ bitmap_port_list(const struct ip_set *set,
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
@@ -237,6 +237,10 @@ bitmap_port_list(const struct ip_set *set,
nla_put_failure:
nla_nest_cancel(skb, nested);
ipset_nest_end(skb, atd);
+ if (unlikely(id == first)) {
+ cb->args[2] = 0;
+ return -EMSGSIZE;
+ }
return 0;
}
@@ -432,7 +436,7 @@ bitmap_port_timeout_head(struct ip_set *set, struct sk_buff *skb)
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
static int
@@ -447,7 +451,7 @@ bitmap_port_timeout_list(const struct ip_set *set,
adt = ipset_nest_start(skb, IPSET_ATTR_ADT);
if (!adt)
- return -EFAULT;
+ return -EMSGSIZE;
for (; cb->args[2] <= last; cb->args[2]++) {
id = cb->args[2];
if (!bitmap_port_timeout_test(map, id))
@@ -456,7 +460,7 @@ bitmap_port_timeout_list(const struct ip_set *set,
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, adt);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
@@ -476,6 +480,10 @@ bitmap_port_timeout_list(const struct ip_set *set,
nla_put_failure:
nla_nest_cancel(skb, nested);
ipset_nest_end(skb, adt);
+ if (unlikely(id == first)) {
+ cb->args[2] = 0;
+ return -EMSGSIZE;
+ }
return 0;
}
diff --git a/kernel/ip_set_core.c b/kernel/ip_set_core.c
index aa5d12f..023813b 100644
--- a/kernel/ip_set_core.c
+++ b/kernel/ip_set_core.c
@@ -755,7 +755,7 @@ ip_set_destroy(struct sock *ctnl, struct sk_buff *skb,
} else {
i = find_set_id(nla_data(attr[IPSET_ATTR_SETNAME]));
if (i == IPSET_INVALID_ID)
- return -EEXIST;
+ return -ENOENT;
else if (atomic_read(&ip_set_list[i]->ref))
return -IPSET_ERR_BUSY;
@@ -793,7 +793,7 @@ ip_set_flush(struct sock *ctnl, struct sk_buff *skb,
} else {
i = find_set_id(nla_data(attr[IPSET_ATTR_SETNAME]));
if (i == IPSET_INVALID_ID)
- return -EEXIST;
+ return -ENOENT;
ip_set_flush_set(ip_set_list[i]);
}
@@ -828,7 +828,7 @@ ip_set_rename(struct sock *ctnl, struct sk_buff *skb,
set = find_set(nla_data(attr[IPSET_ATTR_SETNAME]));
if (set == NULL)
- return -EEXIST;
+ return -ENOENT;
if (atomic_read(&set->ref) != 0)
return -IPSET_ERR_REFERENCED;
@@ -869,7 +869,7 @@ ip_set_swap(struct sock *ctnl, struct sk_buff *skb,
from_id = find_set_id(nla_data(attr[IPSET_ATTR_SETNAME]));
if (from_id == IPSET_INVALID_ID)
- return -EEXIST;
+ return -ENOENT;
to_id = find_set_id(nla_data(attr[IPSET_ATTR_SETNAME2]));
if (to_id == IPSET_INVALID_ID)
@@ -954,7 +954,7 @@ dump_init(struct netlink_callback *cb)
index = find_set_id(nla_data(cda[IPSET_ATTR_SETNAME]));
if (index == IPSET_INVALID_ID)
- return -EEXIST;
+ return -ENOENT;
cb->args[0] = DUMP_ONE;
cb->args[1] = index;
@@ -990,7 +990,7 @@ ip_set_dump_start(struct sk_buff *skb, struct netlink_callback *cb)
set = ip_set_list[index];
if (set == NULL) {
if (cb->args[0] == DUMP_ONE) {
- ret = -EEXIST;
+ ret = -ENOENT;
goto out;
}
continue;
@@ -1012,7 +1012,7 @@ ip_set_dump_start(struct sk_buff *skb, struct netlink_callback *cb)
cb->nlh->nlmsg_seq, flags,
IPSET_CMD_LIST);
if (!nlh) {
- ret = -EFAULT;
+ ret = -EMSGSIZE;
goto release_refcount;
}
NLA_PUT_U8(skb, IPSET_ATTR_PROTOCOL, IPSET_PROTOCOL);
@@ -1147,7 +1147,7 @@ ip_set_uadd(struct sock *ctnl, struct sk_buff *skb,
set = find_set(nla_data(attr[IPSET_ATTR_SETNAME]));
if (set == NULL)
- return -EEXIST;
+ return -ENOENT;
if (attr[IPSET_ATTR_DATA]) {
ret = call_ad(skb, attr,
@@ -1191,7 +1191,7 @@ ip_set_udel(struct sock *ctnl, struct sk_buff *skb,
set = find_set(nla_data(attr[IPSET_ATTR_SETNAME]));
if (set == NULL)
- return -EEXIST;
+ return -ENOENT;
if (attr[IPSET_ATTR_DATA]) {
ret = call_ad(skb, attr,
@@ -1228,7 +1228,7 @@ ip_set_utest(struct sock *ctnl, struct sk_buff *skb,
set = find_set(nla_data(attr[IPSET_ATTR_SETNAME]));
if (set == NULL)
- return -EEXIST;
+ return -ENOENT;
read_lock_bh(&set->lock);
ret = set->variant->uadt(set,
@@ -1262,7 +1262,7 @@ ip_set_header(struct sock *ctnl, struct sk_buff *skb,
index = find_set_id(nla_data(attr[IPSET_ATTR_SETNAME]));
if (index == IPSET_INVALID_ID)
- return -EEXIST;
+ return -ENOENT;
set = ip_set_list[index];
skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
@@ -1282,7 +1282,7 @@ ip_set_header(struct sock *ctnl, struct sk_buff *skb,
ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
if (ret < 0)
- return -EFAULT;
+ return ret;
return 0;
@@ -1290,7 +1290,7 @@ nla_put_failure:
nlmsg_cancel(skb2, nlh2);
nlmsg_failure:
kfree_skb(skb2);
- return -EFAULT;
+ return -EMSGSIZE;
}
/* Get type data */
@@ -1342,7 +1342,7 @@ ip_set_type(struct sock *ctnl, struct sk_buff *skb,
pr_debug("Send TYPE, nlmsg_len: %u\n", nlh2->nlmsg_len);
ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
if (ret < 0)
- return -EFAULT;
+ return ret;
return 0;
@@ -1350,7 +1350,7 @@ nla_put_failure:
nlmsg_cancel(skb2, nlh2);
nlmsg_failure:
kfree_skb(skb2);
- return -EFAULT;
+ return -EMSGSIZE;
}
/* Get protocol version */
@@ -1385,7 +1385,7 @@ ip_set_protocol(struct sock *ctnl, struct sk_buff *skb,
ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
if (ret < 0)
- return -EFAULT;
+ return ret;
return 0;
@@ -1393,7 +1393,7 @@ nla_put_failure:
nlmsg_cancel(skb2, nlh2);
nlmsg_failure:
kfree_skb(skb2);
- return -EFAULT;
+ return -EMSGSIZE;
}
static const struct nfnl_callback ip_set_netlink_subsys_cb[IPSET_MSG_MAX] = {
diff --git a/kernel/ip_set_list_set.c b/kernel/ip_set_list_set.c
index 892a106..933d9ef 100644
--- a/kernel/ip_set_list_set.c
+++ b/kernel/ip_set_list_set.c
@@ -392,7 +392,7 @@ list_set_head(struct ip_set *set, struct sk_buff *skb)
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
static int
@@ -406,7 +406,7 @@ list_set_list(const struct ip_set *set,
atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
if (!atd)
- return -EFAULT;
+ return -EMSGSIZE;
for (; cb->args[2] < map->size; cb->args[2]++) {
i = cb->args[2];
e = list_set_elem(map, i);
@@ -418,7 +418,7 @@ list_set_list(const struct ip_set *set,
if (!nested) {
if (i == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
@@ -441,6 +441,10 @@ finish:
nla_put_failure:
nla_nest_cancel(skb, nested);
ipset_nest_end(skb, atd);
+ if (unlikely(i == first)) {
+ cb->args[2] = 0;
+ return -EMSGSIZE;
+ }
return 0;
}