All of lore.kernel.org
 help / color / mirror / Atom feed
* [nftables PATCH] src: error if listing nonexistent table
@ 2013-10-10 22:21 Arturo Borrero Gonzalez
  2013-10-11  8:24 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: Arturo Borrero Gonzalez @ 2013-10-10 22:21 UTC (permalink / raw)
  To: netfilter-devel

Here examples (foo table doesn't exist).

Before this patch:

# nft list table foo
table ip foo {
}

After:

# nft list table foo
<cmdline>:1:1-14: Error: Could not receive table from kernel: No such file or directory
list table foo
^^^^^^^^^^^^^^

BTW, netlink_get_table() seemed unused.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 src/mnl.c  |    2 ++
 src/rule.c |    2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/mnl.c b/src/mnl.c
index 27b181a..4490411 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -563,6 +563,8 @@ int mnl_nft_table_get(struct mnl_socket *nf_sock, struct nft_table *nlt,
 	nlh = nft_table_nlmsg_build_hdr(buf, NFT_MSG_GETTABLE,
 					nft_table_attr_get_u32(nlt, NFT_TABLE_ATTR_FAMILY),
 					NLM_F_ACK, seq);
+	nft_table_nlmsg_build_payload(nlh, nlt);
+
 	return mnl_talk(nf_sock, nlh, nlh->nlmsg_len, table_get_cb, nlt);
 }
 
diff --git a/src/rule.c b/src/rule.c
index 39a66d7..ff1193a 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -610,6 +610,8 @@ static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd)
 			return 0;
 		}
 		/* List content of this table */
+		if (netlink_get_table(ctx, &cmd->handle, &cmd->location) < 0)
+			return -1;
 		if (do_list_sets(ctx, &cmd->location, table) < 0)
 			return -1;
 		if (netlink_list_chains(ctx, &cmd->handle, &cmd->location) < 0)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [nftables PATCH] src: error if listing nonexistent table
  2013-10-10 22:21 [nftables PATCH] src: error if listing nonexistent table Arturo Borrero Gonzalez
@ 2013-10-11  8:24 ` Pablo Neira Ayuso
  2013-10-11 12:30   ` Arturo Borrero Gonzalez
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2013-10-11  8:24 UTC (permalink / raw)
  To: Arturo Borrero Gonzalez; +Cc: netfilter-devel

Hi Arturo,

On Fri, Oct 11, 2013 at 12:21:30AM +0200, Arturo Borrero Gonzalez wrote:
> Here examples (foo table doesn't exist).
> 
> Before this patch:
> 
> # nft list table foo
> table ip foo {
> }

I cannot reproduce this here:

<cmdline>:1:1-14: Error: Could not receive sets from kernel: No such
file or directory
list table foo
^^^^^^^^^^^^^^
 
> After:
> 
> # nft list table foo
> <cmdline>:1:1-14: Error: Could not receive table from kernel: No such file or directory
> list table foo
> ^^^^^^^^^^^^^^
>
> BTW, netlink_get_table() seemed unused.

Yes, the original nftables code included it already, I guess expecting
some usage at some point.

> Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> ---
>  src/mnl.c  |    2 ++
>  src/rule.c |    2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/src/mnl.c b/src/mnl.c
> index 27b181a..4490411 100644
> --- a/src/mnl.c
> +++ b/src/mnl.c
> @@ -563,6 +563,8 @@ int mnl_nft_table_get(struct mnl_socket *nf_sock, struct nft_table *nlt,
>  	nlh = nft_table_nlmsg_build_hdr(buf, NFT_MSG_GETTABLE,
>  					nft_table_attr_get_u32(nlt, NFT_TABLE_ATTR_FAMILY),
>  					NLM_F_ACK, seq);
> +	nft_table_nlmsg_build_payload(nlh, nlt);
> +
>  	return mnl_talk(nf_sock, nlh, nlh->nlmsg_len, table_get_cb, nlt);
>  }
>  
> diff --git a/src/rule.c b/src/rule.c
> index 39a66d7..ff1193a 100644
> --- a/src/rule.c
> +++ b/src/rule.c
> @@ -610,6 +610,8 @@ static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd)
>  			return 0;
>  		}
>  		/* List content of this table */
> +		if (netlink_get_table(ctx, &cmd->handle, &cmd->location) < 0)
> +			return -1;
>  		if (do_list_sets(ctx, &cmd->location, table) < 0)
>  			return -1;
>  		if (netlink_list_chains(ctx, &cmd->handle, &cmd->location) < 0)
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [nftables PATCH] src: error if listing nonexistent table
  2013-10-11  8:24 ` Pablo Neira Ayuso
@ 2013-10-11 12:30   ` Arturo Borrero Gonzalez
  0 siblings, 0 replies; 3+ messages in thread
From: Arturo Borrero Gonzalez @ 2013-10-11 12:30 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: Netfilter Development Mailing list

On 11 October 2013 10:24, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> Hi Arturo,
>
> On Fri, Oct 11, 2013 at 12:21:30AM +0200, Arturo Borrero Gonzalez wrote:
>> Here examples (foo table doesn't exist).
>>
>> Before this patch:
>>
>> # nft list table foo
>> table ip foo {
>> }
>
> I cannot reproduce this here:

Right. I guess this only happen with the patch I sent the other day
for the kernel to dump sets with NFPROTO_UNSPEC.

I will investigate and come back.
-- 
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-11 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-10 22:21 [nftables PATCH] src: error if listing nonexistent table Arturo Borrero Gonzalez
2013-10-11  8:24 ` Pablo Neira Ayuso
2013-10-11 12:30   ` Arturo Borrero Gonzalez

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.