[ovs-dev] [PATCH v2 1/2] mcast-snooping: Flush ports mdb when VLAN configuration changed.

nickcooper-zhangtonghao nic at opencloud.tech
Fri Mar 3 09:47:45 UTC 2017


If VLAN configuration(e.g. id, mode) change occurs, the IGMP
snooping-learned multicast groups from this port on the VLAN are
deleted. This avoids a MCAST_ENTRY_DEFAULT_IDLE_TIME delay before
mdb is updated again. Hardware switches (e.g. cisco) also do that.

Signed-off-by: nickcooper-zhangtonghao <nic at opencloud.tech>
---
 lib/mcast-snooping.c   | 31 +++++++++++++++++++++++++++++++
 lib/mcast-snooping.h   |  1 +
 ofproto/ofproto-dpif.c |  1 +
 3 files changed, 33 insertions(+)

diff --git a/lib/mcast-snooping.c b/lib/mcast-snooping.c
index f71321d..a3163f5 100644
--- a/lib/mcast-snooping.c
+++ b/lib/mcast-snooping.c
@@ -942,3 +942,34 @@ mcast_snooping_wait(struct mcast_snooping *ms)
     mcast_snooping_wait__(ms);
     ovs_rwlock_unlock(&ms->rwlock);
 }
+
+void
+mcast_snooping_flush_bundle(struct mcast_snooping *ms, void *port)
+{
+    struct mcast_group *g, *next_g;
+    struct mcast_mrouter_bundle *m, *next_m;
+
+    if (!mcast_snooping_enabled(ms)) {
+        return;
+    }
+
+    ovs_rwlock_wrlock(&ms->rwlock);
+    LIST_FOR_EACH_SAFE (g, next_g, group_node, &ms->group_lru) {
+        if (mcast_group_delete_bundle(ms, g, port)) {
+            ms->need_revalidate = true;
+
+            if (!mcast_group_has_bundles(g)) {
+                mcast_snooping_flush_group__(ms, g);
+            }
+        }
+    }
+
+    LIST_FOR_EACH_SAFE (m, next_m, mrouter_node, &ms->mrouter_lru) {
+        if (m->port == port) {
+            mcast_snooping_flush_mrouter(m);
+            ms->need_revalidate = true;
+        }
+    }
+
+    ovs_rwlock_unlock(&ms->rwlock);
+}
diff --git a/lib/mcast-snooping.h b/lib/mcast-snooping.h
index af7fb93..f120405 100644
--- a/lib/mcast-snooping.h
+++ b/lib/mcast-snooping.h
@@ -214,5 +214,6 @@ bool mcast_snooping_is_membership(ovs_be16 igmp_type);
 /* Flush. */
 void mcast_snooping_mdb_flush(struct mcast_snooping *ms);
 void mcast_snooping_flush(struct mcast_snooping *ms);
+void mcast_snooping_flush_bundle(struct mcast_snooping *ms, void *port);
 
 #endif /* mcast-snooping.h */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 89c7b7f..366b7a2 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -2948,6 +2948,7 @@ bundle_set(struct ofproto *ofproto_, void *aux,
      * everything on this port and force flow revalidation. */
     if (need_flush) {
         bundle_flush_macs(bundle, false);
+        mcast_snooping_flush_bundle(ofproto->ms, bundle);
     }
 
     return 0;
-- 
1.8.3.1





More information about the dev mailing list