diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-11-02 20:28:50 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-11-02 20:28:50 +0000 |
commit | 73e30d30e9303ec154a841cb0fc722fe96b77344 (patch) | |
tree | 1f5cf5ff94951dcc0e3b1c65f7478873ff52c8d8 /usr.sbin | |
parent | 650f5a556835c74a288fb331fe461b0abb0ca910 (diff) |
Another routing daemon that gets IMSG_CTL_LOG_VERBOSE to allow toggeling of
log_debug(). ok michele, henning, sthen
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ripd/control.c | 17 | ||||
-rw-r--r-- | usr.sbin/ripd/log.c | 12 | ||||
-rw-r--r-- | usr.sbin/ripd/log.h | 3 | ||||
-rw-r--r-- | usr.sbin/ripd/rde.c | 9 | ||||
-rw-r--r-- | usr.sbin/ripd/ripd.c | 9 | ||||
-rw-r--r-- | usr.sbin/ripd/ripd.h | 3 |
6 files changed, 44 insertions, 9 deletions
diff --git a/usr.sbin/ripd/control.c b/usr.sbin/ripd/control.c index 917ecb5dfaf..27751ace744 100644 --- a/usr.sbin/ripd/control.c +++ b/usr.sbin/ripd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.10 2009/06/06 08:20:55 eric Exp $ */ +/* $OpenBSD: control.c,v 1.11 2009/11/02 20:28:48 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -192,6 +192,7 @@ control_dispatch_imsg(int fd, short event, void *bula) struct imsg imsg; ssize_t n; unsigned int ifidx; + int verbose; if ((c = control_connbyfd(fd)) == NULL) { log_warn("control_dispatch_imsg: fd %d: not found", fd); @@ -254,6 +255,20 @@ control_dispatch_imsg(int fd, short event, void *bula) c->iev.ibuf.pid = imsg.hdr.pid; ripe_imsg_compose_parent(imsg.hdr.type, 0, NULL, 0); break; + case IMSG_CTL_LOG_VERBOSE: + if (imsg.hdr.len != IMSG_HEADER_SIZE + + sizeof(verbose)) + break; + + /* forward to other porcesses */ + ripe_imsg_compose_parent(imsg.hdr.type, imsg.hdr.pid, + imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); + ripe_imsg_compose_rde(imsg.hdr.type, 0, imsg.hdr.pid, + imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); + + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: log_debug("control_dispatch_imsg: " "error handling imsg %d", imsg.hdr.type); diff --git a/usr.sbin/ripd/log.c b/usr.sbin/ripd/log.c index f91405608f2..c66b67838a5 100644 --- a/usr.sbin/ripd/log.c +++ b/usr.sbin/ripd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.2 2006/10/31 23:43:11 michele Exp $ */ +/* $OpenBSD: log.c,v 1.3 2009/11/02 20:28:49 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -34,6 +34,7 @@ static const char * const procnames[] = { }; int debug; +int verbose; void logit(int, const char *, ...); @@ -43,6 +44,7 @@ log_init(int n_debug) extern char *__progname; debug = n_debug; + verbose = n_debug; if (!debug) openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON); @@ -51,6 +53,12 @@ log_init(int n_debug) } void +log_verbose(int v) +{ + verbose = v; +} + +void logit(int pri, const char *fmt, ...) { va_list ap; @@ -128,7 +136,7 @@ log_debug(const char *emsg, ...) { va_list ap; - if (debug) { + if (verbose) { va_start(ap, emsg); vlog(LOG_DEBUG, emsg, ap); va_end(ap); diff --git a/usr.sbin/ripd/log.h b/usr.sbin/ripd/log.h index f1be0c23b55..bc2eb87f447 100644 --- a/usr.sbin/ripd/log.h +++ b/usr.sbin/ripd/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.1 2006/10/18 16:11:58 norby Exp $ */ +/* $OpenBSD: log.h,v 1.2 2009/11/02 20:28:49 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -22,6 +22,7 @@ #include <stdarg.h> void log_init(int); +void log_verbose(int); void vlog(int, const char *, va_list); void log_warn(const char *, ...); void log_warnx(const char *, ...); diff --git a/usr.sbin/ripd/rde.c b/usr.sbin/ripd/rde.c index e24b6916556..f819d2e0d42 100644 --- a/usr.sbin/ripd/rde.c +++ b/usr.sbin/ripd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.13 2009/09/18 16:17:02 michele Exp $ */ +/* $OpenBSD: rde.c,v 1.14 2009/11/02 20:28:49 claudio Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -189,7 +189,7 @@ rde_dispatch_imsg(int fd, short event, void *bula) struct rip_route rr; struct imsg imsg; ssize_t n; - int shut = 0; + int shut = 0, verbose; if (event & EV_READ) { if ((n = imsg_read(ibuf)) == -1) @@ -258,6 +258,11 @@ rde_dispatch_imsg(int fd, short event, void *bula) imsg.hdr.pid, -1, NULL, 0); break; + case IMSG_CTL_LOG_VERBOSE: + /* already checked by ripe */ + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: log_debug("rde_dispatch_msg: unexpected imsg %d", imsg.hdr.type); diff --git a/usr.sbin/ripd/ripd.c b/usr.sbin/ripd/ripd.c index e081bb9a584..b26b6827213 100644 --- a/usr.sbin/ripd/ripd.c +++ b/usr.sbin/ripd/ripd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ripd.c,v 1.18 2009/09/26 18:24:58 michele Exp $ */ +/* $OpenBSD: ripd.c,v 1.19 2009/11/02 20:28:49 claudio Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -342,7 +342,7 @@ main_dispatch_ripe(int fd, short event, void *bula) struct imsg imsg; struct demote_msg dmsg; ssize_t n; - int shut = 0; + int shut = 0, verbose; if (event & EV_READ) { if ((n = imsg_read(ibuf)) == -1) @@ -390,6 +390,11 @@ main_dispatch_ripe(int fd, short event, void *bula) memcpy(&dmsg, imsg.data, sizeof(dmsg)); carp_demote_set(dmsg.demote_group, dmsg.level); break; + case IMSG_CTL_LOG_VERBOSE: + /* already checked by ripe */ + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: log_debug("main_dispatch_ripe: error handling imsg %d", imsg.hdr.type); diff --git a/usr.sbin/ripd/ripd.h b/usr.sbin/ripd/ripd.h index d9e71680059..56db4403643 100644 --- a/usr.sbin/ripd/ripd.h +++ b/usr.sbin/ripd/ripd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ripd.h,v 1.20 2009/09/26 18:24:58 michele Exp $ */ +/* $OpenBSD: ripd.h,v 1.21 2009/11/02 20:28:49 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -78,6 +78,7 @@ enum imsg_type { IMSG_CTL_SHOW_IFACE, IMSG_CTL_SHOW_NBR, IMSG_CTL_SHOW_RIB, + IMSG_CTL_LOG_VERBOSE, IMSG_KROUTE_CHANGE, IMSG_KROUTE_DELETE, IMSG_NETWORK_ADD, |