netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iptables: extensions: libxt_MARK: Add translation for revision 1 to nft
@ 2016-06-21 20:08 rodanber
  2016-06-22  9:47 ` Arturo Borrero Gonzalez
  2016-06-22 17:51 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 3+ messages in thread
From: rodanber @ 2016-06-21 20:08 UTC (permalink / raw)
  To: arturo.borrero.glez; +Cc: pablo, netfilter-devel, Roberto García

From: Roberto García <rodanber@gmail.com>

Add translation for revision 1 of the MARK target to nft.

Examples:

  # iptables-translate -t mangle -A PREROUTING -j MARK --set-mark 0x64
  nft add rule ip mangle PREROUTING counter meta mark set 0x64

  # iptables-translate -t mangle -A PREROUTING -j MARK --and-mark 0x64
  nft add rule ip mangle PREROUTING counter meta mark set mark and 0x64

  # iptables-translate -t mangle -A PREROUTING -j MARK --or-mark 0x64
  nft add rule ip mangle PREROUTING counter meta mark set mark or 0x64

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

diff --git a/extensions/libxt_MARK.c b/extensions/libxt_MARK.c
index ec1ed05..2aaf29c 100644
--- a/extensions/libxt_MARK.c
+++ b/extensions/libxt_MARK.c
@@ -267,6 +267,29 @@ static int mark_tg_xlate(const void *ip, const struct xt_entry_target *target,
 	return 1;
 }
 
+static int MARK_xlate(const void *ip, const struct xt_entry_target *target,
+			 struct xt_xlate *xl, int numeric)
+{
+	const struct xt_mark_target_info_v1 *markinfo =
+		(const struct xt_mark_target_info_v1 *)target->data;
+
+	xt_xlate_add(xl, "meta mark set ");
+
+	switch(markinfo->mode) {
+	case XT_MARK_SET:
+		xt_xlate_add(xl, "0x%x ", markinfo->mark);
+		break;
+	case XT_MARK_AND:
+		xt_xlate_add(xl, "mark and 0x%x ", markinfo->mark);
+		break;
+	case XT_MARK_OR: 
+		xt_xlate_add(xl, "mark or 0x%x ", markinfo->mark);
+		break;
+	}
+	
+	return 1;
+}
+
 static struct xtables_target mark_tg_reg[] = {
 	{
 		.family        = NFPROTO_UNSPEC,
@@ -295,6 +318,7 @@ static struct xtables_target mark_tg_reg[] = {
 		.x6_parse      = MARK_parse_v1,
 		.x6_fcheck     = MARK_check,
 		.x6_options    = MARK_opts,
+		.xlate	       = MARK_xlate,
 	},
 	{
 		.version       = XTABLES_VERSION,
-- 
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] 3+ messages in thread

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-21 20:08 [PATCH] iptables: extensions: libxt_MARK: Add translation for revision 1 to nft rodanber
2016-06-22  9:47 ` Arturo Borrero Gonzalez
2016-06-22 17:51 ` 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).