From: Pablo Neira Ayuso <pablo@netfilter.org>
To: "Álvaro Neira Ayuso" <alvaroneay@gmail.com>
Cc: netfilter-devel@vger.kernel.org, kaber@trash.net
Subject: Re: [nft PATCH v3 2/2] src: add import command
Date: Tue, 10 Mar 2015 19:57:08 +0100 [thread overview]
Message-ID: <20150310185708.GA6322@salvia> (raw)
In-Reply-To: <54FF35AA.3030104@gmail.com>
On Tue, Mar 10, 2015 at 07:19:22PM +0100, Álvaro Neira Ayuso wrote:
> El 10/03/15 a las 11:21, Pablo Neira Ayuso escribió:
> >On Tue, Mar 10, 2015 at 11:04:18AM +0100, Alvaro Neira Ayuso wrote:
> >>diff --git a/src/rule.c b/src/rule.c
> >>index 8d76fd0..8c58a2b 100644
> >>--- a/src/rule.c
> >>+++ b/src/rule.c
> >>@@ -20,6 +20,7 @@
> >> #include <rule.h>
> >> #include <utils.h>
> >> #include <netlink.h>
> >>+#include <mnl.h>
> >>
> >> #include <libnftnl/common.h>
> >> #include <libnftnl/ruleset.h>
> >>@@ -555,6 +556,21 @@ void export_free(struct export *e)
> >> xfree(e);
> >> }
> >>
> >>+struct import *import_alloc(uint32_t format)
> >>+{
> >>+ struct import *import;
> >>+
> >>+ import = xmalloc(sizeof(struct import));
> >>+ import->format = format;
> >>+
> >>+ return import;
> >>+}
> >>+
> >>+void import_free(struct import *i)
> >>+{
> >>+ xfree(i);
> >>+}
> >>+
> >> struct monitor *monitor_alloc(uint32_t format, uint32_t type, const char *event)
> >> {
> >> struct monitor *mon;
> >>@@ -599,6 +615,9 @@ void cmd_free(struct cmd *cmd)
> >> case CMD_OBJ_MONITOR:
> >> monitor_free(cmd->monitor);
> >> break;
> >>+ case CMD_OBJ_IMPORT:
> >>+ import_free(cmd->import);
> >>+ break;
> >> case CMD_OBJ_EXPORT:
> >> export_free(cmd->export);
> >> break;
> >>@@ -1006,6 +1025,322 @@ static int do_command_describe(struct netlink_ctx *ctx, struct cmd *cmd)
> >> return 0;
> >> }
> >>
> >>+struct ruleset_parse {
> >>+ struct netlink_ctx *nl_ctx;
> >>+ struct cmd *cmd;
> >>+};
> >>+
> >>+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;
> >>+ }
> >>+
> >>+ if (ret < 0)
> >>+ netlink_io_error(rp->nl_ctx, &rp->cmd->location,
> >>+ "Could not import set_elems: %s",
> >>+ strerror(errno));
> >
> >I think rp->cmd->location is unset, so this will crash. Could you
> >validate this by forcing an error to make sure it works?
>
> It's not unset. If we have an error, the location is in the import
> command. For example:
>
> Error: Could not import set_elems: Invalid argument
> import json
> ^^^^^^^^^^^
Good, thanks.
BTW, please don't use developer jargon in the error messages, you
better say "Could not import set elements" instead of "set_elems".
--
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
next prev parent reply other threads:[~2015-03-10 18:53 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 [this message]
2015-03-10 10:37 ` Patrick McHardy
2015-03-10 18:13 ` Álvaro 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=20150310185708.GA6322@salvia \
--to=pablo@netfilter.org \
--cc=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).