diff options
author | Flavio Leitner <fbl@sysclose.org> | 2018-04-19 14:09:38 -0300 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-05-09 15:02:48 -0700 |
commit | 7fdd20824e40e381829d60b1c4cd562dec030416 (patch) | |
tree | 05e1b2e3d9bfb5047f38cf0203961636d66b9d19 /ofproto/connmgr.c | |
parent | 9cce7e71ec41eb726fd522e6bf943eee58444f87 (diff) | |
download | openvswitch-7fdd20824e40e381829d60b1c4cd562dec030416.tar.gz |
ofproto: Allow bundle idle timeout to be configured.
In some cases 10 seconds might be too much time and in
other cases it might be too little.
The OpenFlow spec mandates that it should wait at least one
second, so enforce that as the minimum acceptable value.
Signed-off-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ofproto/connmgr.c')
-rw-r--r-- | ofproto/connmgr.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c index 964b8c8d8..f78b4c5ff 100644 --- a/ofproto/connmgr.c +++ b/ofproto/connmgr.c @@ -37,6 +37,7 @@ #include "openvswitch/poll-loop.h" #include "openvswitch/rconn.h" #include "openvswitch/shash.h" +#include "sat-math.h" #include "simap.h" #include "stream.h" #include "timeval.h" @@ -138,10 +139,11 @@ struct ofconn { /* vswitchd/ovs-vswitchd.8.in documents the value of BUNDLE_IDLE_LIFETIME in * seconds. That documentation must be kept in sync with the value below. */ -enum { - BUNDLE_EXPIRY_INTERVAL = 1000, /* Check bundle expiry every 1 sec. */ - BUNDLE_IDLE_TIMEOUT = 10000, /* Expire idle bundles after 10 seconds. */ -}; +#define BUNDLE_EXPIRY_INTERVAL 1000 /* Check bundle expiry every 1 sec. */ +#define BUNDLE_IDLE_TIMEOUT_DEFAULT 10000 /* Expire idle bundles after + * 10 seconds. */ + +static unsigned int bundle_idle_timeout = BUNDLE_IDLE_TIMEOUT_DEFAULT; static struct ofconn *ofconn_create(struct connmgr *, struct rconn *, enum ofconn_type, bool enable_async_msgs) @@ -469,6 +471,18 @@ ofconn_get_ofproto(const struct ofconn *ofconn) { return ofconn->connmgr->ofproto; } + +/* Sets the bundle idle timeout to 'timeout' seconds, interpreting 0 as + * requesting the default timeout. + * + * The OpenFlow spec mandates the timeout to be at least one second; . */ +void +connmgr_set_bundle_idle_timeout(unsigned timeout) +{ + bundle_idle_timeout = (timeout + ? sat_mul(timeout, 1000) + : BUNDLE_IDLE_TIMEOUT_DEFAULT); +} /* OpenFlow configuration. */ @@ -1247,7 +1261,7 @@ static void bundle_remove_expired(struct ofconn *ofconn, long long int now) { struct ofp_bundle *b, *next; - long long int limit = now - BUNDLE_IDLE_TIMEOUT; + long long int limit = now - bundle_idle_timeout; HMAP_FOR_EACH_SAFE (b, next, node, &ofconn->bundles) { if (b->used <= limit) { |