summaryrefslogtreecommitdiff
path: root/ofproto/ofproto-dpif.c
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@samsung.com>2019-06-24 17:20:17 +0300
committerIlya Maximets <i.maximets@samsung.com>2019-07-02 12:24:47 +0300
commitf87c1357067e1f67087eab4af42e5aaf7bf6cc8e (patch)
tree40126b367295f960936e949b52fdcc616ee686ff /ofproto/ofproto-dpif.c
parent7eef7001ab2c0d8db869690bb7d820e88738ca66 (diff)
downloadopenvswitch-f87c1357067e1f67087eab4af42e5aaf7bf6cc8e.tar.gz
vswitchd: Always cleanup userspace datapath.
'netdev' datapath is implemented within ovs-vswitchd process and can not exist without it, so it should be gracefully terminated with a full cleanup of resources upon ovs-vswitchd exit. This change forces dpif cleanup for 'netdev' datapath regardless of passing '--cleanup' to 'ovs-appctl exit'. Such solution allowes to not pass this additional option everytime for userspace datapath installations and also allowes to not terminate system datapath in setups where both datapaths runs at the same time. The main part is that dpif_port_del() will lead to netdev_close() and subsequent netdev_class->destroy(dev) which will stop HW NICs and free their resources. For vhost-user interfaces it will invoke vhost driver unregistering with a properly closed vhost-user connection. For upcoming AF_XDP netdev this will allow to gracefully destroy xdp sockets and unload xdp programs from linux interfaces. Another important thing is that port deletion will also trigger flushing of flows offloaded to HW NICs. Exception made for 'internal' ports that could have user ip/route configuration. These ports will not be removed without '--cleanup'. This change fixes OVS disappearing from the DPDK point of view (keeping HW NICs improperly configured, sudden closing of vhost-user connections) and will help with linux devices clearing with upcoming AF_XDP netdev support. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Tested-by: William Tu <u9012063@gmail.com> Acked-by: Flavio Leitner <fbl@sysclose.org> Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ofproto/ofproto-dpif.c')
-rw-r--r--ofproto/ofproto-dpif.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index cbeb6776f..751535249 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1965,6 +1965,7 @@ port_destruct(struct ofport *port_, bool del)
struct ofport_dpif *port = ofport_dpif_cast(port_);
struct ofproto_dpif *ofproto = ofproto_dpif_cast(port->up.ofproto);
const char *devname = netdev_get_name(port->up.netdev);
+ const char *netdev_type = netdev_get_type(port->up.netdev);
char namebuf[NETDEV_VPORT_NAME_BUFSIZE];
const char *dp_port_name;
@@ -1973,6 +1974,13 @@ port_destruct(struct ofport *port_, bool del)
xlate_ofport_remove(port);
xlate_txn_commit();
+ if (!del && strcmp(netdev_type,
+ ofproto_port_open_type(port->up.ofproto, "internal"))) {
+ /* Check if datapath requires removal of attached ports. Avoid
+ * removal of 'internal' ports to preserve user ip/route settings. */
+ del = dpif_cleanup_required(ofproto->backer->dpif);
+ }
+
dp_port_name = netdev_vport_get_dpif_port(port->up.netdev, namebuf,
sizeof namebuf);
if (del && dpif_port_exists(ofproto->backer->dpif, dp_port_name)) {