Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[cascardo/linux.git] / net / netfilter / ipset / ip_set_hash_ipmark.c
index 7abf978..d231248 100644 (file)
@@ -63,10 +63,10 @@ hash_ipmark4_data_list(struct sk_buff *skb,
        if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip) ||
            nla_put_net32(skb, IPSET_ATTR_MARK, htonl(data->mark)))
                goto nla_put_failure;
-       return 0;
+       return false;
 
 nla_put_failure:
-       return 1;
+       return true;
 }
 
 static inline void
@@ -76,10 +76,8 @@ hash_ipmark4_data_next(struct hash_ipmark4_elem *next,
        next->ip = d->ip;
 }
 
-#define MTYPE           hash_ipmark4
-#define PF              4
-#define HOST_MASK       32
-#define HKEY_DATALEN   sizeof(struct hash_ipmark4_elem)
+#define MTYPE          hash_ipmark4
+#define HOST_MASK      32
 #include "ip_set_hash_gen.h"
 
 static int
@@ -123,12 +121,15 @@ hash_ipmark4_uadt(struct ip_set *set, struct nlattr *tb[],
        if (tb[IPSET_ATTR_LINENO])
                *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
 
-       ret = ip_set_get_ipaddr4(tb[IPSET_ATTR_IP], &e.ip) ||
-             ip_set_get_extensions(set, tb, &ext);
+       ret = ip_set_get_ipaddr4(tb[IPSET_ATTR_IP], &e.ip);
        if (ret)
                return ret;
 
-       e.mark = ntohl(nla_get_u32(tb[IPSET_ATTR_MARK]));
+       ret = ip_set_get_extensions(set, tb, &ext);
+       if (ret)
+               return ret;
+
+       e.mark = ntohl(nla_get_be32(tb[IPSET_ATTR_MARK]));
        e.mark &= h->markmask;
 
        if (adt == IPSET_TEST ||
@@ -147,7 +148,7 @@ hash_ipmark4_uadt(struct ip_set *set, struct nlattr *tb[],
        } else if (tb[IPSET_ATTR_CIDR]) {
                u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
 
-               if (!cidr || cidr > 32)
+               if (!cidr || cidr > HOST_MASK)
                        return -IPSET_ERR_INVALID_CIDR;
                ip_set_mask_from_to(ip, ip_to, cidr);
        }
@@ -191,10 +192,10 @@ hash_ipmark6_data_list(struct sk_buff *skb,
        if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip.in6) ||
            nla_put_net32(skb, IPSET_ATTR_MARK, htonl(data->mark)))
                goto nla_put_failure;
-       return 0;
+       return false;
 
 nla_put_failure:
-       return 1;
+       return true;
 }
 
 static inline void
@@ -204,15 +205,11 @@ hash_ipmark6_data_next(struct hash_ipmark4_elem *next,
 }
 
 #undef MTYPE
-#undef PF
 #undef HOST_MASK
-#undef HKEY_DATALEN
 
 #define MTYPE          hash_ipmark6
-#define PF             6
 #define HOST_MASK      128
-#define HKEY_DATALEN   sizeof(struct hash_ipmark6_elem)
-#define        IP_SET_EMIT_CREATE
+#define IP_SET_EMIT_CREATE
 #include "ip_set_hash_gen.h"
 
 
@@ -258,12 +255,15 @@ hash_ipmark6_uadt(struct ip_set *set, struct nlattr *tb[],
        if (tb[IPSET_ATTR_LINENO])
                *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
 
-       ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip) ||
-             ip_set_get_extensions(set, tb, &ext);
+       ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip);
+       if (ret)
+               return ret;
+
+       ret = ip_set_get_extensions(set, tb, &ext);
        if (ret)
                return ret;
 
-       e.mark = ntohl(nla_get_u32(tb[IPSET_ATTR_MARK]));
+       e.mark = ntohl(nla_get_be32(tb[IPSET_ATTR_MARK]));
        e.mark &= h->markmask;
 
        if (adt == IPSET_TEST) {
@@ -307,7 +307,8 @@ static struct ip_set_type hash_ipmark_type __read_mostly = {
                [IPSET_ATTR_LINENO]     = { .type = NLA_U32 },
                [IPSET_ATTR_BYTES]      = { .type = NLA_U64 },
                [IPSET_ATTR_PACKETS]    = { .type = NLA_U64 },
-               [IPSET_ATTR_COMMENT]    = { .type = NLA_NUL_STRING },
+               [IPSET_ATTR_COMMENT]    = { .type = NLA_NUL_STRING,
+                                           .len  = IPSET_MAX_COMMENT_SIZE },
                [IPSET_ATTR_SKBMARK]    = { .type = NLA_U64 },
                [IPSET_ATTR_SKBPRIO]    = { .type = NLA_U32 },
                [IPSET_ATTR_SKBQUEUE]   = { .type = NLA_U16 },