From patchwork Wed Mar 7 05:30:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoshuai Li X-Patchwork-Id: 882409 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=dtdream.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zx2Kx3Lx6z9sfg for ; Wed, 7 Mar 2018 16:30:44 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 333D814E8; Wed, 7 Mar 2018 05:30:41 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 1471214CD for ; Wed, 7 Mar 2018 05:30:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtp2203-239.mail.aliyun.com (smtp2203-239.mail.aliyun.com [121.197.203.239]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9B0365F4 for ; Wed, 7 Mar 2018 05:30:37 +0000 (UTC) X-Alimail-AntiSpam: AC=CONTINUE; BC=0.2232464|-1; CH=green; FP=0|0|0|0|0|-1|-1|-1; HT=e01l01425; MF=ligs@dtdream.com; NM=1; PH=DS; RN=3; RT=3; SR=0; TI=SMTPD_---.BClm-RN_1520400630; Received: from localhost.localdomain(mailfrom:ligs@dtdream.com fp:222.128.6.212) by smtp.aliyun-inc.com(10.147.42.135); Wed, 07 Mar 2018 13:30:31 +0800 From: Guoshuai Li To: ovs-dev@openvswitch.org Date: Wed, 7 Mar 2018 13:30:16 +0800 Message-Id: <20180307053016.11856-1-ligs@dtdream.com> X-Mailer: git-send-email 2.13.2.windows.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] ovn-nb/sbctl: add inactivity probe in ovn-nb/sbctl set-connection X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Dong Jun This patch can set inactivity probe for connection by command ovn-nbctl set-connection inactivity_probe=30000 ptcp:6641:0.0.0.0 ovn-sbctl set-connection inactivity_probe=30000 ptcp:6642:0.0.0.0 Signed-off-by: Guoshuai Li --- ovn/utilities/ovn-nbctl.8.xml | 2 +- ovn/utilities/ovn-nbctl.c | 28 ++++++++++++++++++++++++---- ovn/utilities/ovn-sbctl.c | 33 ++++++++++++++++++++++++++------- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.8.xml b/ovn/utilities/ovn-nbctl.8.xml index 7f4b3aba8..c2373c5bf 100644 --- a/ovn/utilities/ovn-nbctl.8.xml +++ b/ovn/utilities/ovn-nbctl.8.xml @@ -866,7 +866,7 @@ Deletes the configured connection(s). -
set-connection target...
+
set-connection inactivity_probe target...
Sets the configured manager target or targets.
diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 80fb97cd4..e25275bc9 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -446,7 +446,8 @@ DHCP Options commands:\n\ Connection commands:\n\ get-connection print the connections\n\ del-connection delete the connections\n\ - set-connection TARGET... set the list of connections to TARGET...\n\ + set-connection [INACTIVITY_PROBE] TARGET...\n\ + set the list of connections to TARGET...\n\ \n\ SSL commands:\n\ get-ssl print the SSL configuration\n\ @@ -3491,6 +3492,7 @@ pre_connection(struct ctl_context *ctx) { ovsdb_idl_add_column(ctx->idl, &nbrec_nb_global_col_connections); ovsdb_idl_add_column(ctx->idl, &nbrec_connection_col_target); + ovsdb_idl_add_column(ctx->idl, &nbrec_connection_col_inactivity_probe); } static void @@ -3506,7 +3508,16 @@ cmd_get_connection(struct ctl_context *ctx) svec_init(&targets); NBREC_CONNECTION_FOR_EACH(conn, ctx->idl) { - svec_add(&targets, conn->target); + if (conn->n_inactivity_probe) { + char *s; + s = xasprintf("inactivity_probe=%"PRId64" %s", + conn->inactivity_probe[0], + conn->target); + svec_add(&targets, s); + free(s); + } else { + svec_add(&targets, conn->target); + } } svec_sort_unique(&targets); @@ -3544,17 +3555,25 @@ insert_connections(struct ctl_context *ctx, char *targets[], size_t n) const struct nbrec_nb_global *nb_global = nbrec_nb_global_first(ctx->idl); struct nbrec_connection **connections; size_t i, conns=0; + int64_t inactivity_probe = 0; /* Insert each connection in a new row in Connection table. */ connections = xmalloc(n * sizeof *connections); for (i = 0; i < n; i++) { - if (stream_verify_name(targets[i]) && + if (!strncmp(targets[i], "inactivity_probe=", 17)) { + inactivity_probe = (int64_t)atoll(targets[i] + 17); + continue; + } else if (stream_verify_name(targets[i]) && pstream_verify_name(targets[i])) { VLOG_WARN("target type \"%s\" is possibly erroneous", targets[i]); } connections[conns] = nbrec_connection_insert(ctx->txn); nbrec_connection_set_target(connections[conns], targets[i]); + if (inactivity_probe) { + nbrec_connection_set_inactivity_probe(connections[conns], + &inactivity_probe, 1); + } conns++; } @@ -4065,7 +4084,8 @@ static const struct ctl_command_syntax nbctl_commands[] = { /* Connection commands. */ {"get-connection", 0, 0, "", pre_connection, cmd_get_connection, NULL, "", RO}, {"del-connection", 0, 0, "", pre_connection, cmd_del_connection, NULL, "", RW}, - {"set-connection", 1, INT_MAX, "TARGET...", pre_connection, cmd_set_connection, + {"set-connection", 1, INT_MAX, "[INACTIVITY_PROBE] TARGET...", + pre_connection, cmd_set_connection, NULL, "", RW}, /* SSL commands. */ diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c index c2fd18338..a53b36561 100644 --- a/ovn/utilities/ovn-sbctl.c +++ b/ovn/utilities/ovn-sbctl.c @@ -317,7 +317,8 @@ Logical flow commands:\n\ Connection commands:\n\ get-connection print the connections\n\ del-connection delete the connections\n\ - set-connection TARGET... set the list of connections to TARGET...\n\ + set-connection [INACTIVITY_PROBE] [READ/WRITE] [ROLE] TARGET...\n\ + set the list of connections to TARGET...\n\ \n\ SSL commands:\n\ get-ssl print the SSL configuration\n\ @@ -954,6 +955,7 @@ pre_connection(struct ctl_context *ctx) ovsdb_idl_add_column(ctx->idl, &sbrec_connection_col_target); ovsdb_idl_add_column(ctx->idl, &sbrec_connection_col_read_only); ovsdb_idl_add_column(ctx->idl, &sbrec_connection_col_role); + ovsdb_idl_add_column(ctx->idl, &sbrec_connection_col_inactivity_probe); } static void @@ -971,10 +973,17 @@ cmd_get_connection(struct ctl_context *ctx) SBREC_CONNECTION_FOR_EACH(conn, ctx->idl) { char *s; - s = xasprintf("%s role=\"%s\" %s", - conn->read_only ? "read-only" : "read-write", - conn->role, - conn->target); + if (conn->n_inactivity_probe) { + s = xasprintf("%s role=\"%s\" inactivity_probe=%"PRId64" %s", + conn->read_only ? "read-only" : "read-write", + conn->role, conn->inactivity_probe[0], + conn->target); + } else { + s = xasprintf("%s role=\"%s\" %s", + conn->read_only ? "read-only" : "read-write", + conn->role, + conn->target); + } svec_add(&targets, s); free(s); } @@ -1016,6 +1025,7 @@ insert_connections(struct ctl_context *ctx, char *targets[], size_t n) size_t i, conns=0; bool read_only = false; char *role = ""; + int64_t inactivity_probe = 0; /* Insert each connection in a new row in Connection table. */ connections = xmalloc(n * sizeof *connections); @@ -1029,6 +1039,9 @@ insert_connections(struct ctl_context *ctx, char *targets[], size_t n) } else if (!strncmp(targets[i], "role=", 5)) { role = targets[i] + 5; continue; + } else if (!strncmp(targets[i], "inactivity_probe=", 17)) { + inactivity_probe = (int64_t)atoll(targets[i] + 17); + continue; } else if (stream_verify_name(targets[i]) && pstream_verify_name(targets[i])) { VLOG_WARN("target type \"%s\" is possibly erroneous", targets[i]); @@ -1038,6 +1051,10 @@ insert_connections(struct ctl_context *ctx, char *targets[], size_t n) sbrec_connection_set_target(connections[conns], targets[i]); sbrec_connection_set_read_only(connections[conns], read_only); sbrec_connection_set_role(connections[conns], role); + if (inactivity_probe) { + sbrec_connection_set_inactivity_probe(connections[conns], + &inactivity_probe, 1); + } conns++; } @@ -1426,8 +1443,10 @@ static const struct ctl_command_syntax sbctl_commands[] = { /* Connection commands. */ {"get-connection", 0, 0, "", pre_connection, cmd_get_connection, NULL, "", RO}, {"del-connection", 0, 0, "", pre_connection, cmd_del_connection, NULL, "", RW}, - {"set-connection", 1, INT_MAX, "TARGET...", pre_connection, cmd_set_connection, - NULL, "", RW}, + {"set-connection", 1, INT_MAX, + "[INACTIVITY_PROBE] [READ/WRITE] [ROLE] TARGET...", + pre_connection, cmd_set_connection, + NULL, "", RW}, /* SSL commands. */ {"get-ssl", 0, 0, "", pre_cmd_get_ssl, cmd_get_ssl, NULL, "", RO},