GBPv6: NAT66 actions for GBP

Change-Id: I379150a88f2d53d6281be41e8bad6fc4f4e88a71
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
This commit is contained in:
Neale Ranns
2018-04-24 07:45:33 -07:00
committed by Damjan Marion
parent 99ed486d1e
commit 4a6d02337b
6 changed files with 334 additions and 191 deletions
+12 -1
View File
@@ -92,6 +92,16 @@ gbp_policy_dpo_unlock (dpo_id_t * dpo)
}
}
static u32
gbp_policy_dpo_get_urpf (const dpo_id_t * dpo)
{
gbp_policy_dpo_t *gpd;
gpd = gbp_policy_dpo_get_from_dpo (dpo);
return (gpd->gpd_sw_if_index);
}
void
gbp_policy_dpo_add_or_lock (dpo_proto_t dproto,
epg_id_t epg, u32 sw_if_index, dpo_id_t * dpo)
@@ -138,6 +148,7 @@ const static dpo_vft_t gbp_policy_dpo_vft = {
.dv_lock = gbp_policy_dpo_lock,
.dv_unlock = gbp_policy_dpo_unlock,
.dv_format = format_gbp_policy_dpo,
.dv_get_urpf = gbp_policy_dpo_get_urpf,
};
/**
@@ -499,7 +510,7 @@ VLIB_NODE_FUNCTION_MULTIARCH (gbp_ip4_lpm_classify_node, gbp_ip4_lpm_classify);
VLIB_REGISTER_NODE (gbp_ip6_lpm_classify_node) = {
.function = gbp_ip6_lpm_classify,
.name = "ip6-gpb-lpm-classify",
.name = "ip6-gbp-lpm-classify",
.vector_size = sizeof (u32),
.format_trace = format_gbp_classify_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
+1 -1
View File
@@ -2072,7 +2072,7 @@ fib_path_get_resolving_interface (fib_node_index_t path_index)
case FIB_PATH_TYPE_BIER_IMP:
break;
}
return (~0);
return (dpo_get_urpf(&path->fp_dpo));
}
index_t
+54 -12
View File
@@ -85,11 +85,20 @@ nat_binding::sweep()
{
if (m_binding) {
if (direction_t::INPUT == m_dir) {
HW::enqueue(new nat_binding_cmds::unbind_44_input_cmd(
m_binding, m_itf->handle(), m_zone));
if (l3_proto_t::IPV4 == m_proto) {
HW::enqueue(new nat_binding_cmds::unbind_44_input_cmd(
m_binding, m_itf->handle(), m_zone));
} else {
HW::enqueue(new nat_binding_cmds::unbind_66_input_cmd(
m_binding, m_itf->handle(), m_zone));
}
} else {
HW::enqueue(new nat_binding_cmds::unbind_44_output_cmd(
m_binding, m_itf->handle(), m_zone));
if (l3_proto_t::IPV4 == m_proto) {
HW::enqueue(new nat_binding_cmds::unbind_44_output_cmd(
m_binding, m_itf->handle(), m_zone));
} else {
VOM_LOG(log_level_t::ERROR) << "NAT 66 output feature not supported";
}
}
}
HW::write();
@@ -100,11 +109,20 @@ nat_binding::replay()
{
if (m_binding) {
if (direction_t::INPUT == m_dir) {
HW::enqueue(new nat_binding_cmds::bind_44_input_cmd(
m_binding, m_itf->handle(), m_zone));
if (l3_proto_t::IPV4 == m_proto) {
HW::enqueue(new nat_binding_cmds::bind_44_input_cmd(
m_binding, m_itf->handle(), m_zone));
} else {
HW::enqueue(new nat_binding_cmds::bind_66_input_cmd(
m_binding, m_itf->handle(), m_zone));
}
} else {
HW::enqueue(new nat_binding_cmds::bind_44_output_cmd(
m_binding, m_itf->handle(), m_zone));
if (l3_proto_t::IPV4 == m_proto) {
HW::enqueue(new nat_binding_cmds::bind_44_output_cmd(
m_binding, m_itf->handle(), m_zone));
} else {
VOM_LOG(log_level_t::ERROR) << "NAT 66 output feature not supported";
}
}
}
}
@@ -117,11 +135,20 @@ nat_binding::update(const nat_binding& desired)
*/
if (!m_binding) {
if (direction_t::INPUT == m_dir) {
HW::enqueue(new nat_binding_cmds::bind_44_input_cmd(
m_binding, m_itf->handle(), m_zone));
if (l3_proto_t::IPV4 == m_proto) {
HW::enqueue(new nat_binding_cmds::bind_44_input_cmd(
m_binding, m_itf->handle(), m_zone));
} else {
HW::enqueue(new nat_binding_cmds::bind_66_input_cmd(
m_binding, m_itf->handle(), m_zone));
}
} else {
HW::enqueue(new nat_binding_cmds::bind_44_output_cmd(
m_binding, m_itf->handle(), m_zone));
if (l3_proto_t::IPV4 == m_proto) {
HW::enqueue(new nat_binding_cmds::bind_44_output_cmd(
m_binding, m_itf->handle(), m_zone));
} else {
VOM_LOG(log_level_t::ERROR) << "NAT 66 output feature not supported";
}
}
}
}
@@ -214,6 +241,21 @@ nat_binding::event_handler::handle_populate(const client_db::key_t& key)
zone_t::from_vpp(payload.is_inside));
OM::commit(key, nb);
}
std::shared_ptr<nat_binding_cmds::dump_input_66_cmd> i6cmd =
std::make_shared<nat_binding_cmds::dump_input_66_cmd>();
HW::enqueue(i6cmd);
HW::write();
for (auto& record : *i6cmd) {
auto& payload = record.get_payload();
std::shared_ptr<interface> itf = interface::find(payload.sw_if_index);
nat_binding nb(*itf, direction_t::INPUT, l3_proto_t::IPV6,
zone_t::from_vpp(payload.is_inside));
OM::commit(key, nb);
}
}
dependency_t
+118 -2
View File
@@ -214,7 +214,7 @@ dump_input_44_cmd::issue(connection& con)
std::string
dump_input_44_cmd::to_string() const
{
return ("nat-input-binding-dump");
return ("nat-44-input-binding-dump");
}
dump_output_44_cmd::dump_output_44_cmd()
@@ -246,7 +246,123 @@ dump_output_44_cmd::issue(connection& con)
std::string
dump_output_44_cmd::to_string() const
{
return ("nat-output-binding-dump");
return ("nat-44-output-binding-dump");
}
bind_66_input_cmd::bind_66_input_cmd(HW::item<bool>& item,
const handle_t& itf,
const nat_binding::zone_t& zone)
: rpc_cmd(item)
, m_itf(itf)
, m_zone(zone)
{
}
bool
bind_66_input_cmd::operator==(const bind_66_input_cmd& other) const
{
return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
}
rc_t
bind_66_input_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
auto& payload = req.get_request().get_payload();
payload.is_add = 1;
payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
payload.sw_if_index = m_itf.value();
VAPI_CALL(req.execute());
m_hw_item.set(wait());
return rc_t::OK;
}
std::string
bind_66_input_cmd::to_string() const
{
std::ostringstream s;
s << "nat-66-input-binding-create: " << m_hw_item.to_string()
<< " itf:" << m_itf << " " << m_zone.to_string();
return (s.str());
}
unbind_66_input_cmd::unbind_66_input_cmd(HW::item<bool>& item,
const handle_t& itf,
const nat_binding::zone_t& zone)
: rpc_cmd(item)
, m_itf(itf)
, m_zone(zone)
{
}
bool
unbind_66_input_cmd::operator==(const unbind_66_input_cmd& other) const
{
return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
}
rc_t
unbind_66_input_cmd::issue(connection& con)
{
msg_t req(con.ctx(), std::ref(*this));
auto& payload = req.get_request().get_payload();
payload.is_add = 0;
payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
payload.sw_if_index = m_itf.value();
VAPI_CALL(req.execute());
m_hw_item.set(wait());
return rc_t::OK;
}
std::string
unbind_66_input_cmd::to_string() const
{
std::ostringstream s;
s << "nat-66-input-binding-create: " << m_hw_item.to_string()
<< " itf:" << m_itf << " " << m_zone.to_string();
return (s.str());
}
dump_input_66_cmd::dump_input_66_cmd()
{
}
dump_input_66_cmd::dump_input_66_cmd(const dump_input_66_cmd& d)
{
}
bool
dump_input_66_cmd::operator==(const dump_input_66_cmd& other) const
{
return (true);
}
rc_t
dump_input_66_cmd::issue(connection& con)
{
m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
VAPI_CALL(m_dump->execute());
wait();
return rc_t::OK;
}
std::string
dump_input_66_cmd::to_string() const
{
return ("nat-66-input-binding-dump");
}
}; // namespace nat_binding_cmds
-118
View File
@@ -336,90 +336,6 @@ private:
const nat_binding::zone_t m_zone;
};
/**
* A functor class that binds a NAT configuration to an output interface
*/
/* class bind_66_output_cmd */
/* : public rpc_cmd<HW::item<bool>, */
/* rc_t, */
/* vapi::Nat66_interface_add_del_output_feature> */
/* { */
/* public: */
/* /\** */
/* * Constructor */
/* *\/ */
/* bind_66_output_cmd(HW::item<bool>& item, */
/* const handle_t& itf, */
/* const nat_binding::zone_t& zone); */
/* /\** */
/* * Issue the command to VPP/HW */
/* *\/ */
/* rc_t issue(connection& con); */
/* /\** */
/* * convert to string format for debug purposes */
/* *\/ */
/* std::string to_string() const; */
/* /\** */
/* * Comparison operator - only used for UT */
/* *\/ */
/* bool operator==(const bind_66_output_cmd& i) const; */
/* private: */
/* /\** */
/* * The interface to bind */
/* *\/ */
/* const handle_t m_itf; */
/* /\** */
/* * The zone the interface is in */
/* *\/ */
/* const nat_binding::zone_t m_zone; */
/* }; */
/* /\** */
/* * A cmd class that unbinds a NAT configuration from an output interface */
/* *\/ */
/* class unbind_66_output_cmd */
/* : public rpc_cmd<HW::item<bool>, */
/* rc_t, */
/* vapi::Nat66_interface_add_del_output_feature> */
/* { */
/* public: */
/* /\** */
/* * Constructor */
/* *\/ */
/* unbind_66_output_cmd(HW::item<bool>& item, */
/* const handle_t& itf, */
/* const nat_binding::zone_t& zone); */
/* /\** */
/* * Issue the command to VPP/HW */
/* *\/ */
/* rc_t issue(connection& con); */
/* /\** */
/* * convert to string format for debug purposes */
/* *\/ */
/* std::string to_string() const; */
/* /\** */
/* * Comparison operator - only used for UT */
/* *\/ */
/* bool operator==(const unbind_66_output_cmd& i) const; */
/* private: */
/* /\** */
/* * The interface to bind */
/* *\/ */
/* const handle_t m_itf; */
/* /\** */
/* * The zone the interface is in */
/* *\/ */
/* const nat_binding::zone_t m_zone; */
/* }; */
/**
* A cmd class that Dumps all the nat_statics
*/
@@ -453,40 +369,6 @@ private:
HW::item<bool> item;
};
/**
* A cmd class that Dumps all the nat_statics
*/
/* class dump_output_66_cmd */
/* : public dump_cmd<vapi::Nat66_interface_output_feature_dump> */
/* { */
/* public: */
/* /\** */
/* * Constructor */
/* *\/ */
/* dump_output_66_cmd(); */
/* dump_output_66_cmd(const dump_output_66_cmd& d); */
/* /\** */
/* * Issue the command to VPP/HW */
/* *\/ */
/* rc_t issue(connection& con); */
/* /\** */
/* * convert to string format for debug purposes */
/* *\/ */
/* std::string to_string() const; */
/* /\** */
/* * Comparison operator - only used for UT */
/* *\/ */
/* bool operator==(const dump_output_66_cmd& i) const; */
/* private: */
/* /\** */
/* * HW reutrn code */
/* *\/ */
/* HW::item<bool> item; */
/* }; */
}; // namespace nat_binding_cmds
}; // namespace VOM
+149 -57
View File
File diff suppressed because it is too large Load Diff