diff options
author | Andy Zhou <azhou@ovn.org> | 2017-04-24 18:55:04 -0700 |
---|---|---|
committer | Andy Zhou <azhou@ovn.org> | 2017-05-03 13:12:03 -0700 |
commit | fe13ccdca6a223eec605041f77acfabd21e1fcb2 (patch) | |
tree | 81f886e8130cf26fefc4ded2d4d5f06e8b29ad72 /ofproto | |
parent | 401b70d632729555b555040e4cee13a5ffc5ed3d (diff) | |
download | openvswitch-fe13ccdca6a223eec605041f77acfabd21e1fcb2.tar.gz |
vswitchd: Add --cleanup option to the 'appctl exit' command
'appctl exit' stops the running vswitchd daemon, without releasing
the datapath resources (such as bridges and ports) that vswitchd
has created. This is expected when vswitchd is to be relaunched, to
reduce the perturbation of exiting traffic and connections.
However, when vswitchd is intended to be shutdown permanently, it
is desirable not to leak datapath resources. In theory, this can be
achieved by removing the corresponding configurations from
OVSDB before shutting down vswitchd. However it is not always
possible in practice. Sometimes it is convenient and robust for
vswitchd to release all datapath resources that it has configured.
Add 'appctl exit --cleanup' option for this use case.
Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
Diffstat (limited to 'ofproto')
-rw-r--r-- | ofproto/ofproto-dpif.c | 11 | ||||
-rw-r--r-- | ofproto/ofproto-provider.h | 2 | ||||
-rw-r--r-- | ofproto/ofproto.c | 2 |
3 files changed, 9 insertions, 6 deletions
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index bd45be5ac..9c3a5673c 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -645,7 +645,7 @@ dealloc(struct ofproto *ofproto_) } static void -close_dpif_backer(struct dpif_backer *backer) +close_dpif_backer(struct dpif_backer *backer, bool del) { ovs_assert(backer->refcount > 0); @@ -661,6 +661,9 @@ close_dpif_backer(struct dpif_backer *backer) shash_find_and_delete(&all_dpif_backers, backer->type); free(backer->type); free(backer->dp_version_string); + if (del) { + dpif_delete(backer->dpif); + } dpif_close(backer->dpif); id_pool_destroy(backer->meter_ids); free(backer); @@ -773,7 +776,7 @@ open_dpif_backer(const char *type, struct dpif_backer **backerp) if (error) { VLOG_ERR("failed to listen on datapath of type %s: %s", type, ovs_strerror(error)); - close_dpif_backer(backer); + close_dpif_backer(backer, false); return error; } @@ -1525,7 +1528,7 @@ add_internal_flows(struct ofproto_dpif *ofproto) } static void -destruct(struct ofproto *ofproto_) +destruct(struct ofproto *ofproto_, bool del) { struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_); struct ofproto_async_msg *am; @@ -1578,7 +1581,7 @@ destruct(struct ofproto *ofproto_) seq_destroy(ofproto->ams_seq); - close_dpif_backer(ofproto->backer); + close_dpif_backer(ofproto->backer, del); } static int diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h index 688a9e5d3..9dc73c482 100644 --- a/ofproto/ofproto-provider.h +++ b/ofproto/ofproto-provider.h @@ -829,7 +829,7 @@ struct ofproto_class { */ struct ofproto *(*alloc)(void); int (*construct)(struct ofproto *ofproto); - void (*destruct)(struct ofproto *ofproto); + void (*destruct)(struct ofproto *ofproto, bool del); void (*dealloc)(struct ofproto *ofproto); /* Performs any periodic activity required by 'ofproto'. It should: diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 32b5b303b..d5410fd1b 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1649,7 +1649,7 @@ ofproto_destroy(struct ofproto *p, bool del) free(usage); } - p->ofproto_class->destruct(p); + p->ofproto_class->destruct(p, del); /* We should not postpone this because it involves deleting a listening * socket which we may want to reopen soon. 'connmgr' may be used by other |