aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-12-09 19:37:59 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2017-12-09 19:37:59 +0100
commitde3d06162a356866d1589ecbdf38bfeab57587a3 (patch)
treeca9341c1e1cf1526812416e974d962b0e6000bfd
parentstandalone-tools: specify srctree for out of tree builds (diff)
downloadandroid_kernel_wireguard-de3d06162a356866d1589ecbdf38bfeab57587a3.tar.xz
android_kernel_wireguard-de3d06162a356866d1589ecbdf38bfeab57587a3.zip
wg-quick: accept unsolicited netlink messages
-rw-r--r--wg-quick.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/wg-quick.c b/wg-quick.c
index 08a5486..7231b14 100644
--- a/wg-quick.c
+++ b/wg-quick.c
@@ -183,6 +183,7 @@ _printf_(2, 3) static char *cmd_ret(struct command_buffer *c, const char *cmd_fm
_printf_(1, 2) static void cndc(const char *cmd_fmt, ...)
{
DEFINE_CMD(c);
+ int error_code;
char *ret;
va_list args;
_cleanup_free_ char *ndc_fmt = concat("ndc ", cmd_fmt, NULL);
@@ -197,9 +198,14 @@ _printf_(1, 2) static void cndc(const char *cmd_fmt, ...)
ret = vcmd_ret(&c, ndc_fmt, args);
va_end(args);
- if (!ret || !strstr(ret, "200 0")) {
- if (ret)
- fprintf(stderr, "Error: %s\n", ret);
+ if (!ret) {
+ fprintf(stderr, "Error: could not call ndc\n");
+ exit(ENOSYS);
+ }
+
+ error_code = atoi(ret);
+ if (error_code >= 400 && error_code < 600) {
+ fprintf(stderr, "Error: %s\n", ret);
exit(ENONET);
}
}