]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
Expose the initval hash parameter to userspace
authorJozsef Kadlecsik <kadlec@netfilter.org>
Mon, 21 Sep 2020 18:13:07 +0000 (20:13 +0200)
committerJozsef Kadlecsik <kadlec@netfilter.org>
Mon, 21 Sep 2020 18:13:07 +0000 (20:13 +0200)
It makes possible to reproduce exactly the same set after a save/restore.

Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
37 files changed:
Make_global.am
include/libipset/args.h
include/libipset/data.h
include/libipset/linux_ip_set.h
include/libipset/print.h
kernel/include/uapi/linux/netfilter/ipset/ip_set.h
kernel/net/netfilter/ipset/ip_set_hash_gen.h
kernel/net/netfilter/ipset/ip_set_hash_ip.c
kernel/net/netfilter/ipset/ip_set_hash_ipmac.c
kernel/net/netfilter/ipset/ip_set_hash_ipmark.c
kernel/net/netfilter/ipset/ip_set_hash_ipport.c
kernel/net/netfilter/ipset/ip_set_hash_ipportip.c
kernel/net/netfilter/ipset/ip_set_hash_ipportnet.c
kernel/net/netfilter/ipset/ip_set_hash_mac.c
kernel/net/netfilter/ipset/ip_set_hash_net.c
kernel/net/netfilter/ipset/ip_set_hash_netiface.c
kernel/net/netfilter/ipset/ip_set_hash_netnet.c
kernel/net/netfilter/ipset/ip_set_hash_netport.c
kernel/net/netfilter/ipset/ip_set_hash_netportnet.c
lib/args.c
lib/data.c
lib/debug.c
lib/ipset_hash_ip.c
lib/ipset_hash_ipmac.c
lib/ipset_hash_ipmark.c
lib/ipset_hash_ipport.c
lib/ipset_hash_ipportip.c
lib/ipset_hash_ipportnet.c
lib/ipset_hash_mac.c
lib/ipset_hash_net.c
lib/ipset_hash_netiface.c
lib/ipset_hash_netnet.c
lib/ipset_hash_netport.c
lib/ipset_hash_netportnet.c
lib/libipset.map
lib/print.c
lib/session.c

index 673aa41e7d4c877445f8ded6130de23050278804..cbc3537147f2cd9113e4506db9ad390194f7867e 100644 (file)
@@ -69,7 +69,7 @@
 # interface. 
 
 #            curr:rev:age
-LIBVERSION = 14:0:1
+LIBVERSION = 14:1:2
 
 AM_CPPFLAGS = $(kinclude_CFLAGS) $(all_includes) -I$(top_srcdir)/include
 
index 93b44569b29668b2e77e3ea629a35d00e70c8769..ef861c178656bd1418f2b11241069bbcb483b061 100644 (file)
@@ -57,6 +57,7 @@ enum ipset_keywords {
        IPSET_ARG_SKBPRIO,                      /* skbprio */
        IPSET_ARG_SKBQUEUE,                     /* skbqueue */
        IPSET_ARG_BUCKETSIZE,                   /* bucketsize */
+       IPSET_ARG_INITVAL,                      /* initval */
        IPSET_ARG_MAX,
 };
 
index cce64076cf74cd338744b991c66a0773170914af..0e33c67ca45dc704926b022881471f6e0e4474f3 100644 (file)
@@ -68,6 +68,7 @@ enum ipset_opt {
        IPSET_OPT_SKBQUEUE,
        IPSET_OPT_IFACE_WILDCARD,
        IPSET_OPT_BUCKETSIZE,
+       IPSET_OPT_INITVAL,
        /* Internal options */
        IPSET_OPT_FLAGS = 48,   /* IPSET_FLAG_EXIST| */
        IPSET_OPT_CADT_FLAGS,   /* IPSET_FLAG_BEFORE| */
index e67116f2ecb714bdea9b47a5d4bee77000272146..1852636f4730a60396182868ac90e987010b6e1b 100644 (file)
@@ -92,7 +92,7 @@ enum {
        /* Reserve empty slots */
        IPSET_ATTR_CADT_MAX = 16,
        /* Create-only specific attributes */
-       IPSET_ATTR_GC,
+       IPSET_ATTR_INITVAL,     /* was unused IPSET_ATTR_GC */
        IPSET_ATTR_HASHSIZE,
        IPSET_ATTR_MAXELEM,
        IPSET_ATTR_NETMASK,
index f4552592685c9d05fbc4dd789ef690c831fa9db6..9443ee1c9bb7659cfb023419ed44abc2ca918099 100644 (file)
@@ -35,6 +35,9 @@ extern int ipset_print_ipaddr(char *buf, unsigned int len,
 extern int ipset_print_number(char *buf, unsigned int len,
                              const struct ipset_data *data,
                              enum ipset_opt opt, uint8_t env);
+extern int ipset_print_hexnumber(char *buf, unsigned int len,
+                                const struct ipset_data *data,
+                                enum ipset_opt opt, uint8_t env);
 extern int ipset_print_name(char *buf, unsigned int len,
                            const struct ipset_data *data,
                            enum ipset_opt opt, uint8_t env);
index 60c411cf799e74afd095228ee0c43449055fd59a..8a495aaec73a695a32e539c93ad972613072ff42 100644 (file)
@@ -92,7 +92,7 @@ enum {
        /* Reserve empty slots */
        IPSET_ATTR_CADT_MAX = 16,
        /* Create-only specific attributes */
-       IPSET_ATTR_GC,
+       IPSET_ATTR_INITVAL,     /* was unused IPSET_ATTR_GC */
        IPSET_ATTR_HASHSIZE,
        IPSET_ATTR_MAXELEM,
        IPSET_ATTR_NETMASK,
index e84728ebd3b314929fe9bf6f3f54b4af972ff1d6..acfe0c89974981bf4387694975e7ff93b58691ac 100644 (file)
@@ -1302,9 +1302,11 @@ mtype_head(struct ip_set *set, struct sk_buff *skb)
        if (nla_put_u32(skb, IPSET_ATTR_MARKMASK, h->markmask))
                goto nla_put_failure;
 #endif
-       if (set->flags & IPSET_CREATE_FLAG_BUCKETSIZE &&
-           nla_put_u8(skb, IPSET_ATTR_BUCKETSIZE, h->bucketsize))
-               goto nla_put_failure;
+       if (set->flags & IPSET_CREATE_FLAG_BUCKETSIZE) {
+               if (nla_put_u8(skb, IPSET_ATTR_BUCKETSIZE, h->bucketsize) ||
+                   nla_put_net32(skb, IPSET_ATTR_INITVAL, htonl(h->initval)))
+                       goto nla_put_failure;
+       }
        if (nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref)) ||
            nla_put_net32(skb, IPSET_ATTR_MEMSIZE, htonl(memsize)) ||
            nla_put_net32(skb, IPSET_ATTR_ELEMENTS, htonl(elements)))
@@ -1547,7 +1549,10 @@ IPSET_TOKEN(HTYPE, _create)(struct net *net, struct ip_set *set,
 #ifdef IP_SET_HASH_WITH_MARKMASK
        h->markmask = markmask;
 #endif
-       get_random_bytes(&h->initval, sizeof(h->initval));
+       if (tb[IPSET_ATTR_INITVAL])
+               h->initval = ntohl(nla_get_be32(tb[IPSET_ATTR_INITVAL]));
+       else
+               get_random_bytes(&h->initval, sizeof(h->initval));
        h->bucketsize = AHASH_MAX_SIZE;
        if (tb[IPSET_ATTR_BUCKETSIZE]) {
                h->bucketsize = nla_get_u8(tb[IPSET_ATTR_BUCKETSIZE]);
index bb0cfd4fa9079ed4cbcb0fcc77000918fe1a59ac..94e17a56a9e894781a437247341d88dad5b49395 100644 (file)
@@ -25,7 +25,7 @@
 /*                             2          Comments support */
 /*                             3          Forceadd support */
 /*                             4          skbinfo support */
-#define IPSET_TYPE_REV_MAX     5       /* bucketsize support  */
+#define IPSET_TYPE_REV_MAX     5       /* bucketsize, initval support  */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@netfilter.org>");
@@ -284,6 +284,7 @@ static struct ip_set_type hash_ip_type __read_mostly = {
        .create_policy  = {
                [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
                [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
+               [IPSET_ATTR_INITVAL]    = { .type = NLA_U32 },
                [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
                [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
                [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
index 2655501f9fe38b6d8142cf89c2a8e6df0bbc5d93..467c59a83c0abc5e6740dc617a1d906fdae3eb41 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/netfilter/ipset/ip_set_hash.h>
 
 #define IPSET_TYPE_REV_MIN     0
-#define IPSET_TYPE_REV_MAX     1       /* bucketsize support  */
+#define IPSET_TYPE_REV_MAX     1       /* bucketsize, initval support  */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Tomasz Chilinski <tomasz.chilinski@chilan.com>");
@@ -273,6 +273,7 @@ static struct ip_set_type hash_ipmac_type __read_mostly = {
        .create_policy  = {
                [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
                [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
+               [IPSET_ATTR_INITVAL]    = { .type = NLA_U32 },
                [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
                [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
                [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
index c379a170b0c12fd5dbf0016732e0d6888d53a30d..1757bf84f155a95b7bca8679304712b0c2665ac0 100644 (file)
@@ -24,7 +24,7 @@
 #define IPSET_TYPE_REV_MIN     0
 /*                             1          Forceadd support */
 /*                             2          skbinfo support */
-#define IPSET_TYPE_REV_MAX     3       /* bucketsize support  */
+#define IPSET_TYPE_REV_MAX     3       /* bucketsize, initval support  */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Vytas Dauksa <vytas.dauksa@smoothwall.net>");
@@ -283,6 +283,7 @@ static struct ip_set_type hash_ipmark_type __read_mostly = {
                [IPSET_ATTR_MARKMASK]   = { .type = NLA_U32 },
                [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
                [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
+               [IPSET_ATTR_INITVAL]    = { .type = NLA_U32 },
                [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
                [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
                [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
index 237804f1957acad209f270e0c7cbe615159a84ee..b22f2809425a9aff19618a20168eafbf95ceb009 100644 (file)
@@ -27,7 +27,7 @@
 /*                             3    Comments support added */
 /*                             4    Forceadd support added */
 /*                             5    skbinfo support added */
-#define IPSET_TYPE_REV_MAX     6 /* bucketsize support added */
+#define IPSET_TYPE_REV_MAX     6 /* bucketsize, initval support added */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@netfilter.org>");
@@ -348,6 +348,7 @@ static struct ip_set_type hash_ipport_type __read_mostly = {
        .create_policy  = {
                [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
                [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
+               [IPSET_ATTR_INITVAL]    = { .type = NLA_U32 },
                [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
                [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
                [IPSET_ATTR_PROTO]      = { .type = NLA_U8 },
index 1caf698f608707124c3295174b2f8ae01930261a..d3701519b7ea0c8aeda49302f6e530c8ea7637ab 100644 (file)
@@ -27,7 +27,7 @@
 /*                             3    Comments support added */
 /*                             4    Forceadd support added */
 /*                             5    skbinfo support added */
-#define IPSET_TYPE_REV_MAX     6 /* bucketsize support added */
+#define IPSET_TYPE_REV_MAX     6 /* bucketsize, initval support added */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@netfilter.org>");
@@ -363,6 +363,7 @@ static struct ip_set_type hash_ipportip_type __read_mostly = {
        .create_policy  = {
                [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
                [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
+               [IPSET_ATTR_INITVAL]    = { .type = NLA_U32 },
                [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
                [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
                [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
index 03facf0cef9a422d7866ce82a225b32e7505687e..64f82f296a0b565b89e48a84b9b5b3b0476dd940 100644 (file)
@@ -29,7 +29,7 @@
 /*                             5    Comments support added */
 /*                             6    Forceadd support added */
 /*                             7    skbinfo support added */
-#define IPSET_TYPE_REV_MAX     8 /* bucketsize support added */
+#define IPSET_TYPE_REV_MAX     8 /* bucketsize, initval support added */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@netfilter.org>");
@@ -520,6 +520,7 @@ static struct ip_set_type hash_ipportnet_type __read_mostly = {
        .create_policy  = {
                [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
                [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
+               [IPSET_ATTR_INITVAL]    = { .type = NLA_U32 },
                [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
                [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
                [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
index 153ea36f3f05704b93a520e260c1808b2d361a61..014bb71bebc9c873ef0c5e417ecb8f92dc9e13a1 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/netfilter/ipset/ip_set_hash.h>
 
 #define IPSET_TYPE_REV_MIN     0
-#define IPSET_TYPE_REV_MAX     1       /* bucketsize support */
+#define IPSET_TYPE_REV_MAX     1       /* bucketsize, initval support */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@netfilter.org>");
@@ -131,6 +131,7 @@ static struct ip_set_type hash_mac_type __read_mostly = {
        .create_policy  = {
                [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
                [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
+               [IPSET_ATTR_INITVAL]    = { .type = NLA_U32 },
                [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
                [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
                [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
index cc0034551621bc28736e648dcc4902d05d0ac626..54318dd96913d7b1b18377de80ceaecb9a602d7b 100644 (file)
@@ -26,7 +26,7 @@
 /*                             4    Comments support added */
 /*                             5    Forceadd support added */
 /*                             6    skbinfo support added */
-#define IPSET_TYPE_REV_MAX     7 /* bucketsize support added */
+#define IPSET_TYPE_REV_MAX     7 /* bucketsize, initval support added */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@netfilter.org>");
@@ -361,6 +361,7 @@ static struct ip_set_type hash_net_type __read_mostly = {
        .create_policy  = {
                [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
                [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
+               [IPSET_ATTR_INITVAL]    = { .type = NLA_U32 },
                [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
                [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
                [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
index 682e99f6556f1f36f78c9d69b215d53d637d86ab..d17e6148ead9dcf34d4523cd3e41f008c49c82a0 100644 (file)
@@ -28,7 +28,7 @@
 /*                             5    Forceadd support added */
 /*                             6    skbinfo support added */
 /*                             7    interface wildcard support added */
-#define IPSET_TYPE_REV_MAX     8 /* bucketsize support added */
+#define IPSET_TYPE_REV_MAX     8 /* bucketsize, initval support added */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@netfilter.org>");
@@ -477,6 +477,7 @@ static struct ip_set_type hash_netiface_type __read_mostly = {
        .create_policy  = {
                [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
                [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
+               [IPSET_ATTR_INITVAL]    = { .type = NLA_U32 },
                [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
                [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
                [IPSET_ATTR_PROTO]      = { .type = NLA_U8 },
index 0cc7970f36e91521c908a2987ab519ed9d4680c3..6532f0505e66f8cab2f0f43f38a390354334899d 100644 (file)
@@ -23,7 +23,7 @@
 #define IPSET_TYPE_REV_MIN     0
 /*                             1          Forceadd support added */
 /*                             2          skbinfo support added */
-#define IPSET_TYPE_REV_MAX     3       /* bucketsize support added */
+#define IPSET_TYPE_REV_MAX     3       /* bucketsize, initval support added */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>");
@@ -465,6 +465,7 @@ static struct ip_set_type hash_netnet_type __read_mostly = {
        .create_policy  = {
                [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
                [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
+               [IPSET_ATTR_INITVAL]    = { .type = NLA_U32 },
                [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
                [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
                [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
index 21b9d7314b57d627ba5d20502fbc781729769f6a..2b0a1ebcbf01ed1ee67ec17116c7b3fceccdcb7f 100644 (file)
@@ -28,7 +28,7 @@
 /*                             5    Comments support added */
 /*                             6    Forceadd support added */
 /*                             7    skbinfo support added */
-#define IPSET_TYPE_REV_MAX     8 /* bucketsize support added */
+#define IPSET_TYPE_REV_MAX     8 /* bucketsize, initval support added */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@netfilter.org>");
@@ -467,6 +467,7 @@ static struct ip_set_type hash_netport_type __read_mostly = {
        .create_policy  = {
                [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
                [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
+               [IPSET_ATTR_INITVAL]    = { .type = NLA_U32 },
                [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
                [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
                [IPSET_ATTR_PROTO]      = { .type = NLA_U8 },
index fef77bb45ca83c91c054902bbfedb4823f147336..070736d433bd846c6146446c88020cd227e35c08 100644 (file)
@@ -25,7 +25,7 @@
 /*                             0    Comments support added */
 /*                             1    Forceadd support added */
 /*                             2    skbinfo support added */
-#define IPSET_TYPE_REV_MAX     3 /* bucketsize support added */
+#define IPSET_TYPE_REV_MAX     3 /* bucketsize, initval support added */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>");
@@ -565,6 +565,7 @@ static struct ip_set_type hash_netportnet_type __read_mostly = {
        .create_policy  = {
                [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
                [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
+               [IPSET_ATTR_INITVAL]    = { .type = NLA_U32 },
                [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
                [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
                [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
index ab1022e200047294cd36dd90f611b57f41aebb13..bab3b13f064e17070660e4bbb775e188d4aa6bb7 100644 (file)
@@ -292,6 +292,14 @@ static const struct ipset_arg ipset_args[] = {
                .print = ipset_print_number,
                .help = "[bucketsize VALUE]",
        },
+       [IPSET_ARG_INITVAL] = {
+               .name = { "initval", NULL },
+               .has_arg = IPSET_MANDATORY_ARG,
+               .opt = IPSET_OPT_INITVAL,
+               .parse = ipset_parse_uint32,
+               .print = ipset_print_hexnumber,
+               .help = "[initval VALUE]",
+       },
 };
 
 const struct ipset_arg *
index 43b6f711465de05e33ad4780f935034cbe0d39fc..77201787589b0fac861fdc315e28baa060424c27 100644 (file)
@@ -56,7 +56,7 @@ struct ipset_data {
                        uint32_t hashsize;
                        uint32_t maxelem;
                        uint32_t markmask;
-                       uint32_t gc;
+                       uint32_t initval;
                        uint32_t size;
                        /* Filled out by kernel */
                        uint32_t references;
@@ -286,8 +286,8 @@ ipset_data_set(struct ipset_data *data, enum ipset_opt opt, const void *value)
                data->index = *(const uint16_t *) value;
                break;
        /* Create-specific options */
-       case IPSET_OPT_GC:
-               data->create.gc = *(const uint32_t *) value;
+       case IPSET_OPT_INITVAL:
+               data->create.initval = *(const uint32_t *) value;
                break;
        case IPSET_OPT_HASHSIZE:
                data->create.hashsize = *(const uint32_t *) value;
@@ -498,8 +498,8 @@ ipset_data_get(const struct ipset_data *data, enum ipset_opt opt)
        case IPSET_OPT_INDEX:
                return &data->index;
        /* Create-specific options */
-       case IPSET_OPT_GC:
-               return &data->create.gc;
+       case IPSET_OPT_INITVAL:
+               return &data->create.initval;
        case IPSET_OPT_HASHSIZE:
                return &data->create.hashsize;
        case IPSET_OPT_MAXELEM:
@@ -608,7 +608,7 @@ ipset_data_sizeof(enum ipset_opt opt, uint8_t family)
        case IPSET_OPT_NAMEREF:
                return IPSET_MAXNAMELEN;
        case IPSET_OPT_TIMEOUT:
-       case IPSET_OPT_GC:
+       case IPSET_OPT_INITVAL:
        case IPSET_OPT_HASHSIZE:
        case IPSET_OPT_MAXELEM:
        case IPSET_OPT_MARKMASK:
index 89073b8deebda64352fbc321e40facfc4ed3a7b1..bf57a415eafe586944ae2f1e9acc4e097e1b8eae 100644 (file)
@@ -35,7 +35,7 @@ static const struct ipset_attrname createattr2name[] = {
        [IPSET_ATTR_PROTO]      = { .name = "PROTO" },
        [IPSET_ATTR_CADT_FLAGS] = { .name = "CADT_FLAGS" },
        [IPSET_ATTR_CADT_LINENO] = { .name = "CADT_LINENO" },
-       [IPSET_ATTR_GC]         = { .name = "GC" },
+       [IPSET_ATTR_INITVAL]    = { .name = "INITVAL" },
        [IPSET_ATTR_HASHSIZE]   = { .name = "HASHSIZE" },
        [IPSET_ATTR_MAXELEM]    = { .name = "MAXELEM" },
        [IPSET_ATTR_MARKMASK]   = { .name = "MARKMASK" },
index 470a807588ea6cecaeda36a9c20c43e1f2dc20fa..ea857009fb2e9c63a1eb163f78f07d19603c122e 100644 (file)
@@ -423,6 +423,7 @@ static struct ipset_type ipset_hash_ip5 = {
                                IPSET_ARG_FORCEADD,
                                IPSET_ARG_SKBINFO,
                                IPSET_ARG_BUCKETSIZE,
+                               IPSET_ARG_INITVAL,
                                /* Ignored options: backward compatibilty */
                                IPSET_ARG_PROBES,
                                IPSET_ARG_RESIZE,
@@ -473,7 +474,7 @@ static struct ipset_type ipset_hash_ip5 = {
                 "      CIDR is a valid IPv4 or IPv6 CIDR prefix.\n"
                 "      Adding/deleting multiple elements in IP/CIDR or FROM-TO form\n"
                 "      is supported for IPv4.",
-       .description = "bucketsize support",
+       .description = "bucketsize, initval support",
 };
 
 void _init(void);
index e491e645b24f7a63ab93af145838c8fa2af53f80..c15897b93dd510ae2bb17a17fbe15f3df3b146c8 100644 (file)
@@ -125,6 +125,7 @@ static struct ipset_type ipset_hash_ipmac1 = {
                                IPSET_ARG_FORCEADD,
                                IPSET_ARG_SKBINFO,
                                IPSET_ARG_BUCKETSIZE,
+                               IPSET_ARG_INITVAL,
                        },
                        .need = 0,
                        .full = 0,
@@ -171,7 +172,7 @@ static struct ipset_type ipset_hash_ipmac1 = {
        .usage = "where depending on the INET family\n"
                 "      IP is a valid IPv4 or IPv6 address (or hostname),\n"
                 "      MAC is a MAC address.",
-       .description = "bucketsize support",
+       .description = "bucketsize, initval support",
 };
 
 void _init(void);
index 941ce5d128cf1ea41ca54d371f894331733bef39..7d6d977e33ddbe7ee0c9286cb0ee930d0176fdda 100644 (file)
@@ -324,6 +324,7 @@ static struct ipset_type ipset_hash_ipmark3 = {
                                IPSET_ARG_FORCEADD,
                                IPSET_ARG_SKBINFO,
                                IPSET_ARG_BUCKETSIZE,
+                               IPSET_ARG_INITVAL,
                                /* Ignored options: backward compatibilty */
                                IPSET_ARG_PROBES,
                                IPSET_ARG_RESIZE,
@@ -383,7 +384,7 @@ static struct ipset_type ipset_hash_ipmark3 = {
                 "      is supported for IPv4.\n"
                 "      Adding/deleting single mark element\n"
                 "      is supported both for IPv4 and IPv6.",
-       .description = "bucketsize support",
+       .description = "bucketsize, initval support",
 };
 
 void _init(void);
index cb8832e6f70483c8edc95d9c12047448d7bec436..288be10f653a692fc67130a3403543e32bfcf29f 100644 (file)
@@ -533,6 +533,7 @@ static struct ipset_type ipset_hash_ipport6 = {
                                IPSET_ARG_FORCEADD,
                                IPSET_ARG_SKBINFO,
                                IPSET_ARG_BUCKETSIZE,
+                               IPSET_ARG_INITVAL,
                                /* Ignored options: backward compatibilty */
                                IPSET_ARG_PROBES,
                                IPSET_ARG_RESIZE,
@@ -600,7 +601,7 @@ static struct ipset_type ipset_hash_ipport6 = {
                 "      Adding/deleting multiple elements with TCP/SCTP/UDP/UDPLITE\n"
                 "      port range is supported both for IPv4 and IPv6.",
        .usagefn = ipset_port_usage,
-       .description = "bucketsize support",
+       .description = "bucketsize, initval support",
 };
 
 void _init(void);
index bc23c2184931835f87b963d7e6ab307354140970..6b2e92e0f5bb4ddcf40f979fbe2854222347fd29 100644 (file)
@@ -593,6 +593,7 @@ static struct ipset_type ipset_hash_ipportip6 = {
                                IPSET_ARG_FORCEADD,
                                IPSET_ARG_SKBINFO,
                                IPSET_ARG_BUCKETSIZE,
+                               IPSET_ARG_INITVAL,
                                /* Ignored options: backward compatibilty */
                                IPSET_ARG_PROBES,
                                IPSET_ARG_RESIZE,
@@ -666,7 +667,7 @@ static struct ipset_type ipset_hash_ipportip6 = {
                 "      Adding/deleting multiple elements with TCP/SCTP/UDP/UDPLITE\n"
                 "      port range is supported both for IPv4 and IPv6.",
        .usagefn = ipset_port_usage,
-       .description = "bucketsize support",
+       .description = "bucketsize, initval support",
 };
 
 void _init(void);
index b2b46517aba1b5a5730c13e40126a18fe114ce4d..2552cdbb0c0502ca07d72790ee88f3f9225da8d1 100644 (file)
@@ -851,6 +851,7 @@ static struct ipset_type ipset_hash_ipportnet8 = {
                                IPSET_ARG_FORCEADD,
                                IPSET_ARG_SKBINFO,
                                IPSET_ARG_BUCKETSIZE,
+                               IPSET_ARG_INITVAL,
                                /* Ignored options: backward compatibilty */
                                IPSET_ARG_PROBES,
                                IPSET_ARG_RESIZE,
@@ -932,7 +933,7 @@ static struct ipset_type ipset_hash_ipportnet8 = {
                 "      Adding/deleting multiple elements with TCP/SCTP/UDP/UDPLITE\n"
                 "      port range is supported both for IPv4 and IPv6.",
        .usagefn = ipset_port_usage,
-       .description = "bucketsize support",
+       .description = "bucketsize, initval support",
 };
 
 void _init(void);
index b1e799122dab09a3d2c3247414d59abe7731bfe7..4b20247d73b81cffc9185f35cf0fd5953a169c5a 100644 (file)
@@ -100,6 +100,7 @@ static struct ipset_type ipset_hash_mac1 = {
                                IPSET_ARG_FORCEADD,
                                IPSET_ARG_SKBINFO,
                                IPSET_ARG_BUCKETSIZE,
+                               IPSET_ARG_INITVAL,
                                IPSET_ARG_NONE,
                        },
                        .need = 0,
@@ -139,7 +140,7 @@ static struct ipset_type ipset_hash_mac1 = {
                },
        },
        .usage = "",
-       .description = "bucketsize support",
+       .description = "bucketsize, initval support",
 };
 
 void _init(void);
index a943ea690a0e1ab068ef91f97ecec821d7f0be78..1da95bf89d8ddbd2194730c35aaad3f3a483ddc1 100644 (file)
@@ -560,6 +560,7 @@ static struct ipset_type ipset_hash_net7 = {
                                IPSET_ARG_FORCEADD,
                                IPSET_ARG_SKBINFO,
                                IPSET_ARG_BUCKETSIZE,
+                               IPSET_ARG_INITVAL,
                                /* Ignored options: backward compatibilty */
                                IPSET_ARG_PROBES,
                                IPSET_ARG_RESIZE,
@@ -611,7 +612,7 @@ static struct ipset_type ipset_hash_net7 = {
        .usage = "where depending on the INET family\n"
                 "      IP is an IPv4 or IPv6 address (or hostname),\n"
                 "      CIDR is a valid IPv4 or IPv6 CIDR prefix.",
-       .description = "bucketsize support",
+       .description = "bucketsize, initval support",
 };
 
 void _init(void);
index 7a720c65d413f8210742728630a0e2fbf219b7cf..172c2a98cc28d3bad87893d838a7b8a2a3797408 100644 (file)
@@ -749,6 +749,7 @@ static struct ipset_type ipset_hash_netiface8 = {
                                IPSET_ARG_FORCEADD,
                                IPSET_ARG_SKBINFO,
                                IPSET_ARG_BUCKETSIZE,
+                               IPSET_ARG_INITVAL,
                                IPSET_ARG_NONE,
                        },
                        .need = 0,
@@ -808,7 +809,7 @@ static struct ipset_type ipset_hash_netiface8 = {
                 "      IP is a valid IPv4 or IPv6 address (or hostname),\n"
                 "      CIDR is a valid IPv4 or IPv6 CIDR prefix.\n"
                 "      Adding/deleting multiple elements with IPv4 is supported.",
-       .description = "bucketsize support",
+       .description = "bucketsize, initval support",
 };
 
 void _init(void);
index e1da9ec8942ba73d6f122bffac9bc753ca3a0783..df993b88cbb3f013982995498ab7312425272ab4 100644 (file)
@@ -323,6 +323,7 @@ static struct ipset_type ipset_hash_netnet3 = {
                                IPSET_ARG_FORCEADD,
                                IPSET_ARG_SKBINFO,
                                IPSET_ARG_BUCKETSIZE,
+                               IPSET_ARG_INITVAL,
                                IPSET_ARG_NONE,
                        },
                        .need = 0,
@@ -383,7 +384,7 @@ static struct ipset_type ipset_hash_netnet3 = {
                 "      IP is an IPv4 or IPv6 address (or hostname),\n"
                 "      CIDR is a valid IPv4 or IPv6 CIDR prefix.\n"
                 "      IP range is not supported with IPv6.",
-       .description = "bucketsize support",
+       .description = "bucketsize, initval support",
 };
 
 void _init(void);
index 2d08085778720c783e4805eb3cab01c7bfd403e9..f09de833ea70d42967491122c6181840f98fba49 100644 (file)
@@ -699,6 +699,7 @@ static struct ipset_type ipset_hash_netport8 = {
                                IPSET_ARG_FORCEADD,
                                IPSET_ARG_SKBINFO,
                                IPSET_ARG_BUCKETSIZE,
+                               IPSET_ARG_INITVAL,
                                IPSET_ARG_NONE,
                        },
                        .need = 0,
@@ -764,7 +765,7 @@ static struct ipset_type ipset_hash_netport8 = {
                 "      Adding/deleting multiple elements with TCP/SCTP/UDP/UDPLITE\n"
                 "      port range is supported both for IPv4 and IPv6.",
        .usagefn = ipset_port_usage,
-       .description = "bucketsize support",
+       .description = "bucketsize, initval support",
 };
 
 void _init(void);
index e456fb1ea99e183222dd311a3b5fc14c8d215800..a4a7240fbeed076a0dc305cc3f194c86cdb768a6 100644 (file)
@@ -397,6 +397,7 @@ static struct ipset_type ipset_hash_netportnet3 = {
                                IPSET_ARG_FORCEADD,
                                IPSET_ARG_SKBINFO,
                                IPSET_ARG_BUCKETSIZE,
+                               IPSET_ARG_INITVAL,
                                IPSET_ARG_NONE,
                        },
                        .need = 0,
@@ -475,7 +476,7 @@ static struct ipset_type ipset_hash_netportnet3 = {
                 "      Adding/deleting multiple elements with TCP/SCTP/UDP/UDPLITE\n"
                 "      port range is supported both for IPv4 and IPv6.",
        .usagefn = ipset_port_usage,
-       .description = "bucketsize support",
+       .description = "bucketsize, initval support",
 };
 
 void _init(void);
index 7a4a33c83a6c49c4b2d14cc1892d18650c8939d8..12d16a4faf53c1c0affc3cb24972f8fd54c0f1df 100644 (file)
@@ -202,3 +202,9 @@ global:
   ipset_session_report_msg;
   ipset_session_report_type;
 } LIBIPSET_4.8;
+
+LIBIPSET_4.10 {
+global:
+  ipset_print_hexnumber;
+} LIBIPSET_4.9;
+
index d1d5a20c3747cde02392d1f6ac8110894797101e..0d86a98b36b9479608130f17fcaa9dcce5034436 100644 (file)
@@ -396,6 +396,50 @@ ipset_print_number(char *buf, unsigned int len,
        return 0;
 }
 
+/**
+ * ipset_print_hexnumber - print number in hex to string
+ * @buf: printing buffer
+ * @len: length of available buffer space
+ * @data: data blob
+ * @opt: the option kind
+ * @env: environment flags
+ *
+ * Print number in hex to output buffer.
+ *
+ * Return lenght of printed string or error size.
+ */
+int
+ipset_print_hexnumber(char *buf, unsigned int len,
+                     const struct ipset_data *data, enum ipset_opt opt,
+                     uint8_t env UNUSED)
+{
+       size_t maxsize;
+       const void *number;
+
+       assert(buf);
+       assert(len > 0);
+       assert(data);
+
+       number = ipset_data_get(data, opt);
+       maxsize = ipset_data_sizeof(opt, AF_INET);
+       D("opt: %u, maxsize %zu", opt, maxsize);
+       if (maxsize == sizeof(uint8_t))
+               return snprintf(buf, len, "0x%02"PRIx8,
+                               *(const uint8_t *) number);
+       else if (maxsize == sizeof(uint16_t))
+               return snprintf(buf, len, "0x%04"PRIx16,
+                               *(const uint16_t *) number);
+       else if (maxsize == sizeof(uint32_t))
+               return snprintf(buf, len, "0x%08"PRIx32,
+                               (long unsigned) *(const uint32_t *) number);
+       else if (maxsize == sizeof(uint64_t))
+               return snprintf(buf, len, "0x016lx",
+                               (long long unsigned) *(const uint64_t *) number);
+       else
+               assert(0);
+       return 0;
+}
+
 /**
  * ipset_print_name - print setname element string
  * @buf: printing buffer
@@ -940,7 +984,7 @@ ipset_print_data(char *buf, unsigned int len,
        case IPSET_OPT_IFACE:
                size = ipset_print_iface(buf, len, data, opt, env);
                break;
-       case IPSET_OPT_GC:
+       case IPSET_OPT_INITVAL:
        case IPSET_OPT_HASHSIZE:
        case IPSET_OPT_MAXELEM:
        case IPSET_OPT_MARKMASK:
index 8416308f3e09c3b96202705e9df082939c9c3e32..b088bc82888ac94d5285dacaa9ad4be0bbec5ddc 100644 (file)
@@ -418,9 +418,9 @@ static const struct ipset_attr_policy create_attrs[] = {
                .type = MNL_TYPE_U32,
                .opt = IPSET_OPT_CADT_FLAGS,
        },
-       [IPSET_ATTR_GC] = {
+       [IPSET_ATTR_INITVAL] = {
                .type = MNL_TYPE_U32,
-               .opt = IPSET_OPT_GC,
+               .opt = IPSET_OPT_INITVAL,
        },
        [IPSET_ATTR_HASHSIZE] = {
                .type = MNL_TYPE_U32,