From 7b2d10c52926cf604273b8935c7bce07fe7868d0 Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Fri, 2 Mar 2012 18:33:48 -0800 Subject: [PATCH] ovs-monitor-ipsec: Add unixctl support. With this patch, users can query a running ovs-monitor-ipsec daemon's version, or ask it to exit using ovs-appctl. Signed-off-by: Ethan Jackson --- debian/ovs-monitor-ipsec | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/debian/ovs-monitor-ipsec b/debian/ovs-monitor-ipsec index 981f0a2c..e89e7092 100755 --- a/debian/ovs-monitor-ipsec +++ b/debian/ovs-monitor-ipsec @@ -37,11 +37,19 @@ from ovs.db import types import ovs.util import ovs.daemon import ovs.db.idl +import ovs.unixctl import ovs.vlog vlog = ovs.vlog.Vlog("ovs-monitor-ipsec") root_prefix = '' # Prefix for absolute file names, for testing. setkey = "/usr/sbin/setkey" +exiting = False + + +def unixctl_exit(conn, unused_argv, unused_aux): + global exiting + exiting = True + conn.reply(None) # Class to configure the racoon daemon, which handles IKE negotiation @@ -447,12 +455,22 @@ def main(): ovs.daemon.daemonize() + ovs.unixctl.command_register("exit", "", 0, 0, unixctl_exit, None) + error, unixctl_server = ovs.unixctl.UnixctlServer.create(None) + if error: + ovs.util.ovs_fatal(error, "could not create unixctl server", vlog) + ipsec = IPsec() interfaces = {} while True: + unixctl_server.run() + if exiting: + break + if not idl.run(): poller = ovs.poller.Poller() + unixctl_server.wait(poller) idl.wait(poller) poller.block() continue @@ -499,6 +517,9 @@ def main(): update_ipsec(ipsec, interfaces, new_interfaces) interfaces = new_interfaces + unixctl_server.close() + idl.close() + if __name__ == '__main__': try: -- 2.30.2