[ovs-dev] [PATCH v2] tnl-ports: Remove netdevs in netdev_hash when deleted

fukaige fukaige at huawei.com
Wed Jun 14 05:44:37 UTC 2017


Start a virtual machine with its backend tap device attached to a brought up linux bridge.
If we delete the linux bridge when vm is still running, we'll get the following error when
trying to create a ovs bridge with the same name.

The reason is that ovs-router subsystem add the linux bridge into netdev_shash, but does
not remove it when the bridge is deleted in the situation. When the bridge is deleted, ovs
will receive a RTM_DELLINK msg, take this chance to remove the bridge in netdev_shash.

ovs-vsctl: Error detected while setting up 'br-eth'.  See ovs-vswitchd log for details.

ovs-vswitchd log:
2017-05-11T03:45:25.293Z|00026|ofproto_dpif|INFO|system at ovs-system: Datapath supports recirculation
2017-05-11T03:45:25.293Z|00027|ofproto_dpif|INFO|system at ovs-system: MPLS label stack length probed as 1
2017-05-11T03:45:25.293Z|00028|ofproto_dpif|INFO|system at ovs-system: Datapath supports unique flow ids
2017-05-11T03:45:25.293Z|00029|ofproto_dpif|INFO|system at ovs-system: Datapath supports ct_state
2017-05-11T03:45:25.293Z|00030|ofproto_dpif|INFO|system at ovs-system: Datapath supports ct_zone
2017-05-11T03:45:25.293Z|00031|ofproto_dpif|INFO|system at ovs-system: Datapath supports ct_mark
2017-05-11T03:45:25.293Z|00032|ofproto_dpif|INFO|system at ovs-system: Datapath supports ct_label
2017-05-11T03:45:25.364Z|00001|ofproto_dpif_upcall(handler226)|INFO|received packet on unassociated datapath port 0
2017-05-11T03:45:25.368Z|00033|netdev_linux|WARN|ethtool command ETHTOOL_GFLAGS on network device br-eth failed: No such device
2017-05-11T03:45:25.368Z|00034|dpif|WARN|system at ovs-system: failed to add br-eth as port: No such device
2017-05-11T03:45:25.368Z|00035|bridge|INFO|bridge br-eth: using datapath ID 00002a51cf9f2841
2017-05-11T03:45:25.368Z|00036|connmgr|INFO|br-eth: added service controller "punix:/var/run/openvswitch/br-eth.mgmt"

Signed-off-by: fukaige <fukaige at huawei.com>
---
 lib/tnl-ports.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/tnl-ports.c b/lib/tnl-ports.c
index bcf4b94..75b5909 100644
--- a/lib/tnl-ports.c
+++ b/lib/tnl-ports.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <string.h>
+#include <linux/rtnetlink.h>
 
 #include "classifier.h"
 #include "dynamic-string.h"
@@ -33,6 +34,7 @@
 #include "ovs-thread.h"
 #include "unixctl.h"
 #include "util.h"
+#include "rtnetlink.h"
 
 static struct ovs_mutex mutex = OVS_MUTEX_INITIALIZER;
 static struct classifier cls;   /* Tunnel ports. */
@@ -463,11 +465,19 @@ tnl_port_map_run(void)
     ovs_mutex_unlock(&mutex);
 }
 
+static void
+rtnetlink_del_cb(const struct rtnetlink_change *change, void *aux OVS_UNUSED)
+{
+    if(change->nlmsg_type == RTM_DELLINK)
+        tnl_port_map_delete_ipdev(change->ifname);
+}
+
 void
 tnl_port_map_init(void)
 {
     classifier_init(&cls, flow_segment_u64s);
     list_init(&addr_list);
     list_init(&port_list);
+    rtnetlink_notifier_create(rtnetlink_del_cb, NULL);
     unixctl_command_register("tnl/ports/show", "-v", 0, 1, tnl_port_show, NULL);
 }
-- 
1.8.3.1




More information about the dev mailing list