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

connmgr: Fix ofconn configuration on vswitchd startup.

ofconn connection parameters, such as probe_interval and max_backoff,
are always set to their default values when vswitchd starts up even if
the user has configured these to be something different in ovsdb:

  $ ovs-vsctl set controller UUID inactivity_probe=9000

  $ journalctl -u ovs-vswitchd.service | grep "inactivity"
  ovs|10895|rconn|DBG|dp1<->tcp:127.0.0.1:6653: idle 9 seconds,
  sending inactivity probe

  $ systemctl restart openvswitch-switch.service

  $ journalctl -u ovs-vswitchd.service | grep "inactivity"
  ovs|00848|rconn|DBG|dp1<->tcp:127.0.0.1:6653: idle 5 seconds,
  sending inactivity probe

This bug was introduced by commit a0baa7df (connmgr: Make treatment of
active and passive connections more uniform.).

This happens because ofservice_reconfigure() loops over each
ofconn in ofservice->conns and calls ofconn_reconfigure() on it
to set the configuration parameters, however when ofservice_reconfigure()
is called from ofservice_create(), ofservice->conns hasn't been populated
yet so ofconn_reconfigure() is never called.

This commit moves the ofservice_reconfigure() call to ofconn_create()
where ofservice->conns is populated.

This commit also removes the hardcoded default values for
inactivity_probe (5s) and max_backoff (8s) on initial creation
of the ofservice, as these config values are available from the
ofproto_controller struct c.

Signed-off-by: Brad Cowie <brad@faucet.nz>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Simon Horman <horms@ovn.org>
This commit is contained in:
Brad Cowie 2023-09-28 21:44:24 +00:00 committed by Simon Horman
parent 13dde11310
commit 155f632e71
2 changed files with 32 additions and 7 deletions

View File

@ -1209,7 +1209,7 @@ ofconn_create(struct ofservice *ofservice, struct rconn *rconn,
hmap_init(&ofconn->bundles);
ofconn->next_bundle_expiry_check = time_msec() + BUNDLE_EXPIRY_INTERVAL;
ofconn_set_rate_limit(ofconn, settings->rate_limit, settings->burst_limit);
ofservice_reconfigure(ofservice, settings);
ovs_mutex_unlock(&ofproto_mutex);
}
@ -1915,10 +1915,7 @@ connmgr_count_hidden_rules(const struct connmgr *mgr)
}
/* Creates a new ofservice for 'target' in 'mgr'. Returns 0 if successful,
* otherwise a positive errno value.
*
* ofservice_reconfigure() must be called to fully configure the new
* ofservice. */
* otherwise a positive errno value. */
static void
ofservice_create(struct connmgr *mgr, const char *target,
const struct ofproto_controller *c)
@ -1928,7 +1925,8 @@ ofservice_create(struct connmgr *mgr, const char *target,
struct rconn *rconn = NULL;
if (!vconn_verify_name(target)) {
char *name = ofconn_make_name(mgr, target);
rconn = rconn_create(5, 8, c->dscp, c->allowed_versions);
rconn = rconn_create(c->probe_interval, c->max_backoff,
c->dscp, c->allowed_versions);
rconn_connect(rconn, target, name);
free(name);
} else if (!pvconn_verify_name(target)) {
@ -1951,7 +1949,6 @@ ofservice_create(struct connmgr *mgr, const char *target,
ofservice->rconn = rconn;
ofservice->pvconn = pvconn;
ofservice->s = *c;
ofservice_reconfigure(ofservice, c);
VLOG_INFO("%s: added %s controller \"%s\"",
mgr->name, ofconn_type_to_string(ofservice->type), target);

View File

@ -6720,3 +6720,31 @@ recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0806),arp(tip=172.31.1
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([ofproto - configure inactivity probe interval])
# Set 6 second inactivity probe interval (default is 5 seconds).
OVS_VSWITCHD_START([set-controller br0 unix:testcontroller \
-- set Controller br0 inactivity_probe=6000], [], [],
[-vfile:rconn:dbg])
# Start test openflow controller.
AT_CHECK([ovs-testcontroller -vsyslog:off --detach --no-chdir --pidfile punix:testcontroller],
[0], [ignore])
on_exit 'kill `cat ovs-testcontroller.pid`'
OVS_WAIT_UNTIL([test -e testcontroller])
# After 6 seconds of inactivity there should be a log message.
OVS_WAIT_UNTIL([grep "idle 6 seconds, sending inactivity probe" ovs-vswitchd.log])
# Restart ovs-vswitchd with an empty ovs-vswitchd log file.
OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])
mv ovs-vswitchd.log ovs-vswitchd_1.log
AT_CHECK([ovs-vswitchd --enable-dummy --disable-system --disable-system-route --detach \
--no-chdir --pidfile --log-file -vfile:rconn:dbg -vvconn -vofproto_dpif -vunixctl],
[0], [], [stderr])
# After 6 seconds of inactivity there should be a log message.
OVS_WAIT_UNTIL([grep "idle 6 seconds, sending inactivity probe" ovs-vswitchd.log])
OVS_VSWITCHD_STOP(["/br0<->unix:testcontroller: connection failed/d"])
AT_CLEANUP