diff options
author | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2010-06-22 10:49:41 +0200 |
---|---|---|
committer | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2010-06-22 10:49:41 +0200 |
commit | 020936c8c3375e1efe44a3087c891a4b2cbfe044 (patch) | |
tree | a94751e6f1f11bcf118129c343d1942bbf53e808 /kernel/ip_set_bitmap_ip.c | |
parent | 97a12ba3f184a76c406eb5622ec21a4d4d6fc8bf (diff) | |
download | ipset-020936c8c3375e1efe44a3087c891a4b2cbfe044.tar.gz |
ipset 5: last new feature addedv5.0-pre3
- the hash types can now store protocol together port, not only port
- lots of fixes everywhere: parser, error reporting, manpage
The last bits on the todo list before announcing ipset 5:
- recheck all the error messages
- add possibly more tests
- polish manpage
Diffstat (limited to 'kernel/ip_set_bitmap_ip.c')
-rw-r--r-- | kernel/ip_set_bitmap_ip.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/kernel/ip_set_bitmap_ip.c b/kernel/ip_set_bitmap_ip.c index 66d3979..27b9665 100644 --- a/kernel/ip_set_bitmap_ip.c +++ b/kernel/ip_set_bitmap_ip.c @@ -107,6 +107,7 @@ bitmap_ip_adt_policy[IPSET_ATTR_ADT_MAX+1] __read_mostly = { [IPSET_ATTR_IP_TO] = { .type = NLA_U32 }, [IPSET_ATTR_CIDR] = { .type = NLA_U8 }, [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, + [IPSET_ATTR_LINENO] = { .type = NLA_U32 }, }; static int @@ -115,7 +116,6 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *head, int len, { struct bitmap_ip *map = set->data; struct nlattr *tb[IPSET_ATTR_ADT_MAX]; - bool eexist = flags & IPSET_FLAG_EXIST; u32 ip, ip_to, id; int ret = 0; @@ -123,6 +123,9 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *head, int len, bitmap_ip_adt_policy)) return -IPSET_ERR_PROTOCOL; + if (tb[IPSET_ATTR_LINENO]) + *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]); + if (tb[IPSET_ATTR_IP]) ip = ip_set_get_h32(tb[IPSET_ATTR_IP]); else @@ -164,11 +167,10 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *head, int len, ret = adt == IPSET_ADD ? bitmap_ip_add(map, id) : bitmap_ip_del(map, id); - if (ret && !(ret == -IPSET_ERR_EXIST && eexist)) { - if (tb[IPSET_ATTR_LINENO]) - *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]); + if (ret && !ip_set_eexist(ret, flags)) return ret; - } + else + ret = 0; } return ret; } @@ -356,7 +358,6 @@ bitmap_ip_timeout_uadt(struct ip_set *set, struct nlattr *head, int len, { struct bitmap_ip_timeout *map = set->data; struct nlattr *tb[IPSET_ATTR_ADT_MAX]; - bool eexist = flags & IPSET_FLAG_EXIST; u32 ip, ip_to, id, timeout = map->timeout; int ret = 0; @@ -364,6 +365,9 @@ bitmap_ip_timeout_uadt(struct ip_set *set, struct nlattr *head, int len, bitmap_ip_adt_policy)) return -IPSET_ERR_PROTOCOL; + if (tb[IPSET_ATTR_LINENO]) + *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]); + if (tb[IPSET_ATTR_IP]) ip = ip_set_get_h32(tb[IPSET_ATTR_IP]); else @@ -405,11 +409,10 @@ bitmap_ip_timeout_uadt(struct ip_set *set, struct nlattr *head, int len, ? bitmap_ip_timeout_add(map, id, timeout) : bitmap_ip_timeout_del(map, id); - if (ret && !(ret == -IPSET_ERR_EXIST && eexist)) { - if (tb[IPSET_ATTR_LINENO]) - *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]); + if (ret && !ip_set_eexist(ret, flags)) return ret; - } + else + ret = 0; } return ret; } |