summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2009-11-02 20:34:59 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2009-11-02 20:34:59 +0000
commitfc9e841952912943ca6495d7885058e4408462b0 (patch)
treeac1a244ccb559fa1a0d3b287522207708a9049b4 /usr.sbin/ldpd
parent8f153481f259a4035c7ff4f463838f93bcb6dceb (diff)
More IMSG_CTL_LOG_VERBOSE, still doing the same toggeling of log_debug().
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r--usr.sbin/ldpd/control.c17
-rw-r--r--usr.sbin/ldpd/lde.c9
-rw-r--r--usr.sbin/ldpd/ldpd.c11
-rw-r--r--usr.sbin/ldpd/ldpd.h3
-rw-r--r--usr.sbin/ldpd/log.c12
-rw-r--r--usr.sbin/ldpd/log.h3
6 files changed, 45 insertions, 10 deletions
diff --git a/usr.sbin/ldpd/control.c b/usr.sbin/ldpd/control.c
index 9726038d0a8..66dfe0d2224 100644
--- a/usr.sbin/ldpd/control.c
+++ b/usr.sbin/ldpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.2 2009/06/06 08:09:43 pyr Exp $ */
+/* $OpenBSD: control.c,v 1.3 2009/11/02 20:34:58 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;
int 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)
case IMSG_CTL_SHOW_NBR:
ldpe_nbr_ctl(c);
break;
+ case IMSG_CTL_LOG_VERBOSE:
+ if (imsg.hdr.len != IMSG_HEADER_SIZE +
+ sizeof(verbose))
+ break;
+
+ /* forward to other porcesses */
+ ldpe_imsg_compose_parent(imsg.hdr.type, imsg.hdr.pid,
+ imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE);
+ ldpe_imsg_compose_lde(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/ldpd/lde.c b/usr.sbin/ldpd/lde.c
index 521d7076356..3692ffb836f 100644
--- a/usr.sbin/ldpd/lde.c
+++ b/usr.sbin/ldpd/lde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde.c,v 1.6 2009/09/28 09:48:46 michele Exp $ */
+/* $OpenBSD: lde.c,v 1.7 2009/11/02 20:34:58 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -201,7 +201,7 @@ lde_dispatch_imsg(int fd, short event, void *bula)
struct in_addr addr;
ssize_t n;
time_t now;
- int state, shut = 0;
+ int state, shut = 0, verbose;
if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
@@ -327,6 +327,11 @@ lde_dispatch_imsg(int fd, short event, void *bula)
imsg_compose_event(iev_ldpe, IMSG_CTL_END, 0,
imsg.hdr.pid, -1, NULL, 0);
break;
+ case IMSG_CTL_LOG_VERBOSE:
+ /* already checked by ldpe */
+ memcpy(&verbose, imsg.data, sizeof(verbose));
+ log_verbose(verbose);
+ break;
default:
log_debug("lde_dispatch_imsg: unexpected imsg %d",
imsg.hdr.type);
diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c
index 0be86d4bf19..9e5d93bc11b 100644
--- a/usr.sbin/ldpd/ldpd.c
+++ b/usr.sbin/ldpd/ldpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.c,v 1.4 2009/10/28 09:15:58 sobrado Exp $ */
+/* $OpenBSD: ldpd.c,v 1.5 2009/11/02 20:34:58 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -159,8 +159,8 @@ main(int argc, char *argv[])
if (opts & LDPD_OPT_VERBOSE)
opts |= LDPD_OPT_VERBOSE2;
opts |= LDPD_OPT_VERBOSE;
+ log_verbose(1);
break;
-
default:
usage();
/* NOTREACHED */
@@ -356,7 +356,7 @@ main_dispatch_ldpe(int fd, short event, void *bula)
struct imsgbuf *ibuf = &iev->ibuf;
struct imsg imsg;
ssize_t n;
- int shut = 0;
+ int shut = 0, verbose;
if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
@@ -403,6 +403,11 @@ main_dispatch_ldpe(int fd, short event, void *bula)
else
log_warnx("IFINFO request with wrong len");
break;
+ case IMSG_CTL_LOG_VERBOSE:
+ /* already checked by ldpe */
+ memcpy(&verbose, imsg.data, sizeof(verbose));
+ log_verbose(verbose);
+ break;
default:
log_debug("main_dispatch_ldpe: error handling imsg %d",
imsg.hdr.type);
diff --git a/usr.sbin/ldpd/ldpd.h b/usr.sbin/ldpd/ldpd.h
index 3f8eb00f3ce..2f59d9ea32e 100644
--- a/usr.sbin/ldpd/ldpd.h
+++ b/usr.sbin/ldpd/ldpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.h,v 1.7 2009/09/28 09:48:46 michele Exp $ */
+/* $OpenBSD: ldpd.h,v 1.8 2009/11/02 20:34:58 claudio Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -77,6 +77,7 @@ enum imsg_type {
IMSG_CTL_KROUTE_ADDR,
IMSG_CTL_IFINFO,
IMSG_CTL_END,
+ IMSG_CTL_LOG_VERBOSE,
IMSG_KLABEL_INSERT,
IMSG_KLABEL_CHANGE,
IMSG_KLABEL_DELETE,
diff --git a/usr.sbin/ldpd/log.c b/usr.sbin/ldpd/log.c
index 1e97d6f1a23..98c9c6a05f5 100644
--- a/usr.sbin/ldpd/log.c
+++ b/usr.sbin/ldpd/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.1 2009/06/01 20:59:45 michele Exp $ */
+/* $OpenBSD: log.c,v 1.2 2009/11/02 20:34:58 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/ldpd/log.h b/usr.sbin/ldpd/log.h
index 7fea7d99b30..e03e202164c 100644
--- a/usr.sbin/ldpd/log.h
+++ b/usr.sbin/ldpd/log.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.h,v 1.1 2009/06/01 20:59:45 michele Exp $ */
+/* $OpenBSD: log.h,v 1.2 2009/11/02 20:34: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 *, ...);