Acked-by: Thomas Graf <tg...@redhat.com>
Signed-off-by: Flavio Leitner <f...@redhat.com>
---
 ofproto/ofproto-dpif.c     | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 ofproto/ofproto-provider.h | 22 +++++++++++++++++++
 ofproto/ofproto.c          | 28 +++++++++++++++++++++++
 ofproto/ofproto.h          | 17 ++++++++++++++
 4 files changed, 122 insertions(+)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 38acbf0..eb00ccf 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -2680,6 +2680,59 @@ 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);
+        mcast_snooping_set_flood_unreg(ofproto->ms, s->flood_unreg);
+        ovs_rwlock_unlock(&ofproto->ms->rwlock);
+    } else {
+        mcast_snooping_unref(ofproto->ms);
+        ofproto->ms = NULL;
+    }
+
+    return 0;
+}
+
+/* Configures multicast snooping on 'ofport_' using the settings defined
+ * in 's'.*/
+static int
+set_mcast_snooping_port(struct ofproto *ofproto_, void *aux,
+                        const struct ofproto_port_mcast_snooping_settings *s)
+{
+    struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
+    struct ofbundle *bundle = bundle_lookup(ofproto, aux);
+
+
+    if (!s || !s->flood) {
+        ovs_rwlock_wrlock(&ofproto->ms->rwlock);
+        mcast_snooping_port_disable_flood(ofproto->ms, bundle->vlan, bundle);
+        ovs_rwlock_unlock(&ofproto->ms->rwlock);
+        return 0;
+    }
+
+    ovs_rwlock_wrlock(&ofproto->ms->rwlock);
+    mcast_snooping_port_enable_flood(ofproto->ms, bundle->vlan, bundle);
+    ovs_rwlock_unlock(&ofproto->ms->rwlock);
+    return 0;
+}
+
 
 /* Ports. */
 
@@ -5006,6 +5059,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 bfa0235..fc98049 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -1631,6 +1631,28 @@ 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 on 'ofproto' using the
+     * settings defined in 's'.
+     *
+     * If 's' is nonnull, configures multicast snooping according to its
+     * members.
+     * If 's' is null, removes any multicast snooping configuration from
+     * 'ofport'.
+     *
+     * 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,
+                          const struct ofproto_port_mcast_snooping_settings 
*s);
+
 /* 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 a517264..dfb4abc 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -736,6 +736,34 @@ 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 IGMP snooping on 'ofp_port' of 'ofproto' using the
+ * settings defined in 's'.
+ *
+ * Returns 0 if successful, otherwise a positive errno value.*/
+int
+ofproto_port_set_mcast_snooping(struct ofproto *ofproto, void *aux,
+                        const struct ofproto_port_mcast_snooping_settings *s)
+{
+    return (ofproto->ofproto_class->set_mcast_snooping_port
+            ? ofproto->ofproto_class->set_mcast_snooping_port(ofproto, aux, s)
+            : EOPNOTSUPP);
+}
+
 void
 ofproto_set_threads(int n_handlers_, int n_revalidators_)
 {
diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h
index ab51365..af5466b 100644
--- a/ofproto/ofproto.h
+++ b/ofproto/ofproto.h
@@ -123,6 +123,19 @@ struct ofproto_port_queue {
     uint8_t dscp;               /* DSCP bits (e.g. [0, 63]). */
 };
 
+struct ofproto_mcast_snooping_settings {
+    bool enabled;              /* If false, ignore other members */
+    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 */
+};
+
+struct ofproto_port_mcast_snooping_settings {
+    bool flood;                 /* If true, send all mcast packets. */
+};
+
 /* How the switch should act if the controller cannot be contacted. */
 enum ofproto_fail_mode {
     OFPROTO_FAIL_SECURE,        /* Preserve flow table. */
@@ -241,6 +254,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,
+                        const struct ofproto_port_mcast_snooping_settings *s);
 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.0

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

Reply via email to