Add a new command line option --command-timeout that controls the
command timeout.  It is important to have this configurable, because
the retransmit-timeout is configurable in Libreswan.  Also, users
may prefer the monitor to be more responsive.

ovs-monitor-ipsec options are not documented anywhere, so not
trying to address that here.

Signed-off-by: Ilya Maximets <[email protected]>
---
 ipsec/ovs-monitor-ipsec.in | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ipsec/ovs-monitor-ipsec.in b/ipsec/ovs-monitor-ipsec.in
index 264b055e6..2912075d7 100755
--- a/ipsec/ovs-monitor-ipsec.in
+++ b/ipsec/ovs-monitor-ipsec.in
@@ -82,6 +82,7 @@ vlog = ovs.vlog.Vlog("ovs-monitor-ipsec")
 exiting = False
 monitor = None
 xfrm = None
+command_timeout = None
 TIEMOUT_EXPIRED = 37
 
 
@@ -96,7 +97,7 @@ def run_command(args, description=None):
     proc = subprocess.Popen(args, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
     try:
-        pout, perr = proc.communicate(timeout=120)
+        pout, perr = proc.communicate(timeout=command_timeout)
         ret = proc.returncode
     except subprocess.TimeoutExpired:
         vlog.warn("Command timed out trying to %s." % description)
@@ -1380,6 +1381,10 @@ def main():
     parser.add_argument("--ipsec-ctl", metavar="IPSEC-CTL",
                         help="Use DIR/IPSEC-CTL as location for "
                         " pluto ctl socket (libreswan only).")
+    parser.add_argument("--command-timeout", metavar="TIMEOUT",
+                        type=int, default=120,
+                        help="Timeout for external commands called by the "
+                        "ovs-monitor-ipsec daemon, e.g. ipsec --start.")
 
     ovs.vlog.add_args(parser)
     ovs.daemon.add_args(parser)
@@ -1389,11 +1394,13 @@ def main():
 
     global monitor
     global xfrm
+    global command_timeout
 
     root_prefix = args.root_prefix if args.root_prefix else ""
     xfrm = XFRM(root_prefix)
     monitor = IPsecMonitor(root_prefix, args.ike_daemon,
                            not args.no_restart_ike_daemon, args)
+    command_timeout = args.command_timeout
 
     remote = args.database
     schema_helper = ovs.db.idl.SchemaHelper()
-- 
2.46.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to