From: Alvaro Neira Ayuso <alvaroneay@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: [libnftnl PATCH 1/3] parser: Add operation not supported error message
Date: Mon, 16 Mar 2015 16:06:09 +0100 [thread overview]
Message-ID: <1426518371-11717-1-git-send-email-alvaroneay@gmail.com> (raw)
If we try to import a ruleset in json or xml and the operation is not
supported, we don't show any error message to this case.
This patch adds a new error path if the operation is not supported.
Moreover, this patch sets up this error by default when we create the
structure nft_parse_err.
Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
---
include/libnftnl/common.h | 1 +
src/common.c | 12 +++++++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/include/libnftnl/common.h b/include/libnftnl/common.h
index f8f1304..d92b170 100644
--- a/include/libnftnl/common.h
+++ b/include/libnftnl/common.h
@@ -7,6 +7,7 @@ enum {
NFT_PARSE_EBADINPUT = 0,
NFT_PARSE_EMISSINGNODE,
NFT_PARSE_EBADTYPE,
+ NFT_PARSE_OPNOTSUPP,
};
enum nft_output_type {
diff --git a/src/common.c b/src/common.c
index 7fce48e..fc0bc97 100644
--- a/src/common.c
+++ b/src/common.c
@@ -44,7 +44,15 @@ EXPORT_SYMBOL(nft_nlmsg_build_hdr);
struct nft_parse_err *nft_parse_err_alloc(void)
{
- return calloc(1, sizeof(struct nft_parse_err));
+ struct nft_parse_err *err;
+
+ err = calloc(1, sizeof(struct nft_parse_err));
+ if (err == NULL)
+ return NULL;
+
+ err->error = NFT_PARSE_OPNOTSUPP;
+
+ return err;
}
EXPORT_SYMBOL(nft_parse_err_alloc);
@@ -66,6 +74,8 @@ int nft_parse_perror(const char *msg, struct nft_parse_err *err)
case NFT_PARSE_EBADTYPE:
return fprintf(stderr, "%s: Invalid type in node \"%s\"\n",
msg, err->node_name);
+ case NFT_PARSE_OPNOTSUPP:
+ return fprintf(stderr, "%s: Operation not supported\n", msg);
default:
return fprintf(stderr, "%s: Undefined error\n", msg);
}
--
1.7.10.4
next reply other threads:[~2015-03-16 15:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-16 15:06 Alvaro Neira Ayuso [this message]
2015-03-16 15:06 ` [nft PATCH 2/3] rule: export the ruleset using the new node "add" Alvaro Neira Ayuso
2015-03-17 10:43 ` Pablo Neira Ayuso
2015-03-16 15:06 ` [nft PATCH 3/3 v5] src: add import command Alvaro Neira Ayuso
2015-03-17 10:49 ` [libnftnl PATCH 1/3] parser: Add operation not supported error message 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=1426518371-11717-1-git-send-email-alvaroneay@gmail.com \
--to=alvaroneay@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).