netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Álvaro Neira Ayuso" <alvaroneay@gmail.com>
To: Patrick McHardy <kaber@trash.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH v3 2/2] src: add import command
Date: Tue, 10 Mar 2015 19:13:48 +0100	[thread overview]
Message-ID: <54FF345C.9040307@gmail.com> (raw)
In-Reply-To: <20150310103737.GC4538@acer.localdomain>

El 10/03/15 a las 11:37, Patrick McHardy escribió:
> On 10.03, Alvaro Neira Ayuso wrote:
>> @@ -275,6 +279,13 @@ struct export {
>>   struct export *export_alloc(uint32_t format);
>>   void export_free(struct export *e);
>>
>> +struct import {
>> +	uint32_t	format;
>> +};
>> +
>> +struct import *import_alloc(uint32_t format);
>> +void import_free(struct import *i);
>
> How about a common struct for both commands? "format", "import_export",
> ...
>

Nice idea Patrick. I'm going to do it.

>> +import_cmd		:	import_format
>
> Same here, please change export_format to something common.
>
>> +static int ruleset_parse_setelems(const struct nft_parse_ctx *ctx)
>> +{
>> +	const struct ruleset_parse *rp;
>> +	struct nft_set *set;
>> +	uint32_t cmd;
>> +	int ret = -1;
>> +
>> +	set = nft_ruleset_ctx_get(ctx, NFT_RULESET_CTX_SET);
>> +	rp = nft_ruleset_ctx_get(ctx, NFT_RULESET_CTX_DATA);
>> +
>> +	cmd = nft_ruleset_ctx_get_u32(ctx, NFT_RULESET_CTX_CMD);
>> +	switch (cmd) {
>> +	case NFT_CMD_ADD:
>> +		ret = mnl_nft_setelem_batch_add(set, 0, rp->nl_ctx->seqnum);
>> +		break;
>> +	case NFT_CMD_DELETE:
>> +		ret = mnl_nft_setelem_batch_del(set, 0, rp->nl_ctx->seqnum);
>> +		break;
>> +	default:
>> +		errno = EOPNOTSUPP;
>> +		break;
>
> This would be a BUG, no? Same question for all similar cases.

I don't think so. If the user are in another kernel that one operation 
is not supported, we will say that it's a bug and I think it's better to 
say only that the operation is not supported. Maybe my point of view is 
wrong, I'm opened to change it if you think that it's better to show a 
bug message.

>
>> +static int do_command_import(struct netlink_ctx *ctx, struct cmd *cmd)
>> +{
>> +	int ret;
>> +	struct nft_parse_err *err;
>> +	struct ruleset_parse rp = {
>> +		.nl_ctx = ctx,
>> +		.cmd = cmd
>
> Please align, makes it easier to read.

Catched.

>
>> +	ret = nft_ruleset_parse_file_cb(cmd->import->format, stdin, err, &rp,
>> +					ruleset_parse_cb);
>> +	if (ret < 0)
>> +		nft_parse_perror("unable to import. Parsing failed", err);
>
> I'd suggest a ": parsing failed", makes it clear that its only a single
> error, not two.

Perfect, I'm going to change it too.

Thanks for the review to Pablo and Patrick. I'm going to work in the 
changes.
--
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

      reply	other threads:[~2015-03-10 18:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-10 10:04 [nft PATCH v3 2/2] src: add import command Alvaro Neira Ayuso
2015-03-10 10:21 ` Pablo Neira Ayuso
2015-03-10 18:19   ` Álvaro Neira Ayuso
2015-03-10 18:57     ` Pablo Neira Ayuso
2015-03-10 10:37 ` Patrick McHardy
2015-03-10 18:13   ` Álvaro Neira Ayuso [this message]

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=54FF345C.9040307@gmail.com \
    --to=alvaroneay@gmail.com \
    --cc=kaber@trash.net \
    --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).