From cf3ecb1a42c9c40f386ed59964117c3dab15fa5c Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Tue, 11 Dec 2018 08:40:20 -0800 Subject: VOM: vxlan-tunnel takes egress interface for multicast Change-Id: I23b44d883fbd7919bf55b96b180f97837fd6dae9 Signed-off-by: Neale Ranns --- extras/vom/vom/vxlan_gbp_tunnel_cmds.cpp | 6 ++++-- extras/vom/vom/vxlan_gbp_tunnel_cmds.hpp | 4 +++- extras/vom/vom/vxlan_tunnel.cpp | 31 +++++++++++++++++++++++++++---- extras/vom/vom/vxlan_tunnel.hpp | 15 ++++++++------- extras/vom/vom/vxlan_tunnel_cmds.cpp | 6 ++++-- extras/vom/vom/vxlan_tunnel_cmds.hpp | 4 +++- 6 files changed, 49 insertions(+), 17 deletions(-) (limited to 'extras/vom') diff --git a/extras/vom/vom/vxlan_gbp_tunnel_cmds.cpp b/extras/vom/vom/vxlan_gbp_tunnel_cmds.cpp index 14470806665..a646eac34a0 100644 --- a/extras/vom/vom/vxlan_gbp_tunnel_cmds.cpp +++ b/extras/vom/vom/vxlan_gbp_tunnel_cmds.cpp @@ -23,9 +23,11 @@ namespace vxlan_gbp_tunnel_cmds { create_cmd::create_cmd(HW::item& item, const std::string& name, - const vxlan_tunnel::endpoint_t& ep) + const vxlan_tunnel::endpoint_t& ep, + handle_t mcast_itf) : interface::create_cmd(item, name) , m_ep(ep) + , m_mcast_itf(mcast_itf) { } @@ -46,7 +48,7 @@ create_cmd::issue(connection& con) to_api(m_ep.src, payload.tunnel.src); to_api(m_ep.src, payload.tunnel.dst); - payload.tunnel.mcast_sw_if_index = ~0; + payload.tunnel.mcast_sw_if_index = m_mcast_itf.value(); payload.tunnel.encap_table_id = 0; payload.tunnel.vni = m_ep.vni; diff --git a/extras/vom/vom/vxlan_gbp_tunnel_cmds.hpp b/extras/vom/vom/vxlan_gbp_tunnel_cmds.hpp index 34407f61bda..c7ec87245df 100644 --- a/extras/vom/vom/vxlan_gbp_tunnel_cmds.hpp +++ b/extras/vom/vom/vxlan_gbp_tunnel_cmds.hpp @@ -37,7 +37,8 @@ public: */ create_cmd(HW::item& item, const std::string& name, - const vxlan_tunnel::endpoint_t& ep); + const vxlan_tunnel::endpoint_t& ep, + handle_t mcast_itf); /** * Issue the command to VPP/HW @@ -58,6 +59,7 @@ private: * Enpoint values of the tunnel to be created */ const vxlan_tunnel::endpoint_t m_ep; + handle_t m_mcast_itf; }; /** diff --git a/extras/vom/vom/vxlan_tunnel.cpp b/extras/vom/vom/vxlan_tunnel.cpp index 2abff7615eb..2bc386c1ba7 100644 --- a/extras/vom/vom/vxlan_tunnel.cpp +++ b/extras/vom/vom/vxlan_tunnel.cpp @@ -91,6 +91,21 @@ vxlan_tunnel::vxlan_tunnel(const boost::asio::ip::address& src, interface::admin_state_t::UP) , m_tep(src, dst, vni) , m_mode(mode) + , m_mcast_itf() +{ +} + +vxlan_tunnel::vxlan_tunnel(const boost::asio::ip::address& src, + const boost::asio::ip::address& dst, + uint32_t vni, + const interface& mcast_itf, + const mode_t& mode) + : interface(mk_name(src, dst, mode, vni), + interface::type_t::VXLAN, + interface::admin_state_t::UP) + , m_tep(src, dst, vni) + , m_mode(mode) + , m_mcast_itf(mcast_itf.singular()) { } @@ -130,9 +145,13 @@ vxlan_tunnel::replay() { if (m_hdl) { if (mode_t::STANDARD == m_mode) - HW::enqueue(new vxlan_tunnel_cmds::create_cmd(m_hdl, name(), m_tep)); + HW::enqueue(new vxlan_tunnel_cmds::create_cmd( + m_hdl, name(), m_tep, + (m_mcast_itf ? m_mcast_itf->handle() : handle_t::INVALID))); else if (mode_t::GBP == m_mode) - HW::enqueue(new vxlan_gbp_tunnel_cmds::create_cmd(m_hdl, name(), m_tep)); + HW::enqueue(new vxlan_gbp_tunnel_cmds::create_cmd( + m_hdl, name(), m_tep, + (m_mcast_itf ? m_mcast_itf->handle() : handle_t::INVALID))); } } @@ -160,9 +179,13 @@ vxlan_tunnel::update(const vxlan_tunnel& desired) */ if (!m_hdl) { if (mode_t::STANDARD == m_mode) - HW::enqueue(new vxlan_tunnel_cmds::create_cmd(m_hdl, name(), m_tep)); + HW::enqueue(new vxlan_tunnel_cmds::create_cmd( + m_hdl, name(), m_tep, + (m_mcast_itf ? m_mcast_itf->handle() : handle_t::INVALID))); else if (mode_t::GBP == m_mode) - HW::enqueue(new vxlan_gbp_tunnel_cmds::create_cmd(m_hdl, name(), m_tep)); + HW::enqueue(new vxlan_gbp_tunnel_cmds::create_cmd( + m_hdl, name(), m_tep, + (m_mcast_itf ? m_mcast_itf->handle() : handle_t::INVALID))); } } diff --git a/extras/vom/vom/vxlan_tunnel.hpp b/extras/vom/vom/vxlan_tunnel.hpp index 136f0380e6d..63124e73426 100644 --- a/extras/vom/vom/vxlan_tunnel.hpp +++ b/extras/vom/vom/vxlan_tunnel.hpp @@ -97,15 +97,10 @@ public: const boost::asio::ip::address& dst, uint32_t vni, const mode_t& mode = mode_t::STANDARD); - - /** - * Construct a new object matching the desried state with a handle - * read from VPP - */ - vxlan_tunnel(const handle_t& hdl, - const boost::asio::ip::address& src, + vxlan_tunnel(const boost::asio::ip::address& src, const boost::asio::ip::address& dst, uint32_t vni, + const interface& mcast_itf, const mode_t& mode = mode_t::STANDARD); /* @@ -220,6 +215,12 @@ private: */ mode_t m_mode; + /** + * The interface on which to send the packets if the destination + * is multicast + */ + std::shared_ptr m_mcast_itf; + /** * Construct a unique name for the tunnel */ diff --git a/extras/vom/vom/vxlan_tunnel_cmds.cpp b/extras/vom/vom/vxlan_tunnel_cmds.cpp index dcc06e71797..e45b6046355 100644 --- a/extras/vom/vom/vxlan_tunnel_cmds.cpp +++ b/extras/vom/vom/vxlan_tunnel_cmds.cpp @@ -22,9 +22,11 @@ namespace vxlan_tunnel_cmds { create_cmd::create_cmd(HW::item& item, const std::string& name, - const vxlan_tunnel::endpoint_t& ep) + const vxlan_tunnel::endpoint_t& ep, + handle_t mcast_itf) : interface::create_cmd(item, name) , m_ep(ep) + , m_mcast_itf(mcast_itf) { } @@ -44,7 +46,7 @@ create_cmd::issue(connection& con) payload.is_ipv6 = 0; to_bytes(m_ep.src, &payload.is_ipv6, payload.src_address); to_bytes(m_ep.dst, &payload.is_ipv6, payload.dst_address); - payload.mcast_sw_if_index = ~0; + payload.mcast_sw_if_index = m_mcast_itf.value(); payload.encap_vrf_id = 0; payload.decap_next_index = ~0; payload.vni = m_ep.vni; diff --git a/extras/vom/vom/vxlan_tunnel_cmds.hpp b/extras/vom/vom/vxlan_tunnel_cmds.hpp index 4a8e5990391..423fcdac950 100644 --- a/extras/vom/vom/vxlan_tunnel_cmds.hpp +++ b/extras/vom/vom/vxlan_tunnel_cmds.hpp @@ -38,7 +38,8 @@ public: */ create_cmd(HW::item& item, const std::string& name, - const vxlan_tunnel::endpoint_t& ep); + const vxlan_tunnel::endpoint_t& ep, + handle_t mcast_itf); /** * Issue the command to VPP/HW @@ -59,6 +60,7 @@ private: * Enpoint values of the tunnel to be created */ const vxlan_tunnel::endpoint_t m_ep; + handle_t m_mcast_itf; }; /** -- cgit 1.2.3-korg