]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: fix zapi msg debugging dumps 4233/head
authorQuentin Young <qlyoung@cumulusnetworks.com>
Wed, 1 May 2019 00:49:13 +0000 (00:49 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 3 May 2019 19:55:44 +0000 (19:55 +0000)
When we switched to a pthread per client, we lost the ability to
correlate zapi message debugs with their handlers in zlog, because the
message was logged when it was read off the zapi socket and not right
before it was processed. Move the zapi msg hexdump to happen right
before we call the message handler.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
zebra/zapi_msg.c
zebra/zserv.c
zebra/zserv.h

index f31fb53a3430b79e95265ad034e4c294079a6c10..7f6af820185750e0fa43c2a31e83e2153d75a7e9 100644 (file)
@@ -2507,6 +2507,9 @@ void zserv_handle_commands(struct zserv *client, struct stream *msg)
 
        zapi_parse_header(msg, &hdr);
 
+       if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
+               zserv_log_message(NULL, msg, &hdr);
+
 #if defined(HANDLE_ZAPI_FUZZING)
        zserv_write_incoming(msg, hdr.command);
 #endif
index df5f236c04f0d617687695058846951277bd6371..e7b0a2302d3d0f1b4757a1f7fb04889ba29d3add 100644 (file)
@@ -149,8 +149,8 @@ static void zserv_event(struct zserv *client, enum zserv_event event);
  * hdr (optional)
  *    The message header
  */
-static void zserv_log_message(const char *errmsg, struct stream *msg,
-                             struct zmsghdr *hdr)
+void zserv_log_message(const char *errmsg, struct stream *msg,
+                      struct zmsghdr *hdr)
 {
        zlog_debug("Rx'd ZAPI message");
        if (errmsg)
@@ -411,9 +411,6 @@ static int zserv_read(struct thread *thread)
                                   hdr.vrf_id, hdr.length,
                                   sock);
 
-               if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
-                       zserv_log_message(NULL, client->ibuf_work, &hdr);
-
                stream_set_getp(client->ibuf_work, 0);
                struct stream *msg = stream_dup(client->ibuf_work);
 
index 90fd195712be79217cc84a98db35b5137d0c3bae..380f23916e7db80735cd0fa1e191c3e0d248f056 100644 (file)
@@ -240,6 +240,22 @@ extern struct zserv *zserv_find_client(uint8_t proto, unsigned short instance);
  */
 extern void zserv_close_client(struct zserv *client);
 
+
+/*
+ * Log a ZAPI message hexdump.
+ *
+ * errmsg
+ *    Error message to include with packet hexdump
+ *
+ * msg
+ *    Message to log
+ *
+ * hdr
+ *    Message header
+ */
+void zserv_log_message(const char *errmsg, struct stream *msg,
+                      struct zmsghdr *hdr);
+
 #if defined(HANDLE_ZAPI_FUZZING)
 extern void zserv_read_file(char *input);
 #endif