@@ -866,9 +866,11 @@
Deletes the configured connection(s).
</dd>
- <dt><code>set-connection</code> <var>target</var>...</dt>
+ <dt>[<code>--inactivity-probe=</code><var>msecs</var>] <code>set-connection</code> <var>target</var>...</dt>
<dd>
- Sets the configured manager target or targets.
+ Sets the configured manager target or targets. Use
+ <code>--inactivity-probe=</code><var>msecs</var> to override the default
+ idle connection inactivity probe time. Use 0 to disable inactivity probes.
</dd>
</dl>
@@ -446,6 +446,7 @@ DHCP Options commands:\n\
Connection commands:\n\
get-connection print the connections\n\
del-connection delete the connections\n\
+ [--inactivity-probe=MSECS]\n\
set-connection TARGET... set the list of connections to TARGET...\n\
\n\
SSL commands:\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
@@ -3544,6 +3546,8 @@ 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;
+ const char *inactivity_probe = shash_find_data(&ctx->options,
+ "--inactivity-probe");
/* Insert each connection in a new row in Connection table. */
connections = xmalloc(n * sizeof *connections);
@@ -3555,6 +3559,11 @@ insert_connections(struct ctl_context *ctx, char *targets[], size_t n)
connections[conns] = nbrec_connection_insert(ctx->txn);
nbrec_connection_set_target(connections[conns], targets[i]);
+ if (inactivity_probe) {
+ int64_t msecs = atoll(inactivity_probe);
+ nbrec_connection_set_inactivity_probe(connections[conns],
+ &msecs, 1);
+ }
conns++;
}
@@ -4066,7 +4075,7 @@ static const struct ctl_command_syntax nbctl_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},
+ NULL, "--inactivity-probe=", RW},
/* SSL commands. */
{"get-ssl", 0, 0, "", pre_cmd_get_ssl, cmd_get_ssl, NULL, "", RO},
@@ -317,6 +317,7 @@ Logical flow commands:\n\
Connection commands:\n\
get-connection print the connections\n\
del-connection delete the connections\n\
+ [--inactivity-probe=MSECS]\n\
set-connection TARGET... set the list of connections to TARGET...\n\
\n\
SSL commands:\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
@@ -1016,6 +1018,8 @@ insert_connections(struct ctl_context *ctx, char *targets[], size_t n)
size_t i, conns=0;
bool read_only = false;
char *role = "";
+ const char *inactivity_probe = shash_find_data(&ctx->options,
+ "--inactivity-probe");
/* Insert each connection in a new row in Connection table. */
connections = xmalloc(n * sizeof *connections);
@@ -1038,6 +1042,11 @@ 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) {
+ int64_t msecs = atoll(inactivity_probe);
+ sbrec_connection_set_inactivity_probe(connections[conns],
+ &msecs, 1);
+ }
conns++;
}
@@ -1427,7 +1436,7 @@ static const struct ctl_command_syntax sbctl_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},
+ NULL, "--inactivity-probe=", RW},
/* SSL commands. */
{"get-ssl", 0, 0, "", pre_cmd_get_ssl, cmd_get_ssl, NULL, "", RO},
@@ -1345,3 +1345,17 @@ AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
OVN_NBCTL_TEST_STOP
AT_CLEANUP
+
+dnl ---------------------------------------------------------------------
+
+AT_SETUP([ovn-nbctl - connection])
+OVN_NBCTL_TEST_START
+
+AT_CHECK([ovn-nbctl --inactivity-probe=30000 set-connection ptcp:6641:127.0.0.1 punix:$OVS_RUNDIR/ovnnb_db.sock])
+AT_CHECK([ovn-nbctl list connection | grep inactivity_probe], [0], [dnl
+inactivity_probe : 30000
+inactivity_probe : 30000
+])
+
+OVN_NBCTL_TEST_STOP
+AT_CLEANUP
@@ -134,3 +134,17 @@ options : {vtep_logical_switch="l0", vtep_physical_switch="p0"}
OVN_SBCTL_TEST_STOP
AT_CLEANUP
+
+dnl ---------------------------------------------------------------------
+
+AT_SETUP([ovn-sbctl - connection])
+OVN_SBCTL_TEST_START
+
+AT_CHECK([ovn-sbctl --inactivity-probe=30000 set-connection ptcp:6641:127.0.0.1 punix:$OVS_RUNDIR/ovnsb_db.sock])
+AT_CHECK([ovn-sbctl list connection | grep inactivity_probe], [0], [dnl
+inactivity_probe : 30000
+inactivity_probe : 30000
+])
+
+OVN_SBCTL_TEST_STOP
+AT_CLEANUP
\ No newline at end of file
@@ -487,6 +487,9 @@ AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
[get-controller br0],
[set-controller br0 tcp:8.9.10.11 tcp:5.4.3.2],
+ [get-controller br0],
+
+ [--inactivity-probe=30000 set-controller br0 tcp:1.2.3.4],
[get-controller br0])], [0], [
@@ -495,6 +498,8 @@ tcp:4.5.6.7
tcp:5.4.3.2\ntcp:8.9.10.11
+
+tcp:1.2.3.4
])
OVS_VSCTL_CLEANUP
AT_CLEANUP
@@ -660,6 +665,8 @@ AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
[get-manager],
[set-manager tcp:8.9.10.11 tcp:5.4.3.2],
[get-manager],
+ [--inactivity-probe=30000 set-manager tcp:1.2.3.4],
+ [get-manager],
[del-manager],
[get-manager])], [0], [
@@ -668,6 +675,8 @@ tcp:4.5.6.7
tcp:5.4.3.2\ntcp:8.9.10.11
+tcp:1.2.3.4
+
])
OVS_VSCTL_CLEANUP
@@ -906,6 +906,8 @@ AT_CHECK([RUN_VTEP_CTL_TOGETHER(
[get-manager],
[set-manager tcp:8.9.10.11 tcp:5.4.3.2],
[get-manager],
+ [--inactivity-probe=30000 set-manager tcp:1.2.3.4],
+ [get-manager],
[del-manager],
[get-manager])], [0], [
@@ -914,6 +916,8 @@ tcp:4.5.6.7
tcp:5.4.3.2\ntcp:8.9.10.11
+tcp:1.2.3.4
+
], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
@@ -392,6 +392,7 @@ Interface commands (a bond consists of multiple interfaces):\n\
Controller commands:\n\
get-controller BRIDGE print the controllers for BRIDGE\n\
del-controller BRIDGE delete the controllers for BRIDGE\n\
+ [--inactivity-probe=MSECS]\n\
set-controller BRIDGE TARGET... set the controllers for BRIDGE\n\
get-fail-mode BRIDGE print the fail-mode for BRIDGE\n\
del-fail-mode BRIDGE delete the fail-mode for BRIDGE\n\
@@ -400,6 +401,7 @@ Controller commands:\n\
Manager commands:\n\
get-manager print the managers\n\
del-manager delete the managers\n\
+ [--inactivity-probe=MSECS]\n\
set-manager TARGET... set the list of managers to TARGET...\n\
\n\
SSL commands:\n\
@@ -1854,6 +1856,7 @@ pre_controller(struct ctl_context *ctx)
pre_get_info(ctx);
ovsdb_idl_add_column(ctx->idl, &ovsrec_controller_col_target);
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_controller_col_inactivity_probe);
}
static void
@@ -1914,18 +1917,24 @@ cmd_del_controller(struct ctl_context *ctx)
}
static struct ovsrec_controller **
-insert_controllers(struct ovsdb_idl_txn *txn, char *targets[], size_t n)
+insert_controllers(struct ctl_context *ctx, char *targets[], size_t n)
{
struct ovsrec_controller **controllers;
size_t i;
+ const char *inactivity_probe = shash_find_data(&ctx->options,
+ "--inactivity-probe");
controllers = xmalloc(n * sizeof *controllers);
for (i = 0; i < n; i++) {
if (vconn_verify_name(targets[i]) && pvconn_verify_name(targets[i])) {
VLOG_WARN("target type \"%s\" is possibly erroneous", targets[i]);
}
- controllers[i] = ovsrec_controller_insert(txn);
+ controllers[i] = ovsrec_controller_insert(ctx->txn);
ovsrec_controller_set_target(controllers[i], targets[i]);
+ if (inactivity_probe) {
+ int64_t msecs = atoll(inactivity_probe);
+ ovsrec_controller_set_inactivity_probe(controllers[i], &msecs, 1);
+ }
}
return controllers;
@@ -1947,7 +1956,7 @@ cmd_set_controller(struct ctl_context *ctx)
delete_controllers(br->controller, br->n_controller);
n = ctx->argc - 2;
- controllers = insert_controllers(ctx->txn, &ctx->argv[2], n);
+ controllers = insert_controllers(ctx, &ctx->argv[2], n);
ovsrec_bridge_set_controller(br, controllers, n);
free(controllers);
}
@@ -2023,6 +2032,7 @@ pre_manager(struct ctl_context *ctx)
{
ovsdb_idl_add_column(ctx->idl, &ovsrec_open_vswitch_col_manager_options);
ovsdb_idl_add_column(ctx->idl, &ovsrec_manager_col_target);
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_manager_col_inactivity_probe);
}
static void
@@ -2074,10 +2084,13 @@ cmd_del_manager(struct ctl_context *ctx)
}
static void
-insert_managers(struct vsctl_context *vsctl_ctx, char *targets[], size_t n)
+insert_managers(struct vsctl_context *vsctl_ctx, char *targets[], size_t n,
+ struct shash *options)
{
struct ovsrec_manager **managers;
size_t i;
+ const char *inactivity_probe = shash_find_data(options,
+ "--inactivity-probe");
/* Insert each manager in a new row in Manager table. */
managers = xmalloc(n * sizeof *managers);
@@ -2087,6 +2100,10 @@ insert_managers(struct vsctl_context *vsctl_ctx, char *targets[], size_t n)
}
managers[i] = ovsrec_manager_insert(vsctl_ctx->base.txn);
ovsrec_manager_set_target(managers[i], targets[i]);
+ if (inactivity_probe) {
+ int64_t msecs = atoll(inactivity_probe);
+ ovsrec_manager_set_inactivity_probe(managers[i], &msecs, 1);
+ }
}
/* Store uuids of new Manager rows in 'manager_options' column. */
@@ -2102,7 +2119,7 @@ cmd_set_manager(struct ctl_context *ctx)
verify_managers(vsctl_ctx->ovs);
delete_managers(vsctl_ctx->ovs);
- insert_managers(vsctl_ctx, &ctx->argv[1], n);
+ insert_managers(vsctl_ctx, &ctx->argv[1], n, &ctx->options);
}
static void
@@ -2841,7 +2858,7 @@ static const struct ctl_command_syntax vsctl_commands[] = {
{"del-controller", 1, 1, "BRIDGE", pre_controller, cmd_del_controller,
NULL, "", RW},
{"set-controller", 1, INT_MAX, "BRIDGE TARGET...", pre_controller,
- cmd_set_controller, NULL, "", RW},
+ cmd_set_controller, NULL, "--inactivity-probe=", RW},
{"get-fail-mode", 1, 1, "BRIDGE", pre_get_info, cmd_get_fail_mode, NULL,
"", RO},
{"del-fail-mode", 1, 1, "BRIDGE", pre_get_info, cmd_del_fail_mode, NULL,
@@ -2853,7 +2870,7 @@ static const struct ctl_command_syntax vsctl_commands[] = {
{"get-manager", 0, 0, "", pre_manager, cmd_get_manager, NULL, "", RO},
{"del-manager", 0, 0, "", pre_manager, cmd_del_manager, NULL, "", RW},
{"set-manager", 1, INT_MAX, "TARGET...", pre_manager, cmd_set_manager,
- NULL, "", RW},
+ NULL, "--inactivity-probe=", RW},
/* SSL commands. */
{"get-ssl", 0, 0, "", pre_cmd_get_ssl, cmd_get_ssl, NULL, "", RO},
@@ -316,6 +316,7 @@ VTEP commands:\n\
Manager commands:\n\
get-manager print the managers\n\
del-manager delete the managers\n\
+ [--inactivity-probe=MSECS]\n\
set-manager TARGET... set the list of managers to TARGET...\n\
\n\
Physical Switch commands:\n\
@@ -2097,6 +2098,7 @@ pre_manager(struct ctl_context *ctx)
{
ovsdb_idl_add_column(ctx->idl, &vteprec_global_col_managers);
ovsdb_idl_add_column(ctx->idl, &vteprec_manager_col_target);
+ ovsdb_idl_add_column(ctx->idl, &vteprec_manager_col_inactivity_probe);
}
static void
@@ -2149,10 +2151,13 @@ cmd_del_manager(struct ctl_context *ctx)
}
static void
-insert_managers(struct vtep_ctl_context *vtepctl_ctx, char *targets[], size_t n)
+insert_managers(struct vtep_ctl_context *vtepctl_ctx, char *targets[],
+ size_t n, struct shash *options)
{
struct vteprec_manager **managers;
size_t i;
+ const char *inactivity_probe = shash_find_data(options,
+ "--inactivity-probe");
/* Insert each manager in a new row in Manager table. */
managers = xmalloc(n * sizeof *managers);
@@ -2162,6 +2167,10 @@ insert_managers(struct vtep_ctl_context *vtepctl_ctx, char *targets[], size_t n)
}
managers[i] = vteprec_manager_insert(vtepctl_ctx->base.txn);
vteprec_manager_set_target(managers[i], targets[i]);
+ if (inactivity_probe) {
+ int64_t msecs = atoll(inactivity_probe);
+ vteprec_manager_set_inactivity_probe(managers[i], &msecs, 1);
+ }
}
/* Store uuids of new Manager rows in 'managers' column. */
@@ -2177,7 +2186,7 @@ cmd_set_manager(struct ctl_context *ctx)
verify_managers(vtepctl_ctx->vtep_global);
delete_managers(vtepctl_ctx);
- insert_managers(vtepctl_ctx, &ctx->argv[1], n);
+ insert_managers(vtepctl_ctx, &ctx->argv[1], n, &ctx->options);
}
/* Parameter commands. */
@@ -2491,8 +2500,8 @@ static const struct ctl_command_syntax vtep_commands[] = {
/* Manager commands. */
{"get-manager", 0, 0, NULL, pre_manager, cmd_get_manager, NULL, "", RO},
{"del-manager", 0, 0, NULL, pre_manager, cmd_del_manager, NULL, "", RW},
- {"set-manager", 1, INT_MAX, NULL, pre_manager, cmd_set_manager, NULL, "",
- RW},
+ {"set-manager", 1, INT_MAX, NULL, pre_manager, cmd_set_manager, NULL,
+ "--inactivity-probe=", RW},
{NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, RO},
};
This patch can set inactivity probe for connection by command: ovs-vsctl --inactivity-probe=30000 set-manager tcp:<CONTROLLER IP>:6640 ovs-vsctl --inactivity-probe=30000 set-controller tcp:<CONTROLLER IP>:6641 vtep-ctl --inactivity-probe=30000 set-manager tcp:<CONTROLLER IP>:6640 ovn-nbctl --inactivity-probe=30000 set-connection ptcp:6641:0.0.0.0 ovn-sbctl --inactivity-probe=30000 set-connection ptcp:6642:0.0.0.0 Signed-off-by: Guoshuai Li <ligs@dtdream.com> --- ovn/utilities/ovn-nbctl.8.xml | 6 ++++-- ovn/utilities/ovn-nbctl.c | 11 ++++++++++- ovn/utilities/ovn-sbctl.c | 11 ++++++++++- tests/ovn-nbctl.at | 14 ++++++++++++++ tests/ovn-sbctl.at | 14 ++++++++++++++ tests/ovs-vsctl.at | 9 +++++++++ tests/vtep-ctl.at | 4 ++++ utilities/ovs-vsctl.c | 31 ++++++++++++++++++++++++------- vtep/vtep-ctl.c | 17 +++++++++++++---- 9 files changed, 102 insertions(+), 15 deletions(-)