Skip to contentSkip to conversation

xtables-translate: Support setting standard chain policy

PATCH In review Phil Sutter 2 participants 2 messages Nov 25, 2016 – Nov 29, 2016 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 xtables-translate: Support setting standard chain policy

Looks like this bit was simply forgotten when implementing xlate_chain_set() as everything needed was there to just print the desired policy along with the chain definition.

---
 iptables/xtables-translate.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
iptables/xtables-translate.c +11 -5
index 689533f3d4d85..0c706dcc2b9db 100644
@@ -354,16 +354,22 @@ static int xlate_chain_set(struct nft_handle *h, const char *table,
 {
 	printf("add chain %s %s %s ", family2str[h->family], table, chain);
 	if (strcmp(chain, "PREROUTING") == 0)
-		printf("{ type filter hook prerouting priority 0; }\n");
+		printf("{ type filter hook prerouting priority 0; ");
 	else if (strcmp(chain, "INPUT") == 0)
-		printf("{ type filter hook input priority 0; }\n");
+		printf("{ type filter hook input priority 0; ");
 	else if (strcmp(chain, "FORWARD") == 0)
-		printf("{ type filter hook forward priority 0; }\n");
+		printf("{ type filter hook forward priority 0; ");
 	else if (strcmp(chain, "OUTPUT") == 0)
-		printf("{ type filter hook output priority 0; }\n");
+		printf("{ type filter hook output priority 0; ");
 	else if (strcmp(chain, "POSTROUTING") == 0)
-		printf("{ type filter hook postrouting priority 0; }\n");
+		printf("{ type filter hook postrouting priority 0; ");
 
+	if (strcmp(policy, "ACCEPT") == 0)
+		printf("policy accept; ");
+	else if (strcmp(policy, "DROP") == 0)
+		printf("policy drop; ");
+
+	printf("}\n");
 	return 1;
 }
 
Signature · 1 line
2.10.0
#1 lore raw
Quoted 3 lines · Phil Sutter

Looks like this bit was simply forgotten when implementing xlate_chain_set() as everything needed was there to just print the desired policy along with the chain definition.

Also applied, thanks.