From 5dfb6db929c9e9f9ca4cb190f229e5748e0c0d74 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Mon, 2 Nov 2009 20:23:30 +0000 Subject: Implement "log verbose" and "log brief" to enable or disable verbose debug logging. henning, sthen, michele like the idea --- usr.sbin/ospfctl/ospfctl.8 | 8 ++++++-- usr.sbin/ospfctl/ospfctl.c | 15 +++++++++++++-- usr.sbin/ospfctl/parser.c | 10 +++++++++- usr.sbin/ospfctl/parser.h | 4 +++- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/usr.sbin/ospfctl/ospfctl.8 b/usr.sbin/ospfctl/ospfctl.8 index 13641715ce0..637288f9d20 100644 --- a/usr.sbin/ospfctl/ospfctl.8 +++ b/usr.sbin/ospfctl/ospfctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ospfctl.8,v 1.22 2009/10/22 15:02:12 sobrado Exp $ +.\" $OpenBSD: ospfctl.8,v 1.23 2009/11/02 20:23:29 claudio Exp $ .\" .\" Copyright (c) 2004, 2005 Esben Norby .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 22 2009 $ +.Dd $Mdocdate: November 2 2009 $ .Dt OSPFCTL 8 .Os .Sh NAME @@ -54,6 +54,10 @@ a.k.a. the kernel routing table. Decoupling the FIB from an OSPF router may create routing loops and could cause major routing issues in the complete OSPF cloud. Only routers with just one link to the OSPF cloud can safely decouple the FIB. +.It Cm log verbose +Enable verbose debug logging. +.It Cm log brief +Disable verbose debug logging. .It Cm reload Reload the configuration file. .It Cm show database Op Ar filter diff --git a/usr.sbin/ospfctl/ospfctl.c b/usr.sbin/ospfctl/ospfctl.c index d770e5dbd92..af601c9fe21 100644 --- a/usr.sbin/ospfctl/ospfctl.c +++ b/usr.sbin/ospfctl/ospfctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfctl.c,v 1.49 2009/09/14 11:49:25 claudio Exp $ */ +/* $OpenBSD: ospfctl.c,v 1.50 2009/11/02 20:23:29 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -90,7 +90,7 @@ main(int argc, char *argv[]) unsigned int ifidx = 0; int ctl_sock; int done = 0; - int n; + int n, verbose = 0; int ch; char *sockname; @@ -220,6 +220,15 @@ main(int argc, char *argv[]) printf("decouple request sent.\n"); done = 1; break; + case LOG_VERBOSE: + verbose = 1; + /* FALLTHROUGH */ + case LOG_BRIEF: + imsg_compose(ibuf, IMSG_CTL_LOG_VERBOSE, 0, 0, -1, + &verbose, sizeof(verbose)); + printf("logging request sent.\n"); + done = 1; + break; case RELOAD: imsg_compose(ibuf, IMSG_CTL_RELOAD, 0, 0, -1, NULL, 0); printf("reload request sent.\n"); @@ -287,6 +296,8 @@ main(int argc, char *argv[]) case FIB: case FIB_COUPLE: case FIB_DECOUPLE: + case LOG_VERBOSE: + case LOG_BRIEF: case RELOAD: break; } diff --git a/usr.sbin/ospfctl/parser.c b/usr.sbin/ospfctl/parser.c index 3ca83589c15..8cfacec25eb 100644 --- a/usr.sbin/ospfctl/parser.c +++ b/usr.sbin/ospfctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.15 2007/10/14 01:28:08 deraadt Exp $ */ +/* $OpenBSD: parser.c,v 1.16 2009/11/02 20:23:29 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby @@ -58,11 +58,13 @@ static const struct token t_show_area[]; static const struct token t_show_nbr[]; static const struct token t_show_rib[]; static const struct token t_show_fib[]; +static const struct token t_log[]; static const struct token t_main[] = { {KEYWORD, "reload", RELOAD, NULL}, {KEYWORD, "fib", FIB, t_fib}, {KEYWORD, "show", SHOW, t_show}, + {KEYWORD, "log", NONE, t_log}, {ENDTOKEN, "", NONE, NULL} }; @@ -129,6 +131,12 @@ static const struct token t_show_fib[] = { {ENDTOKEN, "", NONE, NULL} }; +static const struct token t_log[] = { + {KEYWORD, "verbose", LOG_VERBOSE, NULL}, + {KEYWORD, "brief", LOG_BRIEF, NULL}, + {ENDTOKEN, "", NONE, NULL} +}; + static struct parse_result res; struct parse_result * diff --git a/usr.sbin/ospfctl/parser.h b/usr.sbin/ospfctl/parser.h index 3386d9883eb..2815000c26c 100644 --- a/usr.sbin/ospfctl/parser.h +++ b/usr.sbin/ospfctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.8 2006/03/23 18:37:34 norby Exp $ */ +/* $OpenBSD: parser.h,v 1.9 2009/11/02 20:23:29 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby @@ -29,6 +29,8 @@ enum actions { FIB, FIB_COUPLE, FIB_DECOUPLE, + LOG_VERBOSE, + LOG_BRIEF, SHOW, SHOW_SUM, SHOW_IFACE, -- cgit v1.2.3