[PATCH nft] statement: Print NAT IPv4 address in nat_stmt_print()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The case which "nat.addr != NULL && nat.proto != NULL && type != ipv6"
wasn't caught in nat_stmt_print(). Now all cases should be considered.

Also, the if statements were reorganized to get rid of one nested if.

Fixes(Bug 1117 - Table ipv4-nat prerouting dnat doesn't accept dest IP:PORT)

Signed-off-by: Elise Lennion <elise.lennion@xxxxxxxxx>
---
 src/statement.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/statement.c b/src/statement.c
index 9cdabbb..0585d66 100644
--- a/src/statement.c
+++ b/src/statement.c
@@ -494,25 +494,26 @@ static void nat_stmt_print(const struct stmt *stmt)
 	};
 
 	printf("%s to ", nat_types[stmt->nat.type]);
-	if (stmt->nat.addr) {
-		if (stmt->nat.proto) {
-			if (stmt->nat.addr->ops->type == EXPR_VALUE &&
-			    stmt->nat.addr->dtype->type == TYPE_IP6ADDR) {
-				printf("[");
-				expr_print(stmt->nat.addr);
-				printf("]");
-			} else if (stmt->nat.addr->ops->type == EXPR_RANGE &&
-				   stmt->nat.addr->left->dtype->type == TYPE_IP6ADDR) {
-				printf("[");
-				expr_print(stmt->nat.addr->left);
-				printf("]-[");
-				expr_print(stmt->nat.addr->right);
-				printf("]");
-			}
+	if (stmt->nat.addr && stmt->nat.proto) {
+		if (stmt->nat.addr->ops->type == EXPR_RANGE &&
+		    stmt->nat.addr->left->dtype->type == TYPE_IP6ADDR) {
+			printf("[");
+			expr_print(stmt->nat.addr->left);
+			printf("]-[");
+			expr_print(stmt->nat.addr->right);
+			printf("]");
+		}
+		else if (stmt->nat.addr->dtype->type == TYPE_IP6ADDR) {
+			printf("[");
+			expr_print(stmt->nat.addr);
+			printf("]");
 		} else {
 			expr_print(stmt->nat.addr);
 		}
 	}
+	else if (stmt->nat.addr) {
+		expr_print(stmt->nat.addr);
+	}
 
 	if (stmt->nat.proto) {
 		printf(":");
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux