diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-11-02 20:38:16 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-11-02 20:38:16 +0000 |
commit | d4634e25b09562de3e880667f1cb192c2b92df6d (patch) | |
tree | 0e1234b1027c6beddb16ce8d7ba893aadc5d48ee /usr.sbin | |
parent | c2fb2e6439d9d6ad1aafc59781609220efc3b197 (diff) |
Implement IMSG_CTL_LOG_VERBOSE similar to ospfd. Even though bgpd has almost
no log_debug() it makes more sense to make all routing daemons behave the same.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 12 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/control.c | 19 | ||||
-rw-r--r-- | usr.sbin/bgpd/log.c | 12 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.c | 10 |
5 files changed, 47 insertions, 10 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 048e0c3d5f0..b92085737c9 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.149 2009/07/20 15:00:13 claudio Exp $ */ +/* $OpenBSD: bgpd.c,v 1.150 2009/11/02 20:38:15 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -158,6 +158,7 @@ main(int argc, char *argv[]) if (conf.opts & BGPD_OPT_VERBOSE) conf.opts |= BGPD_OPT_VERBOSE2; conf.opts |= BGPD_OPT_VERBOSE; + log_verbose(1); break; case 'r': conf.rcsock = optarg; @@ -554,8 +555,8 @@ int dispatch_imsg(struct imsgbuf *ibuf, int idx) { struct imsg imsg; - int n; - int rv; + ssize_t n; + int rv, verbose; if ((n = imsg_read(ibuf)) == -1) return (-1); @@ -696,6 +697,11 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx) carp_demote_set(msg->demote_group, msg->level); } break; + case IMSG_CTL_LOG_VERBOSE: + /* already checked by SE */ + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: break; } diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 193b1b98348..c8f18e84e26 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.245 2009/09/04 11:50:28 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.246 2009/11/02 20:38:15 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -290,6 +290,7 @@ enum imsg_type { IMSG_CTL_SHOW_RIB_MEM, IMSG_CTL_SHOW_TERSE, IMSG_CTL_SHOW_TIMER, + IMSG_CTL_LOG_VERBOSE, IMSG_NETWORK_ADD, IMSG_NETWORK_REMOVE, IMSG_NETWORK_FLUSH, @@ -713,6 +714,7 @@ int bgpd_filternexthop(struct kroute *, struct kroute6 *); /* log.c */ void log_init(int); +void log_verbose(int); void vlog(int, const char *, va_list); void log_peer_warn(const struct peer_config *, const char *, ...); void log_peer_warnx(const struct peer_config *, const char *, ...); diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index 6ae4eb97ccb..ef1378f7788 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.62 2009/09/02 08:06:42 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.63 2009/11/02 20:38:15 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -191,7 +191,8 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) { struct imsg imsg; struct ctl_conn *c; - int n; + ssize_t n; + int verbose; struct peer *p; struct ctl_neighbor *neighbor; struct ctl_show_rib_request *ribreq; @@ -425,6 +426,20 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) imsg_compose_rde(imsg.hdr.type, 0, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); break; + case IMSG_CTL_LOG_VERBOSE: + if (imsg.hdr.len != IMSG_HEADER_SIZE + + sizeof(verbose)) + break; + + /* forward to other porcesses */ + imsg_compose_parent(imsg.hdr.type, imsg.hdr.pid, + imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); + imsg_compose_rde(imsg.hdr.type, 0, + imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); + + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: break; } diff --git a/usr.sbin/bgpd/log.c b/usr.sbin/bgpd/log.c index c426ee96037..c2ab54834c7 100644 --- a/usr.sbin/bgpd/log.c +++ b/usr.sbin/bgpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.50 2007/04/23 13:04:24 claudio Exp $ */ +/* $OpenBSD: log.c,v 1.51 2009/11/02 20:38:15 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -32,6 +32,7 @@ #include "log.h" int debug; +int verbose; void logit(int, const char *, ...); @@ -69,6 +70,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); @@ -77,6 +79,12 @@ log_init(int n_debug) } void +log_verbose(int v) +{ + verbose = v; +} + +void logit(int pri, const char *fmt, ...) { va_list ap; @@ -193,7 +201,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/bgpd/rde.c b/usr.sbin/bgpd/rde.c index bdbf390b64e..5d8c49d6523 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.272 2009/10/28 15:54:13 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.273 2009/11/02 20:38:15 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -389,7 +389,8 @@ rde_dispatch_imsg_session(struct imsgbuf *ibuf) struct ctl_show_rib_request req; struct filter_set *s; struct nexthop *nh; - int n; + ssize_t n; + int verbose; if ((n = imsg_read(ibuf)) == -1) fatal("rde_dispatch_imsg_session: imsg_read error"); @@ -549,6 +550,11 @@ badnet: imsg_compose(ibuf_se_ctl, IMSG_CTL_SHOW_RIB_MEM, 0, imsg.hdr.pid, -1, &rdemem, sizeof(rdemem)); break; + case IMSG_CTL_LOG_VERBOSE: + /* already checked by SE */ + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: break; } |