[ovs-dev] [PATCH] ofproto-vswitchd: Bubble no-flood configuration up to bridge

Ethan Jackson ethan at nicira.com
Wed Oct 13 22:57:31 UTC 2010


When bridge.c decides to flood a packet as the result of a "normal"
flow action, it now checks whether each port is configured to
receive flood packets.

Bug #3741
---
 ofproto/ofproto.c |    9 +++++++++
 ofproto/ofproto.h |    1 +
 vswitchd/bridge.c |   18 +++++++++++++++++-
 3 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index e25ce28..1d1a10d 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -1277,6 +1277,15 @@ ofproto_port_del(struct ofproto *ofproto, uint16_t odp_port)
     return error;
 }
 
+/* Checks if 'ofproto' thinks 'odp_port' should be included in floods.  Returns
+ * true if 'odp_port' exists and should be included, false otherwise. */
+bool
+ofproto_port_is_floodable(struct ofproto *ofproto, uint16_t odp_port)
+{
+    struct ofport *ofport = get_port(ofproto, odp_port);
+    return ofport && !(ofport->opp.config & OFPPC_NO_FLOOD);
+}
+
 int
 ofproto_send_packet(struct ofproto *p, const struct flow *flow,
                     const union ofp_action *actions, size_t n_actions,
diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h
index 0c403e9..362ea26 100644
--- a/ofproto/ofproto.h
+++ b/ofproto/ofproto.h
@@ -95,6 +95,7 @@ void ofproto_wait(struct ofproto *);
 bool ofproto_is_alive(const struct ofproto *);
 
 int ofproto_port_del(struct ofproto *, uint16_t odp_port);
+bool ofproto_port_is_floodable(struct ofproto *, uint16_t odp_port);
 
 /* Configuration. */
 void ofproto_set_datapath_id(struct ofproto *, uint64_t datapath_id);
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 74ac87e..4a7f90b 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2203,6 +2203,20 @@ port_includes_vlan(const struct port *port, uint16_t vlan)
     return vlan == port->vlan || port_trunks_vlan(port, vlan);
 }
 
+static bool
+port_is_floodable(const struct port *port)
+{
+    int i;
+
+    for (i = 0; i < port->n_ifaces; i++) {
+        if (!ofproto_port_is_floodable(port->bridge->ofproto,
+                                       port->ifaces[i]->dp_ifidx)) {
+            return false;
+        }
+    }
+    return true;
+}
+
 static size_t
 compose_dsts(const struct bridge *br, const struct flow *flow, uint16_t vlan,
              const struct port *in_port, const struct port *out_port,
@@ -2217,7 +2231,9 @@ compose_dsts(const struct bridge *br, const struct flow *flow, uint16_t vlan,
         /* XXX even better, define each VLAN as a datapath port group */
         for (i = 0; i < br->n_ports; i++) {
             struct port *port = br->ports[i];
-            if (port != in_port && port_includes_vlan(port, vlan)
+            if (port != in_port
+                && port_is_floodable(port)
+                && port_includes_vlan(port, vlan)
                 && !port->is_mirror_output_port
                 && set_dst(dst, flow, in_port, port, tags)) {
                 mirrors |= port->dst_mirrors;
-- 
1.7.3.1





More information about the dev mailing list