[ovs-dev] [PATCH 2/3] ofproto: Add protected property to bundle

Ben Kelly ben at benjii.net
Sun Nov 13 13:30:39 UTC 2016


Propagate the protected mode setting from port to xbundle, so that
ofproto* can make decisions.

Signed-off-by: Ben Kelly <ben at benjii.net>
---
 ofproto/ofproto-dpif-xlate.c | 12 +++++++-----
 ofproto/ofproto-dpif-xlate.h |  2 +-
 ofproto/ofproto-dpif.c       | 11 ++++++++++-
 ofproto/ofproto.h            |  2 ++
 vswitchd/bridge.c            |  3 +++
 5 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index f6391ed..98b536a 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -130,6 +130,7 @@ struct xbundle {
                                     * NULL if all VLANs are trunked. */
     bool use_priority_tags;        /* Use 802.1p tag for frames in VLAN 0? */
     bool floodable;                /* No port has OFPUTIL_PC_NO_FLOOD set? */
+    bool protected;                /* Protected port mode */
 };
 
 struct xport {
@@ -534,7 +535,7 @@ static void xlate_xbundle_set(struct xbundle *xbundle,
                               enum port_vlan_mode vlan_mode, int vlan,
                               unsigned long *trunks, bool use_priority_tags,
                               const struct bond *bond, const struct lacp *lacp,
-                              bool floodable);
+                              bool floodable, bool protected);
 static void xlate_xport_set(struct xport *xport, odp_port_t odp_port,
                             const struct netdev *netdev, const struct cfm *cfm,
                             const struct bfd *bfd, const struct lldp *lldp,
@@ -683,7 +684,7 @@ xlate_xbundle_set(struct xbundle *xbundle,
                   enum port_vlan_mode vlan_mode, int vlan,
                   unsigned long *trunks, bool use_priority_tags,
                   const struct bond *bond, const struct lacp *lacp,
-                  bool floodable)
+                  bool floodable, bool protected)
 {
     ovs_assert(xbundle->xbridge);
 
@@ -692,6 +693,7 @@ xlate_xbundle_set(struct xbundle *xbundle,
     xbundle->trunks = trunks;
     xbundle->use_priority_tags = use_priority_tags;
     xbundle->floodable = floodable;
+    xbundle->protected = protected;
 
     if (xbundle->bond != bond) {
         bond_unref(xbundle->bond);
@@ -786,7 +788,7 @@ xlate_xbundle_copy(struct xbridge *xbridge, struct xbundle *xbundle)
     xlate_xbundle_set(new_xbundle, xbundle->vlan_mode,
                       xbundle->vlan, xbundle->trunks,
                       xbundle->use_priority_tags, xbundle->bond, xbundle->lacp,
-                      xbundle->floodable);
+                      xbundle->floodable, xbundle->protected);
     LIST_FOR_EACH (xport, bundle_node, &xbundle->xports) {
         xlate_xport_copy(xbridge, new_xbundle, xport);
     }
@@ -980,7 +982,7 @@ xlate_bundle_set(struct ofproto_dpif *ofproto, struct ofbundle *ofbundle,
                  const char *name, enum port_vlan_mode vlan_mode, int vlan,
                  unsigned long *trunks, bool use_priority_tags,
                  const struct bond *bond, const struct lacp *lacp,
-                 bool floodable)
+                 bool floodable, bool protected)
 {
     struct xbundle *xbundle;
 
@@ -999,7 +1001,7 @@ xlate_bundle_set(struct ofproto_dpif *ofproto, struct ofbundle *ofbundle,
     xbundle->name = xstrdup(name);
 
     xlate_xbundle_set(xbundle, vlan_mode, vlan, trunks,
-                      use_priority_tags, bond, lacp, floodable);
+                      use_priority_tags, bond, lacp, floodable, protected);
 }
 
 static void
diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h
index eaa2e8e..51c05ac 100644
--- a/ofproto/ofproto-dpif-xlate.h
+++ b/ofproto/ofproto-dpif-xlate.h
@@ -170,7 +170,7 @@ void xlate_bundle_set(struct ofproto_dpif *, struct ofbundle *,
                       const char *name, enum port_vlan_mode, int vlan,
                       unsigned long *trunks, bool use_priority_tags,
                       const struct bond *, const struct lacp *,
-                      bool floodable);
+                      bool floodable, bool protected);
 void xlate_bundle_remove(struct ofbundle *);
 
 void xlate_ofport_set(struct ofproto_dpif *, struct ofbundle *,
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 330bd48..aa36462 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -144,6 +144,8 @@ struct ofbundle {
     struct bond *bond;          /* Nonnull iff more than one port. */
     bool use_priority_tags;     /* Use 802.1p tag for frames in VLAN 0? */
 
+    bool protected;             /* Protected port mode */
+
     /* Status. */
     bool floodable;          /* True if no port has OFPUTIL_PC_NO_FLOOD set. */
 };
@@ -620,7 +622,7 @@ type_run(const char *type)
                                  bundle->vlan_mode, bundle->vlan,
                                  bundle->trunks, bundle->use_priority_tags,
                                  bundle->bond, bundle->lacp,
-                                 bundle->floodable);
+                                 bundle->floodable, bundle->protected);
             }
 
             HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) {
@@ -2909,6 +2911,7 @@ bundle_set(struct ofproto *ofproto_, void *aux,
         bundle->bond = NULL;
 
         bundle->floodable = true;
+        bundle->protected = false;
         mbridge_register_bundle(ofproto->mbridge, bundle);
     }
 
@@ -3042,6 +3045,12 @@ bundle_set(struct ofproto *ofproto_, void *aux,
         bundle->bond = NULL;
     }
 
+    /* Set proteced port mode */
+    if (s->protected != bundle->protected) {
+        bundle->protected = s->protected;
+        need_flush = true;
+    }
+
     /* If we changed something that would affect MAC learning, un-learn
      * everything on this port and force flow revalidation. */
     if (need_flush) {
diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h
index d813fda..9df1a87 100644
--- a/ofproto/ofproto.h
+++ b/ofproto/ofproto.h
@@ -405,6 +405,8 @@ struct ofproto_bundle_settings {
 
     struct lacp_settings *lacp;              /* Nonnull to enable LACP. */
     struct lacp_slave_settings *lacp_slaves; /* Array of n_slaves elements. */
+
+    bool protected;             /* Protected port mode */
 };
 
 int ofproto_bundle_register(struct ofproto *, void *aux,
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index d78c48e..7f33070 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -1013,6 +1013,9 @@ port_configure(struct port *port)
         }
     }
 
+    /* Protected port mode */
+    s.protected = cfg->protected;
+
     /* Register. */
     ofproto_bundle_register(port->bridge->ofproto, port, &s);
 
-- 
2.7.4



More information about the dev mailing list