VOM: GBP bridge domain flags 22/16922/2
authorNeale Ranns <nranns@cisco.com>
Thu, 10 Jan 2019 16:00:22 +0000 (08:00 -0800)
committerNeale Ranns <nranns@cisco.com>
Tue, 22 Jan 2019 07:17:43 +0000 (07:17 +0000)
Change-Id: Ib5e4a850e127dda51318ffe82ef2622b980bc947
Signed-off-by: Neale Ranns <nranns@cisco.com>
extras/vom/vom/gbp_bridge_domain.cpp
extras/vom/vom/gbp_bridge_domain.hpp
extras/vom/vom/gbp_bridge_domain_cmds.cpp
extras/vom/vom/gbp_bridge_domain_cmds.hpp
extras/vom/vom/gbp_endpoint_group.cpp
extras/vom/vom/gbp_endpoint_group.hpp
extras/vom/vom/gbp_route_domain.cpp
extras/vom/vom/gbp_route_domain.hpp

index 03be83d..101209f 100644 (file)
 
 namespace VOM {
 
+const gbp_bridge_domain::flags_t gbp_bridge_domain::flags_t::NONE(0, "none");
+const gbp_bridge_domain::flags_t gbp_bridge_domain::flags_t::DO_NOT_LEARN(
+  0,
+  "do-not-learn");
+
+gbp_bridge_domain::flags_t::flags_t(int v, const std::string& s)
+  : enum_base<gbp_bridge_domain::flags_t>(v, s)
+{
+}
+
 /**
  * A DB of al the interfaces, key on the name
  */
@@ -32,40 +42,48 @@ gbp_bridge_domain::event_handler gbp_bridge_domain::m_evh;
  * Construct a new object matching the desried state
  */
 gbp_bridge_domain::gbp_bridge_domain(const bridge_domain& bd,
-                                     const interface& bvi)
+                                     const interface& bvi,
+                                     const flags_t& flags)
   : m_id(bd.id())
   , m_bd(bd.singular())
   , m_bvi(bvi.singular())
+  , m_flags(flags)
 {
 }
 
 gbp_bridge_domain::gbp_bridge_domain(const bridge_domain& bd,
                                      const interface& bvi,
-                                     const interface& uu_fwd)
+                                     const interface& uu_fwd,
+                                     const flags_t& flags)
   : m_id(bd.id())
   , m_bd(bd.singular())
   , m_bvi(bvi.singular())
   , m_uu_fwd(uu_fwd.singular())
+  , m_flags(flags)
 {
 }
 
 gbp_bridge_domain::gbp_bridge_domain(const bridge_domain& bd,
                                      const std::shared_ptr<interface> bvi,
-                                     const std::shared_ptr<interface> uu_fwd)
+                                     const std::shared_ptr<interface> uu_fwd,
+                                     const flags_t& flags)
   : m_id(bd.id())
   , m_bd(bd.singular())
   , m_bvi(bvi->singular())
   , m_uu_fwd(uu_fwd->singular())
+  , m_flags(flags)
 {
 }
 
 gbp_bridge_domain::gbp_bridge_domain(const bridge_domain& bd,
                                      const interface& bvi,
-                                     const std::shared_ptr<interface> uu_fwd)
+                                     const std::shared_ptr<interface> uu_fwd,
+                                     const flags_t& flags)
   : m_id(bd.id())
   , m_bd(bd.singular())
   , m_bvi(bvi.singular())
   , m_uu_fwd(uu_fwd->singular())
+  , m_flags(flags)
 {
 }
 
@@ -74,6 +92,7 @@ gbp_bridge_domain::gbp_bridge_domain(const gbp_bridge_domain& bd)
   , m_bd(bd.m_bd)
   , m_bvi(bd.m_bvi)
   , m_uu_fwd(bd.m_uu_fwd)
+  , m_flags(bd.m_flags)
 {
 }
 
@@ -90,13 +109,13 @@ gbp_bridge_domain::id() const
 }
 
 const std::shared_ptr<bridge_domain>
-gbp_bridge_domain::get_bridge_domain()
+gbp_bridge_domain::get_bridge_domain() const
 {
   return m_bd;
 }
 
 const std::shared_ptr<interface>
-gbp_bridge_domain::get_bvi()
+gbp_bridge_domain::get_bvi() const
 {
   return m_bvi;
 }
@@ -138,7 +157,7 @@ gbp_bridge_domain::replay()
   if (rc_t::OK == m_id.rc()) {
     HW::enqueue(new gbp_bridge_domain_cmds::create_cmd(
       m_id, (m_bvi ? m_bvi->handle() : handle_t::INVALID),
-      (m_uu_fwd ? m_uu_fwd->handle() : handle_t::INVALID)));
+      (m_uu_fwd ? m_uu_fwd->handle() : handle_t::INVALID), m_flags));
   }
 }
 
@@ -181,7 +200,7 @@ gbp_bridge_domain::update(const gbp_bridge_domain& desired)
   if (rc_t::OK != m_id.rc()) {
     HW::enqueue(new gbp_bridge_domain_cmds::create_cmd(
       m_id, (m_bvi ? m_bvi->handle() : handle_t::INVALID),
-      (m_uu_fwd ? m_uu_fwd->handle() : handle_t::INVALID)));
+      (m_uu_fwd ? m_uu_fwd->handle() : handle_t::INVALID), m_flags));
   }
 }
 
index c86c53e..3fcb24c 100644 (file)
@@ -34,19 +34,36 @@ public:
    */
   typedef bridge_domain::key_t key_t;
 
+  struct flags_t : enum_base<flags_t>
+  {
+    const static flags_t NONE;
+    const static flags_t DO_NOT_LEARN;
+
+    static const flags_t& from_vpp(int i);
+
+  private:
+    flags_t(int v, const std::string& s);
+    flags_t();
+  };
+
   /**
    * Construct a GBP bridge_domain
    */
-  gbp_bridge_domain(const bridge_domain& bd, const interface& bvi);
   gbp_bridge_domain(const bridge_domain& bd,
                     const interface& bvi,
-                    const interface& uu_fwd);
+                    const flags_t& flags = flags_t::NONE);
+  gbp_bridge_domain(const bridge_domain& bd,
+                    const interface& bvi,
+                    const interface& uu_fwd,
+                    const flags_t& flags = flags_t::NONE);
   gbp_bridge_domain(const bridge_domain& bd,
                     const std::shared_ptr<interface> bvi,
-                    const std::shared_ptr<interface> uu_fwd);
+                    const std::shared_ptr<interface> uu_fwd,
+                    const flags_t& flags = flags_t::NONE);
   gbp_bridge_domain(const bridge_domain& bd,
                     const interface& bvi,
-                    const std::shared_ptr<interface> uu_fwd);
+                    const std::shared_ptr<interface> uu_fwd,
+                    const flags_t& flags = flags_t::NONE);
 
   /**
    * Copy Construct
@@ -98,8 +115,8 @@ public:
    */
   std::string to_string() const;
 
-  const std::shared_ptr<bridge_domain> get_bridge_domain();
-  const std::shared_ptr<interface> get_bvi();
+  const std::shared_ptr<bridge_domain> get_bridge_domain() const;
+  const std::shared_ptr<interface> get_bvi() const;
 
 private:
   /**
@@ -171,6 +188,7 @@ private:
   std::shared_ptr<bridge_domain> m_bd;
   std::shared_ptr<interface> m_bvi;
   std::shared_ptr<interface> m_uu_fwd;
+  const flags_t& m_flags;
 
   /**
    * A map of all bridge_domains
index 60f7cdd..8fc5250 100644 (file)
@@ -20,10 +20,12 @@ namespace gbp_bridge_domain_cmds {
 
 create_cmd::create_cmd(HW::item<uint32_t>& item,
                        const handle_t bvi,
-                       const handle_t uu_fwd)
+                       const handle_t uu_fwd,
+                       const gbp_bridge_domain::flags_t& flags)
   : rpc_cmd(item)
   , m_bvi(bvi)
   , m_uu_fwd(uu_fwd)
+  , m_flags(flags)
 {
 }
 
@@ -31,7 +33,8 @@ bool
 create_cmd::operator==(const create_cmd& other) const
 {
   return ((m_hw_item.data() == other.m_hw_item.data()) &&
-          (m_bvi == other.m_bvi) && (m_uu_fwd == other.m_uu_fwd));
+          (m_bvi == other.m_bvi) && (m_uu_fwd == other.m_uu_fwd) &&
+          (m_flags == other.m_flags));
 }
 
 rc_t
@@ -45,6 +48,10 @@ create_cmd::issue(connection& con)
   payload.bd.bvi_sw_if_index = m_bvi.value();
   payload.bd.uu_fwd_sw_if_index = m_uu_fwd.value();
 
+  payload.bd.flags = GBP_BD_API_FLAG_NONE;
+  if (gbp_bridge_domain::flags_t::DO_NOT_LEARN == m_flags)
+    payload.bd.flags = GBP_BD_API_FLAG_DO_NOT_LEARN;
+
   VAPI_CALL(req.execute());
 
   return (wait());
index e7c501f..ec6b0a4 100644 (file)
@@ -36,7 +36,8 @@ public:
    */
   create_cmd(HW::item<uint32_t>& item,
              const handle_t bvi,
-             const handle_t uu_fwd);
+             const handle_t uu_fwd,
+             const gbp_bridge_domain::flags_t& flags);
 
   /**
    * Issue the command to VPP/HW
@@ -55,6 +56,7 @@ public:
 private:
   const handle_t m_bvi;
   const handle_t m_uu_fwd;
+  const gbp_bridge_domain::flags_t& m_flags;
 };
 
 /**
index 5f09ed1..e63b09f 100644 (file)
@@ -146,13 +146,13 @@ gbp_endpoint_group::dump(std::ostream& os)
 }
 
 const std::shared_ptr<gbp_route_domain>
-gbp_endpoint_group::get_route_domain()
+gbp_endpoint_group::get_route_domain() const
 {
   return m_rd;
 }
 
 const std::shared_ptr<gbp_bridge_domain>
-gbp_endpoint_group::get_bridge_domain()
+gbp_endpoint_group::get_bridge_domain() const
 {
   return m_bd;
 }
index ed0d8d9..4957800 100644 (file)
@@ -102,8 +102,8 @@ public:
    */
   epg_id_t id() const;
 
-  const std::shared_ptr<gbp_route_domain> get_route_domain();
-  const std::shared_ptr<gbp_bridge_domain> get_bridge_domain();
+  const std::shared_ptr<gbp_route_domain> get_route_domain() const;
+  const std::shared_ptr<gbp_bridge_domain> get_bridge_domain() const;
 
 private:
   /**
index 8e44db5..96216a6 100644 (file)
@@ -77,7 +77,7 @@ gbp_route_domain::id() const
 }
 
 const std::shared_ptr<route_domain>
-gbp_route_domain::get_route_domain()
+gbp_route_domain::get_route_domain() const
 {
   return m_rd;
 }
index ff13d1d..0d133b3 100644 (file)
@@ -96,7 +96,7 @@ public:
    */
   std::string to_string() const;
 
-  const std::shared_ptr<route_domain> get_route_domain();
+  const std::shared_ptr<route_domain> get_route_domain() const;
 
 private:
   /**