diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-11-02 20:24:59 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-11-02 20:24:59 +0000 |
commit | 21fd201e17b979e77710deeb3abb54c7a2d911ce (patch) | |
tree | 7a843a499ad92a431f6fc67b1b08944f15d57869 | |
parent | 5dfb6db929c9e9f9ca4cb190f229e5748e0c0d74 (diff) |
Add IMSG_CTL_LOG_VERBOSE similar to ospfd it allows to toggle debug logging.
henning, sthen, michele like the idea
-rw-r--r-- | usr.sbin/ospf6d/control.c | 22 | ||||
-rw-r--r-- | usr.sbin/ospf6d/log.c | 12 | ||||
-rw-r--r-- | usr.sbin/ospf6d/log.h | 3 | ||||
-rw-r--r-- | usr.sbin/ospf6d/ospf6d.c | 11 | ||||
-rw-r--r-- | usr.sbin/ospf6d/ospf6d.h | 3 | ||||
-rw-r--r-- | usr.sbin/ospf6d/rde.c | 9 |
6 files changed, 47 insertions, 13 deletions
diff --git a/usr.sbin/ospf6d/control.c b/usr.sbin/ospf6d/control.c index 7ecdd792aa3..ad372a6822b 100644 --- a/usr.sbin/ospf6d/control.c +++ b/usr.sbin/ospf6d/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.10 2009/06/06 09:02:46 eric Exp $ */ +/* $OpenBSD: control.c,v 1.11 2009/11/02 20:24:58 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -191,6 +191,7 @@ control_dispatch_imsg(int fd, short event, void *bula) struct imsg imsg; int n; unsigned int ifidx; + int verbose; if ((c = control_connbyfd(fd)) == NULL) { log_warn("control_dispatch_imsg: fd %d: not found", fd); @@ -231,9 +232,8 @@ control_dispatch_imsg(int fd, short event, void *bula) case IMSG_CTL_KROUTE: case IMSG_CTL_KROUTE_ADDR: c->iev.ibuf.pid = imsg.hdr.pid; - ospfe_imsg_compose_parent(imsg.hdr.type, - imsg.hdr.pid, imsg.data, - imsg.hdr.len - IMSG_HEADER_SIZE); + ospfe_imsg_compose_parent(imsg.hdr.type, imsg.hdr.pid, + imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); break; case IMSG_CTL_SHOW_INTERFACE: if (imsg.hdr.len == IMSG_HEADER_SIZE + @@ -262,6 +262,20 @@ control_dispatch_imsg(int fd, short event, void *bula) case IMSG_CTL_SHOW_NBR: ospfe_nbr_ctl(c); break; + case IMSG_CTL_LOG_VERBOSE: + if (imsg.hdr.len != IMSG_HEADER_SIZE + + sizeof(verbose)) + break; + + /* forward to other porcesses */ + ospfe_imsg_compose_parent(imsg.hdr.type, imsg.hdr.pid, + imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); + ospfe_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/ospf6d/log.c b/usr.sbin/ospf6d/log.c index 446268acd42..15f19b8606a 100644 --- a/usr.sbin/ospf6d/log.c +++ b/usr.sbin/ospf6d/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.4 2009/03/29 19:07:56 stsp Exp $ */ +/* $OpenBSD: log.c,v 1.5 2009/11/02 20:24:58 claudio Exp $ */ /* * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org> @@ -41,6 +41,7 @@ static const char * const procnames[] = { }; int debug; +int verbose; void logit(int, const char *, ...); @@ -50,6 +51,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); @@ -58,6 +60,12 @@ log_init(int n_debug) } void +log_verbose(int v) +{ + verbose = v; +} + +void logit(int pri, const char *fmt, ...) { va_list ap; @@ -135,7 +143,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/ospf6d/log.h b/usr.sbin/ospf6d/log.h index 6d5c59cdbe4..456b0aec324 100644 --- a/usr.sbin/ospf6d/log.h +++ b/usr.sbin/ospf6d/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.3 2009/03/29 19:07:56 stsp Exp $ */ +/* $OpenBSD: log.h,v 1.4 2009/11/02 20:24:58 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/ospf6d/ospf6d.c b/usr.sbin/ospf6d/ospf6d.c index 4ca3142623e..f30250bf516 100644 --- a/usr.sbin/ospf6d/ospf6d.c +++ b/usr.sbin/ospf6d/ospf6d.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospf6d.c,v 1.15 2009/06/06 09:02:46 eric Exp $ */ +/* $OpenBSD: ospf6d.c,v 1.16 2009/11/02 20:24:58 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -161,8 +161,8 @@ main(int argc, char *argv[]) if (opts & OSPFD_OPT_VERBOSE) opts |= OSPFD_OPT_VERBOSE2; opts |= OSPFD_OPT_VERBOSE; + log_verbose(1); break; - default: usage(); /* NOTREACHED */ @@ -353,7 +353,7 @@ main_dispatch_ospfe(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) @@ -396,6 +396,11 @@ main_dispatch_ospfe(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 ospfe */ + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: log_debug("main_dispatch_ospfe: error handling imsg %d", imsg.hdr.type); diff --git a/usr.sbin/ospf6d/ospf6d.h b/usr.sbin/ospf6d/ospf6d.h index 7716ad21d21..9bd71a4f0a9 100644 --- a/usr.sbin/ospf6d/ospf6d.h +++ b/usr.sbin/ospf6d/ospf6d.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospf6d.h,v 1.16 2009/06/06 18:31:42 pyr Exp $ */ +/* $OpenBSD: ospf6d.h,v 1.17 2009/11/02 20:24:58 claudio Exp $ */ /* * Copyright (c) 2004, 2007 Esben Norby <norby@openbsd.org> @@ -94,6 +94,7 @@ enum imsg_type { IMSG_CTL_KROUTE, IMSG_CTL_KROUTE_ADDR, IMSG_CTL_END, + IMSG_CTL_LOG_VERBOSE, IMSG_KROUTE_CHANGE, IMSG_KROUTE_DELETE, IMSG_KROUTE_GET, diff --git a/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c index eb69f32bc87..40c717fba7e 100644 --- a/usr.sbin/ospf6d/rde.c +++ b/usr.sbin/ospf6d/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.33 2009/07/28 19:16:34 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.34 2009/11/02 20:24:58 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -256,7 +256,7 @@ rde_dispatch_imsg(int fd, short event, void *bula) char *buf; ssize_t n; time_t now; - int r, state, self, shut = 0; + int r, state, self, shut = 0, verbose; u_int16_t l; if (event & EV_READ) { @@ -597,6 +597,11 @@ rde_dispatch_imsg(int fd, short event, void *bula) orig_intra_area_prefix_lsas(area); } break; + case IMSG_CTL_LOG_VERBOSE: + /* already checked by ospfe */ + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: log_debug("rde_dispatch_imsg: unexpected imsg %d", imsg.hdr.type); |