summaryrefslogtreecommitdiffstats
path: root/lib/libnetgraph
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>2000-04-28 18:41:21 +0000
committerarchie <archie@FreeBSD.org>2000-04-28 18:41:21 +0000
commitfaccef08ea94821090583648e1b7c0bdb747f896 (patch)
treed3bd3f95d586b070c7bf3c9cfa5094aa78229d3b /lib/libnetgraph
parentd7f46cd010ca8dcbcfe5bcc1a28e927ed9a5bd48 (diff)
downloadFreeBSD-src-faccef08ea94821090583648e1b7c0bdb747f896.zip
FreeBSD-src-faccef08ea94821090583648e1b7c0bdb747f896.tar.gz
Fix a bug handling the debug level when displaying control messages
in their ASCII forms at debug levels >= 3.
Diffstat (limited to 'lib/libnetgraph')
-rw-r--r--lib/libnetgraph/debug.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/libnetgraph/debug.c b/lib/libnetgraph/debug.c
index b5bb56a..131ae3c 100644
--- a/lib/libnetgraph/debug.c
+++ b/lib/libnetgraph/debug.c
@@ -171,7 +171,8 @@ _NgDebugSockaddr(const struct sockaddr_ng *sg)
sg->sg_family, sg->sg_len, sg->sg_data);
}
-#define ARGS_BUFSIZE 1024
+#define ARGS_BUFSIZE 2048
+#define RECURSIVE_DEBUG_ADJUST 4
/*
* Display a negraph message
@@ -182,11 +183,7 @@ _NgDebugMsg(const struct ng_mesg *msg, const char *path)
u_char buf[2 * sizeof(struct ng_mesg) + ARGS_BUFSIZE];
struct ng_mesg *const req = (struct ng_mesg *)buf;
struct ng_mesg *const bin = (struct ng_mesg *)req->data;
- int arglen, debugSave, csock = -1;
-
- /* Lower debugging to avoid infinite recursion */
- debugSave = _gNgDebugLevel;
- _gNgDebugLevel -= 4;
+ int arglen, csock = -1;
/* Display header stuff */
NGLOGX("NG_MESG :");
@@ -217,12 +214,22 @@ _NgDebugMsg(const struct ng_mesg *msg, const char *path)
memcpy(bin, msg, sizeof(*msg) + arglen);
bin->header.arglen = arglen;
+ /* Lower debugging to avoid infinite recursion */
+ _gNgDebugLevel -= RECURSIVE_DEBUG_ADJUST;
+
/* Ask the node to translate the binary message to ASCII for us */
if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
- NGM_BINARY2ASCII, bin, sizeof(*bin) + bin->header.arglen) < 0)
+ NGM_BINARY2ASCII, bin, sizeof(*bin) + bin->header.arglen) < 0) {
+ _gNgDebugLevel += RECURSIVE_DEBUG_ADJUST;
goto fail;
- if (NgRecvMsg(csock, req, sizeof(buf), NULL) < 0)
+ }
+ if (NgRecvMsg(csock, req, sizeof(buf), NULL) < 0) {
+ _gNgDebugLevel += RECURSIVE_DEBUG_ADJUST;
goto fail;
+ }
+
+ /* Restore debugging level */
+ _gNgDebugLevel += RECURSIVE_DEBUG_ADJUST;
/* Display command string and arguments */
NGLOGX(" cmd %s (%d)", bin->header.cmdstr, bin->header.cmd);
@@ -240,7 +247,6 @@ fail2:
done:
if (csock != -1)
(void)close(csock);
- _gNgDebugLevel = debugSave;
}
/*
OpenPOWER on IntegriCloud