Skip to contentSkip to conversation

extensions: libxt_mark: fix a wrong translation to nft when mask is specified

PATCH Applied Liping Zhang 2 participants 2 messages Jun 1, 2016 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 extensions: libxt_mark: fix a wrong translation to nft when mask is specified

From: Liping Zhang <[email protected]>

The mask and mark's order is reversed, so when we specify the mask, we will get the wrong translation result:

  # iptables-translate -A INPUT -m mark --mark 0x1/0xff
  nft add rule ip filter INPUT mark and 0x1 == 0xff counter

Apply this patch, translation will become:

  # iptables-translate -A INPUT -m mark --mark 0x1/0xff
  nft add rule ip filter INPUT mark and 0xff == 0x1 counter
Cc Shivani Bhardwaj <[email protected]>
---
 extensions/libxt_mark.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
extensions/libxt_mark.c +2 -2
index 939b4ac..6eccd5b 100644
@@ -107,8 +107,8 @@ print_mark_xlate(struct xt_xlate *xl, unsigned int mark,
 		 unsigned int mask, uint32_t op)
 {
 	if (mask != 0xffffffffU)
-		xt_xlate_add(xl, " and 0x%x %s 0x%x ", mark,
-			   op == XT_OP_EQ ? "==" : "!=", mask);
+		xt_xlate_add(xl, " and 0x%x %s 0x%x ", mask,
+			   op == XT_OP_EQ ? "==" : "!=", mark);
 	else
 		xt_xlate_add(xl, " %s0x%x ",
 			   op == XT_OP_EQ ? "" : "!= ", mark);
Signature · 1 line
2.5.5
maintainer Applied
#1 lore raw
Quoted 10 lines · Liping Zhang

From: Liping Zhang <[email protected]>

The mask and mark's order is reversed, so when we specify the mask, we will get the wrong translation result:

  # iptables-translate -A INPUT -m mark --mark 0x1/0xff
  nft add rule ip filter INPUT mark and 0x1 == 0xff counter

Apply this patch, translation will become:

  # iptables-translate -A INPUT -m mark --mark 0x1/0xff
  nft add rule ip filter INPUT mark and 0xff == 0x1 counter

Applied, thanks.