The daemon will now log to scapy.log file.

Log messages include stats on request processing time as well as any
errors that may happen during processing.

If you'd like to see even more logs (e.g. for debugging purposes), just
pass --verbose to scapy-server.

Signed-off-by: Ihar Hrachyshka <ihrac...@redhat.com>
---
 tests/ovn-macros.at   |  5 ++++-
 tests/scapy-server.py | 20 ++++++++++++++++++--
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at
index 0b15bcc80..21c314c7c 100644
--- a/tests/ovn-macros.at
+++ b/tests/ovn-macros.at
@@ -882,7 +882,10 @@ fmt_pkt() {
 start_scapy_server() {
     pidfile=$ovs_base/scapy.pid
     ctlfile=$ovs_base/scapy.ctl
-    "$top_srcdir"/tests/scapy-server.py --pidfile=$pidfile --unixctl=$ctlfile 
--detach
+    logfile=$ovs_base/scapy.log
+
+    "$top_srcdir"/tests/scapy-server.py \
+        --pidfile=$pidfile --unixctl=$ctlfile --log-file=$logfile --detach
     on_exit "test -e \"$pidfile\" && ovs-appctl -t $ctlfile exit"
 }
 
diff --git a/tests/scapy-server.py b/tests/scapy-server.py
index a7255c84d..52def4b5c 100755
--- a/tests/scapy-server.py
+++ b/tests/scapy-server.py
@@ -1,6 +1,7 @@
 #!/usr/bin/env python3
 
 import argparse
+import datetime
 
 import ovs.daemon
 import ovs.unixctl
@@ -23,15 +24,28 @@ def exit(conn, argv, aux):
 
 
 def process(data):
+    start_time = datetime.now()
+    vlog.info("received payload request")
     try:
         data = data.replace('\n', '')
         return binascii.hexlify(raw(eval(data))).decode()
-    except Exception:
+    except Exception as e:
+        vlog.exception(
+            f"failed to process payload request: {e}\n"
+            f" Request was: {data}")
         return ""
+    finally:
+        total_time = (datetime.now() - start_time).microseconds / 1000
+        vlog.info(f"took {total_time:.2f}ms to process payload request")
 
 
 def payload(conn, argv, aux):
-    conn.reply(process(argv[0]))
+    try:
+        conn.reply(process(argv[0]))
+    except Exception as e:
+        vlog.exception(
+            f"failed to reply to payload request: {e}\n"
+            f" Request was: {argv[0]}")
 
 
 def main():
@@ -55,6 +69,8 @@ def main():
     ovs.unixctl.command_register("payload", "", 1, 1, payload, None)
     ovs.daemon.daemonize_complete()
 
+    vlog.info("scapy server ready")
+
     poller = ovs.poller.Poller()
     while not exiting:
         server.run()
-- 
2.41.0

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to