Signed-off-by: Flavio Leitner <f...@redhat.com>
---
 ofproto/ofproto-dpif.c     | 50 ++++++++++++++++++++++++++++++++++++++++++++++
 ofproto/ofproto-provider.h | 16 +++++++++++++++
 ofproto/ofproto.c          | 27 +++++++++++++++++++++++++
 ofproto/ofproto.h          | 12 +++++++++++
 4 files changed, 105 insertions(+)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 30851df..0063a55 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -2710,6 +2710,54 @@ set_mac_table_config(struct ofproto *ofproto_, unsigned 
int idle_time,
     mac_learning_set_max_entries(ofproto->ml, max_entries);
     ovs_rwlock_unlock(&ofproto->ml->rwlock);
 }
+
+static int
+set_mcast_snooping(struct ofproto *ofproto_,
+                   const struct ofproto_mcast_snooping_settings *s)
+{
+    struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
+
+    /* Only revalidate flows if the configuration changed. */
+    if (!s != !ofproto->ms) {
+        ofproto->backer->need_revalidate = REV_RECONFIGURE;
+    }
+
+    if (s) {
+        if (!ofproto->ms) {
+            ofproto->ms = mcast_snooping_create();
+        }
+
+        ovs_rwlock_wrlock(&ofproto->ms->rwlock);
+        mcast_snooping_set_idle_time(ofproto->ms, s->idle_time);
+        mcast_snooping_set_max_entries(ofproto->ms, s->max_entries);
+        if (mcast_snooping_set_flood_unreg(ofproto->ms, s->flood_unreg)) {
+            ofproto->backer->need_revalidate = REV_RECONFIGURE;
+        }
+        ovs_rwlock_unlock(&ofproto->ms->rwlock);
+    } else {
+        mcast_snooping_unref(ofproto->ms);
+        ofproto->ms = NULL;
+    }
+
+    return 0;
+}
+
+/* Configures multicast snooping flood setting on 'ofport_'. */
+static int
+set_mcast_snooping_port(struct ofproto *ofproto_, void *aux, bool flood)
+{
+    struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
+    struct ofbundle *bundle = bundle_lookup(ofproto, aux);
+
+    if (ofproto->ms) {
+        ovs_rwlock_wrlock(&ofproto->ms->rwlock);
+        mcast_snooping_set_port_flood(ofproto->ms, bundle->vlan, bundle,
+                                      flood);
+        ovs_rwlock_unlock(&ofproto->ms->rwlock);
+    }
+    return 0;
+}
+
 
 /* Ports. */
 
@@ -4954,6 +5002,8 @@ const struct ofproto_class ofproto_dpif_class = {
     is_mirror_output_bundle,
     forward_bpdu_changed,
     set_mac_table_config,
+    set_mcast_snooping,
+    set_mcast_snooping_port,
     set_realdev,
     NULL,                       /* meter_get_features */
     NULL,                       /* meter_set */
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index ceeda64..134fd45 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -1621,6 +1621,22 @@ struct ofproto_class {
     void (*set_mac_table_config)(struct ofproto *ofproto,
                                  unsigned int idle_time, size_t max_entries);
 
+    /* Sets the multicast snooping aging timeout for the OFPP_NORMAL action
+     * to 'idle_time', in seconds, and the maximum number of multicast snooping
+     * table entries to 'max_entries'.
+     *
+     * An implementation that doesn't support configuring these features may
+     * set this function to NULL or implement it as a no-op. */
+    int (*set_mcast_snooping)(struct ofproto *ofproto,
+                              const struct ofproto_mcast_snooping_settings *s);
+
+    /* Configures multicast snooping flood setting on 'ofproto'
+     *
+     * EOPNOTSUPP as a return value indicates that this ofproto_class does not
+     * support multicast snooping, as does a null pointer. */
+    int (*set_mcast_snooping_port)(struct ofproto *ofproto_, void *aux,
+                                   bool flood);
+
 /* Linux VLAN device support (e.g. "eth0.10" for VLAN 10.)
  *
  * This is deprecated.  It is only for compatibility with broken device drivers
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 63f65c3..7f17ce3 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -740,6 +740,33 @@ ofproto_set_mac_table_config(struct ofproto *ofproto, 
unsigned idle_time,
     }
 }
 
+/* Multicast snooping configuration. */
+
+/* Configures IGMP snooping on 'ofproto' using the settings
+ * defined in 's'.  If 's' is NULL, disables IGMP snooping.
+ *
+ * Returns 0 if successful, otherwise a positive errno value. */
+int
+ofproto_set_mcast_snooping(struct ofproto *ofproto,
+                           const struct ofproto_mcast_snooping_settings *s)
+{
+    return (ofproto->ofproto_class->set_mcast_snooping
+            ? ofproto->ofproto_class->set_mcast_snooping(ofproto, s)
+            : EOPNOTSUPP);
+}
+
+/* Configures multicast snooping flood setting on 'ofp_port' of 'ofproto'.
+ *
+ * Returns 0 if successful, otherwise a positive errno value.*/
+int
+ofproto_port_set_mcast_snooping(struct ofproto *ofproto, void *aux, bool flood)
+{
+    return (ofproto->ofproto_class->set_mcast_snooping_port
+            ? ofproto->ofproto_class->set_mcast_snooping_port(ofproto, aux,
+                                                              flood)
+            : EOPNOTSUPP);
+}
+
 void
 ofproto_set_threads(int n_handlers_, int n_revalidators_)
 {
diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h
index de078b7..d20a60b 100644
--- a/ofproto/ofproto.h
+++ b/ofproto/ofproto.h
@@ -123,6 +123,14 @@ struct ofproto_port_queue {
     uint8_t dscp;               /* DSCP bits (e.g. [0, 63]). */
 };
 
+struct ofproto_mcast_snooping_settings {
+    bool flood_unreg;           /* if true, flood unregistered packets to all
+                                   all ports. If false, send only to ports
+                                   connected to multicast routers */
+    unsigned int idle_time;    /* Entry is removed after the idle time */
+    unsigned int max_entries;  /* Size of the multicast snooping table */
+};
+
 /* How the switch should act if the controller cannot be contacted. */
 enum ofproto_fail_mode {
     OFPROTO_FAIL_SECURE,        /* Preserve flow table. */
@@ -241,6 +249,10 @@ void ofproto_set_max_idle(unsigned max_idle);
 void ofproto_set_forward_bpdu(struct ofproto *, bool forward_bpdu);
 void ofproto_set_mac_table_config(struct ofproto *, unsigned idle_time,
                                   size_t max_entries);
+int ofproto_set_mcast_snooping(struct ofproto *ofproto,
+                              const struct ofproto_mcast_snooping_settings *s);
+int ofproto_port_set_mcast_snooping(struct ofproto *ofproto, void *aux,
+                                    bool flood);
 void ofproto_set_threads(int n_handlers, int n_revalidators);
 void ofproto_set_dp_desc(struct ofproto *, const char *dp_desc);
 int ofproto_set_snoops(struct ofproto *, const struct sset *snoops);
-- 
1.9.3

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to