Re: [PATCH nft] fix integer type size to be used as a key for sets and maps
On Fri, Mar 02, 2018 at 06:58:44PM +0100, Phil Sutter wrote: > Hi Laura, > > On Fri, Mar 02, 2018 at 05:34:02PM +0100, Laura Garcia Liebana wrote: > [...] > > diff --git a/src/datatype.c b/src/datatype.c > > index 324ac80..06015bb 100644 > > --- a/src/datatype.c > > +++ b/src/datatype.c > > @@ -356,6 +356,7 @@ const struct datatype integer_type = { > > .type = TYPE_INTEGER, > > .name = "integer", > > .desc = "integer", > > + .size = 4 * BITS_PER_BYTE, > > .print = integer_type_print, > > .parse = integer_type_parse, > > }; > > I'm not sure this is going to work: integer_type is used as basetype for > many others, and there is at least lladdr_type which doesn't define a > size on it's own (and is larger than four bytes). Are you sure this > won't cause unexpected side-effects (like, e.g. lookups in sets > containing lladdr_type entries returning false-positives)? It seems that this issue requires a more elaborated fix. I'll check it out. Thanks Phil. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH nft] fix integer type size to be used as a key for sets and maps
Hi Laura, On Fri, Mar 02, 2018 at 05:34:02PM +0100, Laura Garcia Liebana wrote: [...] > diff --git a/src/datatype.c b/src/datatype.c > index 324ac80..06015bb 100644 > --- a/src/datatype.c > +++ b/src/datatype.c > @@ -356,6 +356,7 @@ const struct datatype integer_type = { > .type = TYPE_INTEGER, > .name = "integer", > .desc = "integer", > + .size = 4 * BITS_PER_BYTE, > .print = integer_type_print, > .parse = integer_type_parse, > }; I'm not sure this is going to work: integer_type is used as basetype for many others, and there is at least lladdr_type which doesn't define a size on it's own (and is larger than four bytes). Are you sure this won't cause unexpected side-effects (like, e.g. lookups in sets containing lladdr_type entries returning false-positives)? Cheers, Phil -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH nft] fix integer type size to be used as a key for sets and maps
Includes the size of the type integer in order to be used as a key in a map or set. Without this patch we obtain the following error: Error: unqualified key type integer specified in map definition add map nftlb mapa { type integer : ipv4_addr; timeout 5s; } ^^^ After this patch, we can use an integer as a key for sets and maps: table ip nftlb { map mapa { type integer : ipv4_addr } set conjunto { type integer } } Signed-off-by: Laura Garcia Liebana --- src/datatype.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/datatype.c b/src/datatype.c index 324ac80..06015bb 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -356,6 +356,7 @@ const struct datatype integer_type = { .type = TYPE_INTEGER, .name = "integer", .desc = "integer", + .size = 4 * BITS_PER_BYTE, .print = integer_type_print, .parse = integer_type_parse, }; -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html