All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] iptables: extensions: libxt_MARK: Add translation to nft
@ 2016-06-08 22:24 Roberto García
  2016-06-14 16:59 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Roberto García @ 2016-06-08 22:24 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Arturo Borrero Gonzalez, Pablo Neira Ayuso

Add translation for the MARK target to nftables.

Examples:

$ sudo iptables-translate -t mangle -A OUTPUT -j MARK --set-mark 64

nft add rule ip mangle OUTPUT counter meta mark set 0x40

$ sudo iptables-translate -t mangle -A OUTPUT -j MARK --set-xmark 0x40/0x32

nft add rule ip mangle OUTPUT counter meta mark set mark xor 0x40 and 0x32

$ sudo iptables-translate -t mangle -A OUTPUT -j MARK --or-mark 64

nft add rule ip mangle OUTPUT counter meta mark set mark or 0x40

$ sudo iptables-translate -t mangle -A OUTPUT -j MARK --and-mark 64

nft add rule ip mangle OUTPUT counter meta mark set mark and 0x40

$ sudo iptables-translate -t mangle -A OUTPUT -j MARK --xor-mark 64

nft add rule ip mangle OUTPUT counter meta mark set mark xor 0x40

Signed-off-by: Roberto García <rodanber@gmail.com>
---
  extensions/libxt_MARK.c | 23 +++++++++++++++++++++++
  1 file changed, 23 insertions(+)

diff --git a/extensions/libxt_MARK.c b/extensions/libxt_MARK.c
index 556dbde..ec1ed05 100644
--- a/extensions/libxt_MARK.c
+++ b/extensions/libxt_MARK.c
@@ -245,6 +245,28 @@ static void mark_tg_save(const void *ip, const 
struct xt_entry_target *target)
  	printf(" --set-xmark 0x%x/0x%x", info->mark, info->mask);
  }
  +static int mark_tg_xlate(const void *ip, const struct xt_entry_target 
*target,
+			 struct xt_xlate *xl, int numeric)
+{
+	const struct xt_mark_tginfo2 *info = (const void *)target->data;
+
+	xt_xlate_add(xl, "meta mark set ");
+
+	if (info->mark == 0)
+		xt_xlate_add(xl, "mark and 0x%x ", ~info->mask);
+	else if (info->mark == info->mask)
+		xt_xlate_add(xl, "mark or 0x%x ", info->mark);
+	else if (info->mask == 0)
+		xt_xlate_add(xl, "mark xor 0x%x ", info->mark);
+	else if (info->mask == 0xffffffffU)
+		xt_xlate_add(xl, "0x%x ", info->mark);
+	else
+		xt_xlate_add(xl, "mark xor 0x%x and 0x%x ", info->mark,
+			     info->mask);
+
+	return 1;
+}
+
  static struct xtables_target mark_tg_reg[] = {
  	{
  		.family        = NFPROTO_UNSPEC,
@@ -287,6 +309,7 @@ static struct xtables_target mark_tg_reg[] = {
  		.x6_parse      = mark_tg_parse,
  		.x6_fcheck     = mark_tg_check,
  		.x6_options    = mark_tg_opts,
+		.xlate	       = mark_tg_xlate,
  	},
  };
  -- 2.8.0

--
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 related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] iptables: extensions: libxt_MARK: Add translation to nft
  2016-06-08 22:24 [PATCH v2] iptables: extensions: libxt_MARK: Add translation to nft Roberto García
@ 2016-06-14 16:59 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2016-06-14 16:59 UTC (permalink / raw)
  To: Roberto García; +Cc: netfilter-devel, Arturo Borrero Gonzalez

On Thu, Jun 09, 2016 at 12:24:53AM +0200, Roberto García wrote:
> diff --git a/extensions/libxt_MARK.c b/extensions/libxt_MARK.c
> index 556dbde..ec1ed05 100644
> --- a/extensions/libxt_MARK.c
> +++ b/extensions/libxt_MARK.c
> @@ -245,6 +245,28 @@ static void mark_tg_save(const void *ip,
> const struct xt_entry_target *target)
>  	printf(" --set-xmark 0x%x/0x%x", info->mark, info->mask);
>  }
>  +static int mark_tg_xlate(const void *ip, const struct
> xt_entry_target *target,
> +			 struct xt_xlate *xl, int numeric)

git am says this patch has been mangled by you MUA :(. Please resend.
Thanks.
--
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] 2+ messages in thread

end of thread, other threads:[~2016-06-14 17:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-08 22:24 [PATCH v2] iptables: extensions: libxt_MARK: Add translation to nft Roberto García
2016-06-14 16:59 ` Pablo Neira Ayuso

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.