From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net
Subject: [PATCH nft 1/2] src: introduce netlink_init_error()
Date: Mon, 6 Apr 2015 14:06:30 +0200 [thread overview]
Message-ID: <1428321991-10125-1-git-send-email-pablo@netfilter.org> (raw)
Based on the existing netlink_open_error(), but indicate file and line
where the error happens. This will helps us to diagnose what is going
wrong when users can back to us to report problems.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/netlink.h | 4 +++-
src/netlink.c | 9 +++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/include/netlink.h b/include/netlink.h
index c1ff9c6..9f24ea5 100644
--- a/include/netlink.h
+++ b/include/netlink.h
@@ -145,7 +145,9 @@ extern void netlink_restart(void);
extern void __noreturn __netlink_abi_error(const char *file, int line, const char *reason);
extern int netlink_io_error(struct netlink_ctx *ctx,
const struct location *loc, const char *fmt, ...);
-extern void netlink_open_error(void) __noreturn;
+#define netlink_init_error() \
+ __netlink_init_error(__FILE__, __LINE__, strerror(errno));
+extern void __noreturn __netlink_init_error(const char *file, int line, const char *reason);
extern int netlink_flush_ruleset(struct netlink_ctx *ctx,
const struct handle *h,
diff --git a/src/netlink.c b/src/netlink.c
index a33bb0b..4155763 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -52,7 +52,7 @@ static struct mnl_socket *nfsock_open(void)
s = mnl_socket_open(NETLINK_NETFILTER);
if (s == NULL)
- netlink_open_error();
+ netlink_init_error();
return s;
}
@@ -110,10 +110,11 @@ int netlink_io_error(struct netlink_ctx *ctx, const struct location *loc,
return -1;
}
-void __noreturn netlink_open_error(void)
+void __noreturn __netlink_init_error(const char *filename, int line,
+ const char *reason)
{
- fprintf(stderr, "E: Unable to open Netlink socket: %s\n",
- strerror(errno));
+ fprintf(stderr, "%s:%d: Unable to initialize Netlink socket: %s\n",
+ filename, line, reason);
exit(NFT_EXIT_NONL);
}
--
1.7.10.4
next reply other threads:[~2015-04-06 12:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-06 12:06 Pablo Neira Ayuso [this message]
2015-04-06 12:06 ` [PATCH nft 2/2] src: restore interface to index cache Pablo Neira Ayuso
2015-04-06 12:39 ` Patrick McHardy
2015-04-06 12:58 ` Pablo Neira Ayuso
2015-04-06 12:58 ` 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=1428321991-10125-1-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--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).