2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 01:51:26 +00:00

ctl-option: add --inactivity-probe= option in set targets commands

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>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Guoshuai Li 2018-03-12 19:23:44 +08:00 committed by Ben Pfaff
parent 6a6b706065
commit 3ffed5cb90
9 changed files with 102 additions and 15 deletions

View File

@ -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>

View File

@ -455,6 +455,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\
@ -3501,6 +3502,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
@ -3554,6 +3556,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);
@ -3565,6 +3569,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++;
}
@ -4076,7 +4085,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},

View File

@ -326,6 +326,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\
@ -964,6 +965,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
@ -1026,6 +1028,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);
@ -1048,6 +1052,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++;
}
@ -1437,7 +1446,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},

View File

@ -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

View File

@ -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

View 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

View File

@ -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

View File

@ -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\
@ -1855,6 +1857,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
@ -1915,18 +1918,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;
@ -1948,7 +1957,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);
}
@ -2024,6 +2033,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
@ -2075,10 +2085,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);
@ -2088,6 +2101,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. */
@ -2103,7 +2120,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
@ -2842,7 +2859,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,
@ -2854,7 +2871,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},

View File

@ -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},
};