Skip to contentSkip to conversation

ebtables-compat: fix print_header

PATCH Applied Giuseppe Longo 2 participants 7 messages Oct 16, 2014 – Oct 20, 2014 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ebtables-compat: fix print_header

This prints the header like ebtables.

---
 iptables/nft-bridge.c | 3 +--
 iptables/nft.c        | 7 +++++--
 2 files changed, 6 insertions(+), 4 deletions(-)
iptables/nft-bridge.c +1 -2
index ab97881..1fe10ed 100644
@@ -362,8 +362,7 @@ static void nft_bridge_print_header(unsigned int format, const char *chain,
 				    const struct xt_counters *counters,
 				    bool basechain, uint32_t refs)
 {
-	/* FIXME: Giuseppe replace this with ebtables format */
-	print_header(format, chain, pol, counters, basechain, refs);
+	printf("Bridge chain: %s, entries: %u, policy: %s\n", chain, refs, pol);
 }
 
 static void nft_bridge_print_firewall(struct nft_rule *r, unsigned int num,
iptables/nft.c +5 -2
index bab2834..0cdf027 100644
@@ -2006,6 +2006,9 @@ int nft_rule_list(struct nft_handle *h, const char *chain, const char *table,
 	if (iter == NULL)
 		goto err;
 
+	if (h->family == NFPROTO_BRIDGE)
+		printf("Bridge table: %s\n\n", table);
+
 	c = nft_chain_list_iter_next(iter);
 	while (c != NULL) {
 		const char *chain_table =
@@ -2033,8 +2036,8 @@ int nft_rule_list(struct nft_handle *h, const char *chain, const char *table,
 		if (found)
 			printf("\n");
 
-		ops->print_header(format, chain_name, policy_name[policy],
-				  &ctrs, basechain, refs);
+		ops->print_header(format, chain_name,
+				  policy_name[policy], &ctrs, basechain, refs);
 
 		__nft_rule_list(h, chain_name, table,
 				rulenum, format, ops->print_firewall);
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/3 nft: fix syntax error

This fixes a syntax error, remove ; in an if statement

---
 iptables/nft-shared.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
iptables/nft-shared.c +1 -1
index 2b87092..d6f838c 100644
@@ -444,7 +444,7 @@ void nft_parse_cmp(struct nft_xt_ctx *ctx, struct nft_rule_expr *e)
 	if (ctx->flags & NFT_XT_CTX_META)
 		ops->parse_meta(ctx, e, data);
 	/* bitwise context is interpreted from payload */
-	if (ctx->flags & NFT_XT_CTX_PAYLOAD);
+	if (ctx->flags & NFT_XT_CTX_PAYLOAD)
 		ops->parse_payload(ctx, e, data);
 }
 
Signature · 1 line
1.9.1
maintainer Applied
#2 lore raw

Re: [iptables-compat PATCH 2/3] nft: fix syntax error

Quoted 1 line · Giuseppe Longo

This fixes a syntax error, remove ; in an if statement

Applied to master, thanks.

#3 lore raw

PATCH 3/3 nft-ipv46: replace offset var with ctx->payload.offset

In reply to Giuseppe Longo

The offset variable (undefined) is passed to DEBUGP function, so you get a compilation error if you try to build iptables with debug enabled

---
 iptables/nft-ipv4.c | 2 +-
 iptables/nft-ipv6.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
iptables/nft-ipv4.c +1 -1
index eedcb50..a2c5806 100644
@@ -205,7 +205,7 @@ static void nft_ipv4_parse_payload(struct nft_xt_ctx *ctx,
 			cs->fw.ip.invflags |= IPT_INV_FRAG;
 		break;
 	default:
-		DEBUGP("unknown payload offset %d\n", offset);
+		DEBUGP("unknown payload offset %d\n", ctx->payload.offset);
 		break;
 	}
 }
iptables/nft-ipv6.c +1 -1
index 2e50627..5489398 100644
@@ -142,7 +142,7 @@ static void nft_ipv6_parse_payload(struct nft_xt_ctx *ctx,
 		if (inv)
 			cs->fw6.ipv6.invflags |= IPT_INV_PROTO;
 	default:
-		DEBUGP("unknown payload offset %d\n", offset);
+		DEBUGP("unknown payload offset %d\n", ctx->payload.offset);
 		break;
 	}
 }
Signature · 1 line
1.9.1
maintainer Applied
#4 lore raw

Re: [iptables-compat PATCH 3/3] nft-ipv46: replace offset var with ctx->payload.offset

Quoted 3 lines · Giuseppe Longo

The offset variable (undefined) is passed to DEBUGP function, so you get a compilation error if you try to build iptables with debug enabled

Applied to master, thanks.

I have rebased the ebtables-compat branch again upon these fixes.