Re: [PATCH 2/2 libnfntl] Fix nftnl_*_get to set data_len

2016-07-11 Thread Pablo Neira Ayuso
On Mon, Jul 11, 2016 at 12:24:27PM +0200, Pablo Neira Ayuso wrote:
> Carlos,
> 
> Habla con Laura para ver cómo lleva este cambio en la reunión:
> 
> http://patchwork.ozlabs.org/patch/639253/
> 
> Si ella no anda con tiempo, creo que tú tienes los conocimientos para
> hacer este cambio que describo ahí.
> 
> No lo olvides. Gracias.

Sorry, I accidentally sent this email to the mailing list in Spanish.
--
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 2/2 libnfntl] Fix nftnl_*_get to set data_len

2016-07-11 Thread Pablo Neira Ayuso
Carlos,

Habla con Laura para ver cómo lleva este cambio en la reunión:

http://patchwork.ozlabs.org/patch/639253/

Si ella no anda con tiempo, creo que tú tienes los conocimientos para
hacer este cambio que describo ahí.

No lo olvides. Gracias.
--
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 2/2 libnfntl] Fix nftnl_*_get to set data_len

2016-07-06 Thread Pablo Neira Ayuso
On Tue, Jul 05, 2016 at 07:15:17PM +0200, Carlos Falgueras García wrote:
> All getters must set the output parameter 'data_len'

Then, send me a v2 that also replaces strlen(x) + 1 to strlen(x)
from getters.

I can see several spots in src/expr/ that return strlen(x) + 1.  So we
leave this in consistent state in one go.

Thanks.
--
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 2/2 libnfntl] Fix nftnl_*_get to set data_len

2016-07-05 Thread Carlos Falgueras García
All getters must set the output parameter 'data_len'

Signed-off-by: Carlos Falgueras García 
---
 src/chain.c   | 3 +++
 src/expr.c| 1 +
 src/expr/dynset.c | 3 +++
 src/expr/lookup.c | 3 +++
 src/gen.c | 1 +
 src/rule.c| 2 ++
 src/set.c | 2 ++
 src/set_elem.c| 6 ++
 src/table.c   | 1 +
 9 files changed, 22 insertions(+)

diff --git a/src/chain.c b/src/chain.c
index cab64b5..ccf0f92 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -272,8 +272,10 @@ const void *nftnl_chain_get_data(const struct nftnl_chain 
*c, uint16_t attr,
 
switch(attr) {
case NFTNL_CHAIN_NAME:
+   *data_len = strlen(c->name);
return c->name;
case NFTNL_CHAIN_TABLE:
+   *data_len = strlen(c->table);
return c->table;
case NFTNL_CHAIN_HOOKNUM:
*data_len = sizeof(uint32_t);
@@ -303,6 +305,7 @@ const void *nftnl_chain_get_data(const struct nftnl_chain 
*c, uint16_t attr,
*data_len = sizeof(uint32_t);
return c->type;
case NFTNL_CHAIN_DEV:
+   *data_len = strlen(c->dev);
return c->dev;
}
return NULL;
diff --git a/src/expr.c b/src/expr.c
index f802725..06afcd3 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -119,6 +119,7 @@ const void *nftnl_expr_get(const struct nftnl_expr *expr,
 
switch(type) {
case NFTNL_EXPR_NAME:
+   *data_len = strlen(expr->ops->name);
ret = expr->ops->name;
break;
default:
diff --git a/src/expr/dynset.c b/src/expr/dynset.c
index 0404359..6bf360e 100644
--- a/src/expr/dynset.c
+++ b/src/expr/dynset.c
@@ -88,10 +88,13 @@ nftnl_expr_dynset_get(const struct nftnl_expr *e, uint16_t 
type,
*data_len = sizeof(dynset->timeout);
return >timeout;
case NFTNL_EXPR_DYNSET_SET_NAME:
+   *data_len = strlen(dynset->set_name);
return dynset->set_name;
case NFTNL_EXPR_DYNSET_SET_ID:
+   *data_len = sizeof(dynset->set_id);
return >set_id;
case NFTNL_EXPR_DYNSET_EXPR:
+   *data_len = 0;
return dynset->expr;
}
return NULL;
diff --git a/src/expr/lookup.c b/src/expr/lookup.c
index 7f68f74..54d19d6 100644
--- a/src/expr/lookup.c
+++ b/src/expr/lookup.c
@@ -73,10 +73,13 @@ nftnl_expr_lookup_get(const struct nftnl_expr *e, uint16_t 
type,
*data_len = sizeof(lookup->dreg);
return >dreg;
case NFTNL_EXPR_LOOKUP_SET:
+   *data_len = strlen(lookup->set_name);
return lookup->set_name;
case NFTNL_EXPR_LOOKUP_SET_ID:
+   *data_len = sizeof(lookup->set_id);
return >set_id;
case NFTNL_EXPR_LOOKUP_FLAGS:
+   *data_len = sizeof(lookup->flags);
return >flags;
}
return NULL;
diff --git a/src/gen.c b/src/gen.c
index 37a9049..c69d2f8 100644
--- a/src/gen.c
+++ b/src/gen.c
@@ -100,6 +100,7 @@ const void *nftnl_gen_get_data(const struct nftnl_gen *gen, 
uint16_t attr,
 
switch(attr) {
case NFTNL_GEN_ID:
+   *data_len = sizeof(gen->id);
return >id;
}
return NULL;
diff --git a/src/rule.c b/src/rule.c
index 2b23c8e..bf72595 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -213,8 +213,10 @@ const void *nftnl_rule_get_data(const struct nftnl_rule 
*r, uint16_t attr,
*data_len = sizeof(uint32_t);
return >family;
case NFTNL_RULE_TABLE:
+   *data_len = strlen(r->table);
return r->table;
case NFTNL_RULE_CHAIN:
+   *data_len = strlen(r->chain);
return r->chain;
case NFTNL_RULE_HANDLE:
*data_len = sizeof(uint64_t);
diff --git a/src/set.c b/src/set.c
index e48ff78..f728373 100644
--- a/src/set.c
+++ b/src/set.c
@@ -215,8 +215,10 @@ const void *nftnl_set_get_data(const struct nftnl_set *s, 
uint16_t attr,
 
switch(attr) {
case NFTNL_SET_TABLE:
+   *data_len = strlen(s->table);
return s->table;
case NFTNL_SET_NAME:
+   *data_len = strlen(s->name);
return s->name;
case NFTNL_SET_FLAGS:
*data_len = sizeof(uint32_t);
diff --git a/src/set_elem.c b/src/set_elem.c
index 40b5bfe..2056209 100644
--- a/src/set_elem.c
+++ b/src/set_elem.c
@@ -160,25 +160,31 @@ const void *nftnl_set_elem_get(struct nftnl_set_elem *s, 
uint16_t attr, uint32_t
 
switch(attr) {
case NFTNL_SET_ELEM_FLAGS:
+   *data_len = sizeof(s->set_elem_flags);
return >set_elem_flags;
case NFTNL_SET_ELEM_KEY:/* NFTA_SET_ELEM_KEY */
*data_len = s->key.len;
return >key.val;
case NFTNL_SET_ELEM_VERDICT:/*