To adjust the minimum number of connection attempts by ovsdb-server to the cloud controller (to avoid ddos when controller was down and then up)
Was carefully tested within product's codestack Signed-off-by: Anton Pryima <apryim...@cable.comcast.com> diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index c8ce5362e..f7c5f17c1 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -1306,6 +1306,16 @@ jsonrpc_session_set_max_backoff(struct jsonrpc_session *s, int max_backoff) reconnect_set_backoff(s->reconnect, 0, max_backoff); } +/* Sets 'min_backoff and 'max_backoff' as the minimum and maximum time, + * in milliseconds, to wait after a connection attempt fails before attempting + * to connect again. */ +void +jsonrpc_session_set_backoff(struct jsonrpc_session *s, int min_backoff, + int max_backoff) +{ + reconnect_set_backoff(s->reconnect, min_backoff, max_backoff); +} + /* Sets the "probe interval" for 's' to 'probe_interval', in milliseconds. If * this is zero, it disables the connection keepalive feature. Otherwise, if * 's' is idle for 'probe_interval' milliseconds then 's' will send an echo diff --git a/lib/jsonrpc.h b/lib/jsonrpc.h index 2aa97d3fe..cece97f3b 100644 --- a/lib/jsonrpc.h +++ b/lib/jsonrpc.h @@ -141,6 +141,8 @@ void jsonrpc_session_reset_backoff(struct jsonrpc_session *); void jsonrpc_session_set_max_backoff(struct jsonrpc_session *, int max_backoff); +void jsonrpc_session_set_backoff(struct jsonrpc_session *, + int min_backoff, int max_backoff); void jsonrpc_session_set_probe_interval(struct jsonrpc_session *, int probe_interval); void jsonrpc_session_set_dscp(struct jsonrpc_session *, diff --git a/lib/reconnect.c b/lib/reconnect.c index a929ddfd2..e23763fb8 100644 --- a/lib/reconnect.c +++ b/lib/reconnect.c @@ -551,7 +551,8 @@ reconnect_deadline__(const struct reconnect *fsm) return fsm->state_entered + fsm->backoff; case S_CONNECTING: - return fsm->state_entered + MAX(1000, fsm->backoff); + return fsm->state_entered + MAX(1000, MAX(fsm->min_backoff, + fsm->backoff)); case S_ACTIVE: if (fsm->probe_interval) { diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c index 351c39d8a..8e283bf0c 100644 --- a/ovsdb/jsonrpc-server.c +++ b/ovsdb/jsonrpc-server.c @@ -212,6 +212,7 @@ ovsdb_jsonrpc_default_options(const char *target) { struct ovsdb_jsonrpc_options *options = xzalloc(sizeof *options); options->max_backoff = RECONNECT_DEFAULT_MAX_BACKOFF; + options->min_backoff = RECONNECT_DEFAULT_MIN_BACKOFF; options->probe_interval = (stream_or_pstream_needs_probes(target) ? RECONNECT_DEFAULT_PROBE_INTERVAL : 0); @@ -577,7 +578,8 @@ static void ovsdb_jsonrpc_session_set_options(struct ovsdb_jsonrpc_session *session, const struct ovsdb_jsonrpc_options *options) { - jsonrpc_session_set_max_backoff(session->js, options->max_backoff); + jsonrpc_session_set_backoff(session->js, options->min_backoff, + options->max_backoff); jsonrpc_session_set_probe_interval(session->js, options->probe_interval); jsonrpc_session_set_dscp(session->js, options->dscp); } diff --git a/ovsdb/jsonrpc-server.h b/ovsdb/jsonrpc-server.h index e0653aa39..b157c2860 100644 --- a/ovsdb/jsonrpc-server.h +++ b/ovsdb/jsonrpc-server.h @@ -34,6 +34,7 @@ void ovsdb_jsonrpc_server_destroy(struct ovsdb_jsonrpc_server *); /* Options for a remote. */ struct ovsdb_jsonrpc_options { int max_backoff; /* Maximum reconnection backoff, in msec. */ + int min_backoff; /* Minimum reconnection backoff, in msec. */ int probe_interval; /* Max idle time before probing, in msec. */ bool read_only; /* Only read-only transactions are allowed. */ int dscp; /* Dscp value for manager connections */ diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index b34d97e29..2696643a2 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -948,7 +948,7 @@ add_manager_options(struct shash *remotes, const struct ovsdb_row *row) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); struct ovsdb_jsonrpc_options *options; - long long int max_backoff, probe_interval; + long long int max_backoff, min_backoff, probe_interval; bool read_only; const char *target, *dscp_string, *role; @@ -962,6 +962,9 @@ add_manager_options(struct shash *remotes, const struct ovsdb_row *row) if (ovsdb_util_read_integer_column(row, "max_backoff", &max_backoff)) { options->max_backoff = max_backoff; } + if (ovsdb_util_read_integer_column(row, "min_backoff", &min_backoff)) { + options->min_backoff = min_backoff; + } if (ovsdb_util_read_integer_column(row, "inactivity_probe", &probe_interval)) { options->probe_interval = probe_interval; diff --git a/vswitchd/vswitch.ovsschema b/vswitchd/vswitch.ovsschema index 4873cfde7..457925d91 100644 --- a/vswitchd/vswitch.ovsschema +++ b/vswitchd/vswitch.ovsschema @@ -1,6 +1,6 @@ {"name": "Open_vSwitch", - "version": "8.3.0", - "cksum": "3781850481 26690", + "version": "8.4.0", + "cksum": "542313912 26846", "tables": { "Open_vSwitch": { "columns": { @@ -625,6 +625,10 @@ "type": {"key": {"type": "integer", "minInteger": 1000}, "min": 0, "max": 1}}, + "min_backoff": { + "type": {"key": {"type": "integer", + "minInteger": 1000}, + "min": 0, "max": 1}}, "inactivity_probe": { "type": {"key": "integer", "min": 0, "max": 1}}, "connection_mode": { diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index 026b5e2ca..4ccfe7f55 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -5668,6 +5668,11 @@ ovs-vsctl add-port br0 p0 -- set Interface p0 type=patch options:peer=p1 \ Default is implementation-specific. </column> + <column name="min_backoff"> + Minimum number of milliseconds to wait between connection attempts. + Default is implementation-specific. + </column> + <column name="inactivity_probe"> Maximum number of milliseconds of idle time on connection to the client before sending an inactivity probe message. If Open vSwitch does not _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev