]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: introduce netlink_init_error()
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 6 Apr 2015 11:57:10 +0000 (13:57 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 9 Apr 2015 11:50:00 +0000 (13:50 +0200)
Based on the existing netlink_open_error(), but indicate file and line
where the error happens. This will help 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
src/netlink.c

index c1ff9c6052f2fa1f38b25c301e2fb942237169cc..9f24ea5ecd353b3b407fb1617d09991c1e933be0 100644 (file)
@@ -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,
index c118502abc2ef4e69276fe10017a44737ad00bcd..343d8bea4e1bd9466d43ec35f951285f4d334c8c 100644 (file)
@@ -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);
 }