return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
/* Reply a LIST/SAVE request: dump the elements of the specified 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);
if (!nested) {
if (cb->args[2] == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto 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;
}
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]);
if (!nested) {
if (cb->args[2] == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto 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;
}
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
static int
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))
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
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;
}
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
static int
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))
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, adt);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
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;
}
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);
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
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;
}
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);
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
nla_put_failure:
nla_nest_cancel(skb, nested);
ipset_nest_end(skb, atd);
- return 0;
+ return -EMSGSIZE;
}
static int
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
static bool
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
static int
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))
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
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;
}
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
static int
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))
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, adt);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
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;
}
} 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;
} 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]);
}
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;
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)
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;
set = ip_set_list[index];
if (set == NULL) {
if (cb->args[0] == DUMP_ONE) {
- ret = -EEXIST;
+ ret = -ENOENT;
goto out;
}
continue;
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);
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,
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,
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,
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);
ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
if (ret < 0)
- return -EFAULT;
+ return ret;
return 0;
nlmsg_cancel(skb2, nlh2);
nlmsg_failure:
kfree_skb(skb2);
- return -EFAULT;
+ return -EMSGSIZE;
}
/* Get type data */
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;
nlmsg_cancel(skb2, nlh2);
nlmsg_failure:
kfree_skb(skb2);
- return -EFAULT;
+ return -EMSGSIZE;
}
/* Get protocol version */
ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
if (ret < 0)
- return -EFAULT;
+ return ret;
return 0;
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] = {
return 0;
nla_put_failure:
- return -EFAULT;
+ return -EMSGSIZE;
}
static int
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);
if (!nested) {
if (i == first) {
nla_nest_cancel(skb, atd);
- return -EFAULT;
+ return -EMSGSIZE;
} else
goto nla_put_failure;
}
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;
}
/* Core kernel error codes */
static const struct ipset_errcode_table core_errcode_table[] = {
/* Generic error codes */
- { EEXIST, 0,
+ { ENOENT, 0,
"The set with the given name does not exist" },
+ { EMSGSIZE, 0,
+ "Kernel error received: message could not be created" },
{ IPSET_ERR_PROTOCOL, 0,
"Kernel error received: ipset protocol error" },