aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-03-20 21:12:19 +0100
committerStefano Brivio <sbrivio@redhat.com>2021-03-20 22:19:15 +0100
commit35015ce72ea47208e207ef6c5e75d550fa095862 (patch)
tree1fd7a17847c611bf5696d2b940ea7511d7ae0e0a
parent9f8049931370426f43d704a288113596ea3ea6e6 (diff)
downloadpasst-35015ce72ea47208e207ef6c5e75d550fa095862.tar
passt-35015ce72ea47208e207ef6c5e75d550fa095862.tar.gz
passt-35015ce72ea47208e207ef6c5e75d550fa095862.tar.bz2
passt-35015ce72ea47208e207ef6c5e75d550fa095862.tar.lz
passt-35015ce72ea47208e207ef6c5e75d550fa095862.tar.xz
passt-35015ce72ea47208e207ef6c5e75d550fa095862.tar.zst
passt-35015ce72ea47208e207ef6c5e75d550fa095862.zip
passt: Initialise socket after getting addresses and routes
...otherwise, both IPv4 and IPv6 are considered disabled, and nothing works anymore. While at it, don't fork to background on debug builds, and log to stderr too in that case. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--passt.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/passt.c b/passt.c
index 6b160c0..51b76c9 100644
--- a/passt.c
+++ b/passt.c
@@ -540,21 +540,25 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
- if (icmp_sock_init(&c) || tcp_sock_init(&c) || udp_sock_init(&c))
- exit(EXIT_FAILURE);
-
- fd_unix = sock_unix();
-
+#if DEBUG
+ openlog("passt", LOG_PERROR, LOG_DAEMON);
+#else
openlog("passt", 0, LOG_DAEMON);
if (daemon(0, 0)) {
fprintf(stderr, "Failed to fork into background\n");
exit(EXIT_FAILURE);
}
+#endif
get_routes(&c);
get_addrs(&c);
get_dns(&c);
+ fd_unix = sock_unix();
+
+ if (icmp_sock_init(&c) || tcp_sock_init(&c) || udp_sock_init(&c))
+ exit(EXIT_FAILURE);
+
if (c.v4) {
info("ARP:");
info(" address: %02x:%02x:%02x:%02x:%02x:%02x from %s",