diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2017-08-23 15:49:09 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2017-08-23 15:49:09 +0000 |
commit | c6769c2b8f7dc3117a337b5b1a195ceb316960ae (patch) | |
tree | 96dca3fe89b7f04410fc7bf256c71ce03db5b68c /sbin/slaacd | |
parent | c7ec5cfdad3c48d3705b60cc1e0a0eae570ea5f6 (diff) |
Overhaul verbosity handling.
Get rid of cmd_opts which is a leftover from daemons that handle
config files. Instead use a verbose counter for the amount of -v
given on the command line. One enables debug logging, two logs
received router advertisements. This will make debugging unexpected
RAs easier.
Instead of asking for a pcap we can ask for -vv.
Diffstat (limited to 'sbin/slaacd')
-rw-r--r-- | sbin/slaacd/engine.c | 9 | ||||
-rw-r--r-- | sbin/slaacd/slaacd.8 | 7 | ||||
-rw-r--r-- | sbin/slaacd/slaacd.c | 23 | ||||
-rw-r--r-- | sbin/slaacd/slaacd.h | 7 |
4 files changed, 22 insertions, 24 deletions
diff --git a/sbin/slaacd/engine.c b/sbin/slaacd/engine.c index 0e70e0b923c..7f443759d61 100644 --- a/sbin/slaacd/engine.c +++ b/sbin/slaacd/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.17 2017/08/23 14:05:26 florian Exp $ */ +/* $OpenBSD: engine.c,v 1.18 2017/08/23 15:49:08 florian Exp $ */ /* * Copyright (c) 2017 Florian Obser <florian@openbsd.org> @@ -999,9 +999,10 @@ parse_ra(struct slaacd_iface *iface, struct imsg_ra *ra) const char *hbuf; uint8_t *p; -#if 0 - debug_log_ra(ra); -#endif +#ifndef SMALL + if (log_getverbose() > 1) + debug_log_ra(ra); +#endif /* SMALL */ hbuf = sin6_to_str(&ra->from); if (!IN6_IS_ADDR_LINKLOCAL(&ra->from.sin6_addr)) { diff --git a/sbin/slaacd/slaacd.8 b/sbin/slaacd/slaacd.8 index 5adc2e03163..cc2524844f5 100644 --- a/sbin/slaacd/slaacd.8 +++ b/sbin/slaacd/slaacd.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: slaacd.8,v 1.2 2017/08/22 13:58:00 florian Exp $ +.\" $OpenBSD: slaacd.8,v 1.3 2017/08/23 15:49:08 florian Exp $ .\" .\" Copyright (c) 2017 Florian Obser <florian@openbsd.org> .\" Copyright (c) 2016 Kenneth R Westerback <kwesterback@gmail.com> @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: August 22 2017 $ +.Dd $Mdocdate: August 23 2017 $ .Dt SLAACD 8 .Os .Sh NAME @@ -63,6 +63,9 @@ will run in the foreground and log to Use an alternate location for the default control socket. .It Fl v Produce more verbose output. +Multiple +.Fl v +options increase the verbosity. .El .Sh FILES .Bl -tag -width "/dev/slaacd.sockXX" -compact diff --git a/sbin/slaacd/slaacd.c b/sbin/slaacd/slaacd.c index 4c733009e70..5e00cdb123c 100644 --- a/sbin/slaacd/slaacd.c +++ b/sbin/slaacd/slaacd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slaacd.c,v 1.10 2017/08/23 10:48:01 florian Exp $ */ +/* $OpenBSD: slaacd.c,v 1.11 2017/08/23 15:49:08 florian Exp $ */ /* * Copyright (c) 2017 Florian Obser <florian@openbsd.org> @@ -105,8 +105,6 @@ struct imsgev *iev_engine; pid_t frontend_pid; pid_t engine_pid; -uint32_t cmd_opts; - int routesock, ioctl_sock; char *csock; @@ -149,6 +147,7 @@ main(int argc, char *argv[]) struct event ev_sigint, ev_sigterm, ev_sighup; int ch; int debug = 0, engine_flag = 0, frontend_flag = 0; + int verbose = 0; char *saved_argv0; int pipe_main2frontend[2]; int pipe_main2engine[2]; @@ -177,9 +176,7 @@ main(int argc, char *argv[]) csock = optarg; break; case 'v': - if (cmd_opts & OPT_VERBOSE) - cmd_opts |= OPT_VERBOSE2; - cmd_opts |= OPT_VERBOSE; + verbose++; break; default: usage(); @@ -192,9 +189,9 @@ main(int argc, char *argv[]) usage(); if (engine_flag) - engine(debug, cmd_opts & OPT_VERBOSE); + engine(debug, verbose); else if (frontend_flag) - frontend(debug, cmd_opts & OPT_VERBOSE, csock); + frontend(debug, verbose, csock); /* Check for root privileges. */ if (geteuid()) @@ -205,7 +202,7 @@ main(int argc, char *argv[]) errx(1, "unknown user %s", SLAACD_USER); log_init(debug, LOG_DAEMON); - log_setverbose(cmd_opts & OPT_VERBOSE); + log_setverbose(verbose); if (!debug) daemon(1, 0); @@ -221,9 +218,9 @@ main(int argc, char *argv[]) /* Start children. */ engine_pid = start_child(PROC_ENGINE, saved_argv0, pipe_main2engine[1], - debug, cmd_opts & OPT_VERBOSE, NULL); + debug, verbose, NULL); frontend_pid = start_child(PROC_FRONTEND, saved_argv0, - pipe_main2frontend[1], debug, cmd_opts & OPT_VERBOSE, csock); + pipe_main2frontend[1], debug, verbose, csock); slaacd_process = PROC_MAIN; @@ -323,7 +320,7 @@ main_shutdown(void) static pid_t start_child(int p, char *argv0, int fd, int debug, int verbose, char *sockname) { - char *argv[7]; + char *argv[8]; int argc = 0; pid_t pid; @@ -355,6 +352,8 @@ start_child(int p, char *argv0, int fd, int debug, int verbose, char *sockname) argv[argc++] = "-d"; if (verbose) argv[argc++] = "-v"; + if (verbose > 1) + argv[argc++] = "-v"; if (sockname) { argv[argc++] = "-s"; argv[argc++] = sockname; diff --git a/sbin/slaacd/slaacd.h b/sbin/slaacd/slaacd.h index fc5c1d64bfe..d32270a1e03 100644 --- a/sbin/slaacd/slaacd.h +++ b/sbin/slaacd/slaacd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: slaacd.h,v 1.9 2017/08/23 10:48:01 florian Exp $ */ +/* $OpenBSD: slaacd.h,v 1.10 2017/08/23 15:49:08 florian Exp $ */ /* * Copyright (c) 2017 Florian Obser <florian@openbsd.org> @@ -21,9 +21,6 @@ #define SLAACD_SOCKET "/dev/slaacd.sock" #define SLAACD_USER "_slaacd" -#define OPT_VERBOSE 0x00000001 -#define OPT_VERBOSE2 0x00000002 - /* MAXDNAME from arpa/namesr.h */ #define SLAACD_MAX_DNSSL 1025 @@ -191,8 +188,6 @@ struct imsg_ra { uint8_t packet[1500]; }; -extern uint32_t cmd_opts; - /* slaacd.c */ int main_imsg_compose_frontend(int, pid_t, void *, uint16_t); int main_imsg_compose_engine(int, pid_t, void *, uint16_t); |