netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ana Rey <anarey@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: Ana Rey <anarey@gmail.com>
Subject: [PATCH v2] nftables: Fix list of sets by family
Date: Fri, 28 Mar 2014 12:40:31 +0100	[thread overview]
Message-ID: <008e38aa5e97439e7ac8a9e178689c2d666fa554.1396006133.git.anarey@gmail.com> (raw)

Fix the result of command line 'nft list sets FAMILY'. It shows the
following error message:

"Error: syntax error, unexpected end of file, expecting string"

Now, it is possible shows right this information:

$ sudo nft -nna list sets ip
	set set_test {
		type ipv4_address
		elements = { 192.168.3.45, 192.168.3.43, 192.168.3.42, 192.168.3.4}
	}
	set set_test2 {
		type ipv4_address
		elements = { 192.168.3.43, 192.168.3.42, 192.168.3.4}
	}
	set set0 {
		type ipv4_address
		flags constant
		elements = { 127.0.0.12, 12.11.11.11}
	}

Signed-off-by: Ana Rey <anarey@gmail.com>
---
[Changes in v2]
* Delete all references regarding the indentation in the code.
* Delete all references regarding the indentation in the descriptions.
These changes were spotted by Patrick McHardy.

 src/parser.y | 2 +-
 src/rule.c   | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/parser.y b/src/parser.y
index db6f493..af34857 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -719,7 +719,7 @@ list_cmd		:	TABLE		table_spec
 			{
 				$$ = cmd_alloc(CMD_LIST, CMD_OBJ_CHAIN, &$2, &@$, NULL);
 			}
-			|	SETS		table_spec
+			|	SETS		tables_spec
 			{
 				$$ = cmd_alloc(CMD_LIST, CMD_OBJ_SETS, &$2, &@$, NULL);
 			}
diff --git a/src/rule.c b/src/rule.c
index b719040..00dedf5 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -668,8 +668,12 @@ static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd)
 	case CMD_OBJ_SETS:
 		if (netlink_list_sets(ctx, &cmd->handle, &cmd->location) < 0)
 			return -1;
-		list_for_each_entry_safe(set, nset, &ctx->list, list)
-			list_move_tail(&set->list, &table->sets);
+		list_for_each_entry(set, &ctx->list, list){
+			if (netlink_get_setelems(ctx, &set->handle,
+						 &cmd->location, set) < 0)
+				return -1;
+			set_print(set);
+		}
 		break;
 	case CMD_OBJ_SET:
 		if (netlink_get_set(ctx, &cmd->handle, &cmd->location) < 0)
-- 
1.9.0


             reply	other threads:[~2014-03-28 11:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-28 11:40 Ana Rey [this message]
2014-03-28 12:31 ` [PATCH v2] nftables: Fix list of sets by family Patrick McHardy

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=008e38aa5e97439e7ac8a9e178689c2d666fa554.1396006133.git.anarey@gmail.com \
    --to=anarey@gmail.com \
    --cc=netfilter-devel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).