From ca71508e5c9c1ed5bb822ea6f33c900922443934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Thu, 10 May 2018 19:51:18 +0000 Subject: [PATCH] Show pid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- src/bind.c | 5 ++++- src/ctl.h | 1 + src/show.c | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bind.c b/src/bind.c index 4bbd339..0e726f3 100644 --- a/src/bind.c +++ b/src/bind.c @@ -202,7 +202,9 @@ gt_bind(int argc, char **argv) fd_set_nonblock(mud_fd); fd_set_nonblock(ctl_fd); - gt_log("running...\n"); + const long pid = (long)getpid(); + + gt_log("running on device %s as pid %li\n", tun_name, pid); fd_set rfds; FD_ZERO(&rfds); @@ -286,6 +288,7 @@ gt_bind(int argc, char **argv) res.ret = errno; break; case CTL_STATUS: + res.status.pid = pid; res.status.mtu = mtu; res.status.chacha = chacha; res.status.bind = bind_addr; diff --git a/src/ctl.h b/src/ctl.h index bcac6b5..2a432e9 100644 --- a/src/ctl.h +++ b/src/ctl.h @@ -26,6 +26,7 @@ struct ctl_msg { } path; struct mud_path path_status; struct { + long pid; size_t mtu; int chacha; struct sockaddr_storage bind; diff --git a/src/show.c b/src/show.c index b6deeff..83b2084 100644 --- a/src/show.c +++ b/src/show.c @@ -29,21 +29,25 @@ gt_show_dev_status(int fd, const char *dev) if (server) { printf("server %s:\n" + " pid: %li\n" " bind: %s port %"PRIu16"\n" " mtu: %zu\n" " cipher: %s\n", dev, + res.status.pid, bindstr[0] ? bindstr : "-", gt_get_port((struct sockaddr *)&res.status.bind), res.status.mtu, res.status.chacha ? "chacha20poly1305" : "aes256gcm"); } else { printf("client %s:\n" + " pid: %li\n" " bind: %s port %"PRIu16"\n" " peer: %s port %"PRIu16"\n" " mtu: %zu\n" " cipher: %s\n", dev, + res.status.pid, bindstr[0] ? bindstr : "-", gt_get_port((struct sockaddr *)&res.status.bind), peerstr[0] ? peerstr : "-",