summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2009-11-02 20:20:54 +0000
committerclaudio <claudio@openbsd.org>2009-11-02 20:20:54 +0000
commit636d06c3c3c72c74ae6d3c17bf98c92b0296f35c (patch)
tree49e1b858bb0816ec8003450707789c3d2c32f46c
parentDouble the escape timer (the time after a \033 is received before tmux gives up (diff)
downloadwireguard-openbsd-636d06c3c3c72c74ae6d3c17bf98c92b0296f35c.tar.xz
wireguard-openbsd-636d06c3c3c72c74ae6d3c17bf98c92b0296f35c.zip
Implement IMSG_CTL_LOG_VERBOSE to enable or disable debug logging on runtime.
It always annoyed me that in case of a problem I had to restart the ospf in forground debug mode and by doing so losing all routes at least twice. OK henning, sthen, michele
-rw-r--r--usr.sbin/ospfd/control.c22
-rw-r--r--usr.sbin/ospfd/log.c12
-rw-r--r--usr.sbin/ospfd/log.h3
-rw-r--r--usr.sbin/ospfd/ospfd.c11
-rw-r--r--usr.sbin/ospfd/ospfd.h3
-rw-r--r--usr.sbin/ospfd/rde.c9
6 files changed, 47 insertions, 13 deletions
diff --git a/usr.sbin/ospfd/control.c b/usr.sbin/ospfd/control.c
index cc3a1c7c8fc..9f57bb03611 100644
--- a/usr.sbin/ospfd/control.c
+++ b/usr.sbin/ospfd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.27 2009/06/06 07:31:26 eric Exp $ */
+/* $OpenBSD: control.c,v 1.28 2009/11/02 20:20:54 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -193,6 +193,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);
@@ -234,9 +235,8 @@ control_dispatch_imsg(int fd, short event, void *bula)
case IMSG_CTL_KROUTE_ADDR:
case IMSG_CTL_IFINFO:
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 +
@@ -263,6 +263,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/ospfd/log.c b/usr.sbin/ospfd/log.c
index ebba51eb84b..e8326b81d45 100644
--- a/usr.sbin/ospfd/log.c
+++ b/usr.sbin/ospfd/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.5 2006/03/09 16:58:40 claudio Exp $ */
+/* $OpenBSD: log.c,v 1.6 2009/11/02 20:20:54 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/ospfd/log.h b/usr.sbin/ospfd/log.h
index ea96b9c0cc9..ff5ef25a428 100644
--- a/usr.sbin/ospfd/log.h
+++ b/usr.sbin/ospfd/log.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.h,v 1.4 2007/09/28 18:46:56 claudio Exp $ */
+/* $OpenBSD: log.h,v 1.5 2009/11/02 20:20:54 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/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c
index 51ca0fc552d..0150308db5f 100644
--- a/usr.sbin/ospfd/ospfd.c
+++ b/usr.sbin/ospfd/ospfd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.c,v 1.70 2009/06/06 07:31:26 eric Exp $ */
+/* $OpenBSD: ospfd.c,v 1.71 2009/11/02 20:20:54 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -166,8 +166,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 */
@@ -367,7 +367,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;
ibuf = &iev->ibuf;
@@ -420,6 +420,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/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h
index 6d3e8edee82..0e52b2394a4 100644
--- a/usr.sbin/ospfd/ospfd.h
+++ b/usr.sbin/ospfd/ospfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.h,v 1.83 2009/06/06 18:31:42 pyr Exp $ */
+/* $OpenBSD: ospfd.h,v 1.84 2009/11/02 20:20:54 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -90,6 +90,7 @@ enum imsg_type {
IMSG_CTL_KROUTE_ADDR,
IMSG_CTL_IFINFO,
IMSG_CTL_END,
+ IMSG_CTL_LOG_VERBOSE,
IMSG_KROUTE_CHANGE,
IMSG_KROUTE_DELETE,
IMSG_IFINFO,
diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c
index 88c1d7a4350..4c82b747c5b 100644
--- a/usr.sbin/ospfd/rde.c
+++ b/usr.sbin/ospfd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.82 2009/10/05 08:20:26 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.83 2009/11/02 20:20:54 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -240,7 +240,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
char *buf;
ssize_t n;
time_t now;
- int r, state, self, error, shut = 0;
+ int r, state, self, error, shut = 0, verbose;
u_int16_t l;
ibuf = &iev->ibuf;
@@ -562,6 +562,11 @@ rde_dispatch_imsg(int fd, short event, void *bula)
imsg_compose_event(iev_ospfe, IMSG_CTL_END, 0, imsg.hdr.pid,
-1, NULL, 0);
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);