diff options
author | Neale Ranns <neale.ranns@cisco.com> | 2018-04-04 09:34:50 -0700 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2018-04-13 08:51:21 +0000 |
commit | 25b049484fcf9161edb2c19250066b893c38c264 (patch) | |
tree | 69204352a0648cfc4089fa0e37214bffbae61e81 /src/vpp-api/vom/nat_static.cpp | |
parent | 4f8863b21405d1ab3e067e978a60be72a343358b (diff) |
GBP V2
update the GBP plugin to implement the full NAT feature set of opflex agent
Change-Id: Ic06a039c889445ed0b9087fa1f292634192b0f8d
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'src/vpp-api/vom/nat_static.cpp')
-rw-r--r-- | src/vpp-api/vom/nat_static.cpp | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/src/vpp-api/vom/nat_static.cpp b/src/vpp-api/vom/nat_static.cpp index 3185b56e228..bf8573d333e 100644 --- a/src/vpp-api/vom/nat_static.cpp +++ b/src/vpp-api/vom/nat_static.cpp @@ -22,7 +22,7 @@ singular_db<nat_static::key_t, nat_static> nat_static::m_db; nat_static::event_handler nat_static::m_evh; nat_static::nat_static(const boost::asio::ip::address& inside, - const boost::asio::ip::address_v4& outside) + const boost::asio::ip::address& outside) : m_hw(false) , m_rd(route_domain::get_default()) , m_inside(inside) @@ -32,7 +32,7 @@ nat_static::nat_static(const boost::asio::ip::address& inside, nat_static::nat_static(const route_domain& rd, const boost::asio::ip::address& inside, - const boost::asio::ip::address_v4& outside) + const boost::asio::ip::address& outside) : m_hw(false) , m_rd(rd.singular()) , m_inside(inside) @@ -74,7 +74,10 @@ nat_static::sweep() if (m_hw) { if (m_inside.is_v4()) { HW::enqueue(new nat_static_cmds::delete_44_cmd( - m_hw, m_rd->table_id(), m_inside.to_v4(), m_outside)); + m_hw, m_rd->table_id(), m_inside.to_v4(), m_outside.to_v4())); + } else { + HW::enqueue(new nat_static_cmds::delete_66_cmd( + m_hw, m_rd->table_id(), m_inside.to_v6(), m_outside.to_v6())); } } HW::write(); @@ -86,7 +89,10 @@ nat_static::replay() if (m_hw) { if (m_inside.is_v4()) { HW::enqueue(new nat_static_cmds::create_44_cmd( - m_hw, m_rd->table_id(), m_inside.to_v4(), m_outside)); + m_hw, m_rd->table_id(), m_inside.to_v4(), m_outside.to_v4())); + } else { + HW::enqueue(new nat_static_cmds::create_66_cmd( + m_hw, m_rd->table_id(), m_inside.to_v6(), m_outside.to_v6())); } } } @@ -100,7 +106,10 @@ nat_static::update(const nat_static& r) if (rc_t::OK != m_hw.rc()) { if (m_inside.is_v4()) { HW::enqueue(new nat_static_cmds::create_44_cmd( - m_hw, m_rd->table_id(), m_inside.to_v4(), m_outside)); + m_hw, m_rd->table_id(), m_inside.to_v4(), m_outside.to_v4())); + } else { + HW::enqueue(new nat_static_cmds::create_66_cmd( + m_hw, m_rd->table_id(), m_inside.to_v6(), m_outside.to_v6())); } } } @@ -158,20 +167,43 @@ nat_static::event_handler::handle_populate(const client_db::key_t& key) /* * dump VPP current states */ - std::shared_ptr<nat_static_cmds::dump_44_cmd> cmd = + std::shared_ptr<nat_static_cmds::dump_44_cmd> cmd44 = std::make_shared<nat_static_cmds::dump_44_cmd>(); - HW::enqueue(cmd); + HW::enqueue(cmd44); HW::write(); - for (auto& record : *cmd) { + for (auto& record : *cmd44) { auto& payload = record.get_payload(); boost::asio::ip::address inside = from_bytes(0, payload.local_ip_address); boost::asio::ip::address outside = from_bytes(0, payload.external_ip_address); - nat_static n(route_domain(payload.vrf_id), inside, outside.to_v4()); + nat_static n(route_domain(payload.vrf_id), inside, outside); + + /* + * Write each of the discovered mappings into the OM, + * but disable the HW Command q whilst we do, so that no + * commands are sent to VPP + */ + OM::commit(key, n); + } + + std::shared_ptr<nat_static_cmds::dump_66_cmd> cmd66 = + std::make_shared<nat_static_cmds::dump_66_cmd>(); + + HW::enqueue(cmd66); + HW::write(); + + for (auto& record : *cmd66) { + + auto& payload = record.get_payload(); + + boost::asio::ip::address inside = from_bytes(1, payload.local_ip_address); + boost::asio::ip::address outside = + from_bytes(1, payload.external_ip_address); + nat_static n(route_domain(payload.vrf_id), inside, outside); /* * Write each of the discovered mappings into the OM, |