All of lore.kernel.org
 help / color / mirror / Atom feed
* [libnftables PATCH 0/3] small fixes
@ 2013-06-04  8:05 Eric Leblond
  2013-06-04  8:05 ` [libnftables PATCH 1/3] examples: delete payload code in nft-chain-add Eric Leblond
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Eric Leblond @ 2013-06-04  8:05 UTC (permalink / raw)
  To: netfilter-devel


Hi,

Here's three small patches which fix some issue with the examples
provided in the code.

BR,
--
Eric

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [libnftables PATCH 1/3] examples: delete payload code in nft-chain-add
  2013-06-04  8:05 [libnftables PATCH 0/3] small fixes Eric Leblond
@ 2013-06-04  8:05 ` Eric Leblond
  2013-06-05  3:52   ` Pablo Neira Ayuso
  2013-06-04  8:05 ` [libnftables PATCH 2/3] nft-events: add newline to output Eric Leblond
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Eric Leblond @ 2013-06-04  8:05 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Eric Leblond

'make check' was not working due to the fact that
'libnftables/payload.h' was not present. As the payload
related code was commented, the "I've got an axe" solution
was to remove all payload related code. This is done in this
patch.

Signed-off-by: Eric Leblond <eric@regit.org>
---
 examples/nft-rule-add.c |   25 -------------------------
 1 file changed, 25 deletions(-)

diff --git a/examples/nft-rule-add.c b/examples/nft-rule-add.c
index b906715..c2b8968 100644
--- a/examples/nft-rule-add.c
+++ b/examples/nft-rule-add.c
@@ -21,7 +21,6 @@
 #include <libmnl/libmnl.h>
 #include <libnftables/rule.h>
 #include <libnftables/expr.h>
-#include <libnftables/payload.h>
 
 #include <linux/netfilter_ipv4/ipt_LOG.h>
 #include <linux/netfilter/xt_iprange.h>
@@ -93,29 +92,6 @@ static void add_expr_match(struct nft_rule *r)
 
 #define field_sizeof(t, f)	(sizeof(((t *)NULL)->f))
 
-static void add_payload2(struct nft_rule_expr *e)
-{
-	nft_rule_expr_set_u32(e, NFT_EXPR_PAYLOAD_BASE,
-			      NFT_PAYLOAD_NETWORK_HEADER);
-	nft_rule_expr_set_u32(e, NFT_EXPR_PAYLOAD_DREG, NFT_REG_1);
-	nft_rule_expr_set_u32(e, NFT_EXPR_PAYLOAD_OFFSET,
-			      offsetof(struct iphdr, protocol));
-	nft_rule_expr_set_u32(e, NFT_EXPR_PAYLOAD_LEN, 1);
-}
-
-static void add_payload(struct nft_rule *r)
-{
-	struct nft_rule_expr *expr;
-
-	expr = nft_rule_expr_alloc("payload");
-	if (expr == NULL)
-		return;
-
-	add_payload2(expr);
-
-	nft_rule_add_expr(r, expr);
-}
-
 int main(int argc, char *argv[])
 {
 	struct mnl_socket *nl;
@@ -153,7 +129,6 @@ int main(int argc, char *argv[])
 
 	add_expr_match(r);
 	add_expr_target(r);
-//	add_payload(r);
 
 	char tmp[1024];
 	nft_rule_snprintf(tmp, sizeof(tmp), r, 0, 0);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [libnftables PATCH 2/3] nft-events: add newline to output
  2013-06-04  8:05 [libnftables PATCH 0/3] small fixes Eric Leblond
  2013-06-04  8:05 ` [libnftables PATCH 1/3] examples: delete payload code in nft-chain-add Eric Leblond
@ 2013-06-04  8:05 ` Eric Leblond
  2013-06-05  3:52   ` Pablo Neira Ayuso
  2013-06-04  8:05 ` [libnftables PATCH 3/3] expr: fix display of dreg expression Eric Leblond
  2013-06-04  8:16 ` [libnftables PATCH 0/3] small fixes Arturo Borrero Gonzalez
  3 siblings, 1 reply; 8+ messages in thread
From: Eric Leblond @ 2013-06-04  8:05 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Eric Leblond

This patch adds a new line to messages to be sure that they are
printed to the shell as soon as they occur. This also fixes the
display of output.

Signed-off-by: Eric Leblond <eric@regit.org>
---
 examples/nft-events.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/examples/nft-events.c b/examples/nft-events.c
index aa8c85e..5550c70 100644
--- a/examples/nft-events.c
+++ b/examples/nft-events.c
@@ -39,7 +39,7 @@ static int table_cb(const struct nlmsghdr *nlh, int type)
 	}
 
 	nft_table_snprintf(buf, sizeof(buf), t, NFT_TABLE_O_DEFAULT, 0);
-	printf("[%s]\t%s", type == NFT_MSG_NEWTABLE ? "NEW" : "DEL", buf);
+	printf("[%s]\t%s\n", type == NFT_MSG_NEWTABLE ? "NEW" : "DEL", buf);
 
 err_free:
 	nft_table_free(t);
@@ -64,7 +64,7 @@ static int rule_cb(const struct nlmsghdr *nlh, int type)
 	}
 
 	nft_rule_snprintf(buf, sizeof(buf), t, NFT_RULE_O_DEFAULT, 0);
-	printf("[%s]\t%s", type == NFT_MSG_NEWRULE ? "NEW" : "DEL", buf);
+	printf("[%s]\t%s\n", type == NFT_MSG_NEWRULE ? "NEW" : "DEL", buf);
 
 err_free:
 	nft_rule_free(t);
@@ -89,7 +89,7 @@ static int chain_cb(const struct nlmsghdr *nlh, int type)
 	}
 
 	nft_chain_snprintf(buf, sizeof(buf), t, NFT_CHAIN_O_DEFAULT, 0);
-	printf("[%s]\t%s", type == NFT_MSG_NEWCHAIN ? "NEW" : "DEL", buf);
+	printf("[%s]\t%s\n", type == NFT_MSG_NEWCHAIN ? "NEW" : "DEL", buf);
 
 err_free:
 	nft_chain_free(t);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [libnftables PATCH 3/3] expr: fix display of dreg expression
  2013-06-04  8:05 [libnftables PATCH 0/3] small fixes Eric Leblond
  2013-06-04  8:05 ` [libnftables PATCH 1/3] examples: delete payload code in nft-chain-add Eric Leblond
  2013-06-04  8:05 ` [libnftables PATCH 2/3] nft-events: add newline to output Eric Leblond
@ 2013-06-04  8:05 ` Eric Leblond
  2013-06-05  3:53   ` Pablo Neira Ayuso
  2013-06-04  8:16 ` [libnftables PATCH 0/3] small fixes Arturo Borrero Gonzalez
  3 siblings, 1 reply; 8+ messages in thread
From: Eric Leblond @ 2013-06-04  8:05 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Eric Leblond


Signed-off-by: Eric Leblond <eric@regit.org>
---
 src/expr/immediate.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/expr/immediate.c b/src/expr/immediate.c
index 7cfb4bf..295054d 100644
--- a/src/expr/immediate.c
+++ b/src/expr/immediate.c
@@ -335,7 +335,7 @@ nft_rule_expr_immediate_snprintf_default(char *buf, size_t len,
 	int size = len, offset = 0, ret;
 	struct nft_expr_immediate *imm = (struct nft_expr_immediate *)e->data;
 
-	ret = snprintf(buf, len, "dreg=%u", imm->dreg);
+	ret = snprintf(buf, len, "dreg=%u ", imm->dreg);
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
 	if (e->flags & (1 << NFT_EXPR_IMM_DATA)) {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [libnftables PATCH 0/3] small fixes
  2013-06-04  8:05 [libnftables PATCH 0/3] small fixes Eric Leblond
                   ` (2 preceding siblings ...)
  2013-06-04  8:05 ` [libnftables PATCH 3/3] expr: fix display of dreg expression Eric Leblond
@ 2013-06-04  8:16 ` Arturo Borrero Gonzalez
  3 siblings, 0 replies; 8+ messages in thread
From: Arturo Borrero Gonzalez @ 2013-06-04  8:16 UTC (permalink / raw)
  To: Eric Leblond; +Cc: Netfilter Development Mailing list

2013/6/4 Eric Leblond <eric@regit.org>:
>
> Hi,
>
> Here's three small patches which fix some issue with the examples
> provided in the code.
>

Hi Eric,

I also saw that issues. Thanks.

Regards.
--
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [libnftables PATCH 1/3] examples: delete payload code in nft-chain-add
  2013-06-04  8:05 ` [libnftables PATCH 1/3] examples: delete payload code in nft-chain-add Eric Leblond
@ 2013-06-05  3:52   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 8+ messages in thread
From: Pablo Neira Ayuso @ 2013-06-05  3:52 UTC (permalink / raw)
  To: Eric Leblond; +Cc: netfilter-devel

On Tue, Jun 04, 2013 at 10:05:21AM +0200, Eric Leblond wrote:
> 'make check' was not working due to the fact that
> 'libnftables/payload.h' was not present.

Oops, that file was dead lying on my filesystem, applied a fix for
this.

> As the payload related code was commented, the "I've got an axe"
> solution was to remove all payload related code. This is done in
> this patch.

I prefered to keep the payload example, so apply a different fix.
Thanks for the spots anyway.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [libnftables PATCH 2/3] nft-events: add newline to output
  2013-06-04  8:05 ` [libnftables PATCH 2/3] nft-events: add newline to output Eric Leblond
@ 2013-06-05  3:52   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 8+ messages in thread
From: Pablo Neira Ayuso @ 2013-06-05  3:52 UTC (permalink / raw)
  To: Eric Leblond; +Cc: netfilter-devel

On Tue, Jun 04, 2013 at 10:05:22AM +0200, Eric Leblond wrote:
> This patch adds a new line to messages to be sure that they are
> printed to the shell as soon as they occur. This also fixes the
> display of output.

Applied, thanks Eric.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [libnftables PATCH 3/3] expr: fix display of dreg expression
  2013-06-04  8:05 ` [libnftables PATCH 3/3] expr: fix display of dreg expression Eric Leblond
@ 2013-06-05  3:53   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 8+ messages in thread
From: Pablo Neira Ayuso @ 2013-06-05  3:53 UTC (permalink / raw)
  To: Eric Leblond; +Cc: netfilter-devel

Also applied, thanks Eric.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-06-05  3:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-04  8:05 [libnftables PATCH 0/3] small fixes Eric Leblond
2013-06-04  8:05 ` [libnftables PATCH 1/3] examples: delete payload code in nft-chain-add Eric Leblond
2013-06-05  3:52   ` Pablo Neira Ayuso
2013-06-04  8:05 ` [libnftables PATCH 2/3] nft-events: add newline to output Eric Leblond
2013-06-05  3:52   ` Pablo Neira Ayuso
2013-06-04  8:05 ` [libnftables PATCH 3/3] expr: fix display of dreg expression Eric Leblond
2013-06-05  3:53   ` Pablo Neira Ayuso
2013-06-04  8:16 ` [libnftables PATCH 0/3] small fixes Arturo Borrero Gonzalez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.