netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] src: netlink_linearize: Fix bug for redirect target
@ 2016-01-28 19:35 Shivani Bhardwaj
  2016-02-01 14:09 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Shivani Bhardwaj @ 2016-01-28 19:35 UTC (permalink / raw)
  To: netfilter-devel

Before this patch,
$ sudo nft --debug=netlink add rule ip nat post ip protocol tcp redirect to 100-200
ip nat post
  [ payload load 1b @ network header + 9 => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ immediate reg 1 0x00006400 ]
  [ immediate reg 2 0x0000c800 ]
  [ redir proto_min reg 1 proto_max reg 5 ]

<cmdline>:1:1-56: Error: Could not process rule: Invalid argument
add rule ip nat post ip protocol tcp redirect to 100-200
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

After this patch,
$ sudo nft --debug=netlink add rule ip nat post ip protocol tcp redirect to 100-200
ip nat post
  [ payload load 1b @ network header + 9 => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ immediate reg 1 0x00006400 ]
  [ immediate reg 2 0x0000c800 ]
  [ redir proto_min reg 1 proto_max reg 2 ]

Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
 src/netlink_linearize.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c
index 7c6ef16..dfe8dca 100644
--- a/src/netlink_linearize.c
+++ b/src/netlink_linearize.c
@@ -861,17 +861,17 @@ static void netlink_gen_redir_stmt(struct netlink_linearize_ctx *ctx,
 					 pmin_reg);
 			netlink_gen_expr(ctx, stmt->redir.proto->right,
 					 pmax_reg);
-			nftnl_expr_set_u32(nle,
-					      NFTNL_EXPR_REDIR_REG_PROTO_MIN,
-					      pmin_reg);
-			nftnl_expr_set_u32(nle,
-					      NFTNL_EXPR_REDIR_REG_PROTO_MAX,
-					      pmax_reg);
+			netlink_put_register(nle,
+					     NFTNL_EXPR_REDIR_REG_PROTO_MIN,
+					     pmin_reg);
+			netlink_put_register(nle,
+					     NFTNL_EXPR_REDIR_REG_PROTO_MAX,
+					     pmax_reg);
 		} else {
 			netlink_gen_expr(ctx, stmt->redir.proto, pmin_reg);
-			nftnl_expr_set_u32(nle,
-					      NFTNL_EXPR_REDIR_REG_PROTO_MIN,
-					      pmin_reg);
+			netlink_put_register(nle,
+					     NFTNL_EXPR_REDIR_REG_PROTO_MIN,
+					     pmin_reg);
 		}
 	}
 
-- 
1.9.1


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

* Re: [PATCH] src: netlink_linearize: Fix bug for redirect target
  2016-01-28 19:35 [PATCH] src: netlink_linearize: Fix bug for redirect target Shivani Bhardwaj
@ 2016-02-01 14:09 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2016-02-01 14:09 UTC (permalink / raw)
  To: Shivani Bhardwaj; +Cc: netfilter-devel

On Fri, Jan 29, 2016 at 01:05:37AM +0530, Shivani Bhardwaj wrote:
> Before this patch,
> $ sudo nft --debug=netlink add rule ip nat post ip protocol tcp redirect to 100-200
> ip nat post
>   [ payload load 1b @ network header + 9 => reg 1 ]
>   [ cmp eq reg 1 0x00000006 ]
>   [ immediate reg 1 0x00006400 ]
>   [ immediate reg 2 0x0000c800 ]
>   [ redir proto_min reg 1 proto_max reg 5 ]
> 
> <cmdline>:1:1-56: Error: Could not process rule: Invalid argument
> add rule ip nat post ip protocol tcp redirect to 100-200
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> After this patch,
> $ sudo nft --debug=netlink add rule ip nat post ip protocol tcp redirect to 100-200
> ip nat post
>   [ payload load 1b @ network header + 9 => reg 1 ]
>   [ cmp eq reg 1 0x00000006 ]
>   [ immediate reg 1 0x00006400 ]
>   [ immediate reg 2 0x0000c800 ]
>   [ redir proto_min reg 1 proto_max reg 2 ]

Shivani, this is a very good catch. Applied, thanks!


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

end of thread, other threads:[~2016-02-01 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-28 19:35 [PATCH] src: netlink_linearize: Fix bug for redirect target Shivani Bhardwaj
2016-02-01 14:09 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).