Skip to contentSkip to conversation

iptables: extensions: libxt_MARK: Add translation for revision 1 to nft

PATCH Applied [email protected] 3 participants 3 messages Jun 21, 2016 – Jun 22, 2016 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iptables: extensions: libxt_MARK: Add translation for revision 1 to nft

From: Roberto García <[email protected]>

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
---
 extensions/libxt_MARK.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
extensions/libxt_MARK.c +24 -0
index ec1ed05..2aaf29c 100644
@@ -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,
Signature · 6 lines
2.8.0

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · On 21 June 2016 at 22:08, <[email protected]> wrote:

From: Roberto García <[email protected]>

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
Quoted 8 lines
  # iptables-translate -t mangle -A PREROUTING -j MARK --or-mark 0x64
  nft add rule ip mangle PREROUTING counter meta mark set mark or 0x64
---
 extensions/libxt_MARK.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Seems good to me.

Signature · 5 lines
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer Applied
#2 lore raw
In reply to [email protected]
Quoted 6 lines · On Tue, Jun 21, 2016 at 10:08:24PM +0200, [email protected] wrote:

From: Roberto García <[email protected]>

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

Examples:

Quoted 8 lines
  # 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

Applied, thanks.

Roberto, please make sure your editor highlights trailing whitespace and unnecessary indentations. This is usually very easy to enable.

This time I have fixed this here, but you make it easier for me if you already deal with this.

Note that otherwise I get this warnings:

Applying: iptables: extensions: libxt_MARK: Add translation for revision 1 to nft patch:28: trailing whitespace.
case XT_MARK_OR:
patch:32: trailing whitespace.

warning: 2 lines add whitespace errors.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html