All of lore.kernel.org
 help / color / mirror / Atom feed
From: Elise Lennion <elise.lennion@gmail.com>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH nft] statement: Print NAT IPv4 address in nat_stmt_print()
Date: Fri, 3 Feb 2017 16:50:38 -0200	[thread overview]
Message-ID: <20170203185038.GA6536@lennorien.com> (raw)

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@gmail.com>
---
 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


             reply	other threads:[~2017-02-03 18:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-03 18:50 Elise Lennion [this message]
2017-02-05 20:46 ` [PATCH nft] statement: Print NAT IPv4 address in nat_stmt_print() Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170203185038.GA6536@lennorien.com \
    --to=elise.lennion@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.