Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ipv4 connectivity #262

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions common/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,7 @@ enum class eFlowType : uint8_t
route,
route_local,
route_tunnel,
route_tunnel_ipip,
acl_egress,
dregress,
controlPlane,
Expand Down Expand Up @@ -2084,6 +2085,8 @@ inline const char* eFlowType_toString(eFlowType t)
return "route_local";
case eFlowType::route_tunnel:
return "route_tunnel";
case eFlowType::route_tunnel_ipip:
return "route_tunnel_ipip";
case eFlowType::acl_egress:
return "acl_egress";
case eFlowType::dregress:
Expand Down
13 changes: 11 additions & 2 deletions controlplane/configconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ void config_converter_t::convertToFlow(const std::string& nextModule,
{
flow.type = common::globalBase::eFlowType::route_local;
}
else if (entry == "tunnel")
else if (entry == "tunnel" || entry == "tunnel_ipip")
{
flow.type = common::globalBase::eFlowType::route_tunnel;
flow.type = (entry == "tunnel" ? common::globalBase::eFlowType::route_tunnel : common::globalBase::eFlowType::route_tunnel_ipip);

if (!it->second.tunnel_enabled)
{
Expand Down Expand Up @@ -458,6 +458,7 @@ void config_converter_t::processDecap()

if (decap.flow.type != common::globalBase::eFlowType::route &&
decap.flow.type != common::globalBase::eFlowType::route_tunnel &&
decap.flow.type != common::globalBase::eFlowType::route_tunnel_ipip &&
decap.flow.type != common::globalBase::eFlowType::controlPlane &&
decap.flow.type != common::globalBase::eFlowType::drop)
{
Expand Down Expand Up @@ -488,6 +489,7 @@ void config_converter_t::processNat64stateful()

if (nat64stateful.flow.type != common::globalBase::eFlowType::route &&
nat64stateful.flow.type != common::globalBase::eFlowType::route_tunnel &&
nat64stateful.flow.type != common::globalBase::eFlowType::route_tunnel_ipip &&
nat64stateful.flow.type != common::globalBase::eFlowType::controlPlane &&
nat64stateful.flow.type != common::globalBase::eFlowType::drop)
{
Expand All @@ -513,6 +515,7 @@ void config_converter_t::processTun64()

if (tunnel.flow.type != common::globalBase::eFlowType::route &&
tunnel.flow.type != common::globalBase::eFlowType::route_tunnel &&
tunnel.flow.type != common::globalBase::eFlowType::route_tunnel_ipip &&
tunnel.flow.type != common::globalBase::eFlowType::controlPlane &&
tunnel.flow.type != common::globalBase::eFlowType::drop)
{
Expand All @@ -537,6 +540,7 @@ void config_converter_t::processNat64()

if (nat64stateless.flow.type != common::globalBase::eFlowType::route &&
nat64stateless.flow.type != common::globalBase::eFlowType::route_tunnel &&
nat64stateless.flow.type != common::globalBase::eFlowType::route_tunnel_ipip &&
nat64stateless.flow.type != common::globalBase::eFlowType::controlPlane &&
nat64stateless.flow.type != common::globalBase::eFlowType::drop)
{
Expand Down Expand Up @@ -596,6 +600,7 @@ void config_converter_t::processNat46clat()

if (nat46clat.flow.type != common::globalBase::eFlowType::route &&
nat46clat.flow.type != common::globalBase::eFlowType::route_tunnel &&
nat46clat.flow.type != common::globalBase::eFlowType::route_tunnel_ipip &&
nat46clat.flow.type != common::globalBase::eFlowType::controlPlane &&
nat46clat.flow.type != common::globalBase::eFlowType::drop)
{
Expand Down Expand Up @@ -766,6 +771,10 @@ void config_converter_t::processAcl()
{
acl_rules_route_forward(acl, nextModule);
}
else if (entry == "tunnel_ipip")
{
acl_rules_route_forward(acl, nextModule);
}
else
{
acl_rules_route_local(acl, nextModule);
Expand Down
8 changes: 7 additions & 1 deletion dataplane/globalbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,8 @@ static bool checkFlow(const common::globalBase::tFlow& flow)
}
}
else if (flow.type == common::globalBase::eFlowType::route ||
flow.type == common::globalBase::eFlowType::route_tunnel)
flow.type == common::globalBase::eFlowType::route_tunnel ||
flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
if (flow.data.routeId >= CONFIG_YADECAP_ROUTES_SIZE)
{
Expand Down Expand Up @@ -837,6 +838,7 @@ eResult generation::tun64_update(const common::idp::updateGlobalBase::tun64_upda

if (flow.type != common::globalBase::eFlowType::route &&
flow.type != common::globalBase::eFlowType::route_tunnel &&
flow.type != common::globalBase::eFlowType::route_tunnel_ipip &&
flow.type != common::globalBase::eFlowType::controlPlane &&
flow.type != common::globalBase::eFlowType::drop)
{
Expand Down Expand Up @@ -939,6 +941,7 @@ eResult generation::updateDecap(const common::idp::updateGlobalBase::updateDecap
}
if (flow.type != common::globalBase::eFlowType::route &&
flow.type != common::globalBase::eFlowType::route_tunnel &&
flow.type != common::globalBase::eFlowType::route_tunnel_ipip &&
flow.type != common::globalBase::eFlowType::controlPlane &&
flow.type != common::globalBase::eFlowType::drop)
{
Expand Down Expand Up @@ -1109,6 +1112,7 @@ eResult generation::nat64stateful_update(const common::idp::updateGlobalBase::na
}
if (flow.type != common::globalBase::eFlowType::route &&
flow.type != common::globalBase::eFlowType::route_tunnel &&
flow.type != common::globalBase::eFlowType::route_tunnel_ipip &&
flow.type != common::globalBase::eFlowType::controlPlane &&
flow.type != common::globalBase::eFlowType::drop)
{
Expand Down Expand Up @@ -1210,6 +1214,7 @@ eResult generation::updateNat64stateless(const common::idp::updateGlobalBase::up
}
if (flow.type != common::globalBase::eFlowType::route &&
flow.type != common::globalBase::eFlowType::route_tunnel &&
flow.type != common::globalBase::eFlowType::route_tunnel_ipip &&
flow.type != common::globalBase::eFlowType::controlPlane &&
flow.type != common::globalBase::eFlowType::drop)
{
Expand Down Expand Up @@ -1318,6 +1323,7 @@ eResult generation::nat46clat_update(const common::idp::updateGlobalBase::nat46c

if (flow.type != common::globalBase::eFlowType::route &&
flow.type != common::globalBase::eFlowType::route_tunnel &&
flow.type != common::globalBase::eFlowType::route_tunnel_ipip &&
flow.type != common::globalBase::eFlowType::controlPlane &&
flow.type != common::globalBase::eFlowType::drop)
{
Expand Down
5 changes: 5 additions & 0 deletions dataplane/report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,11 @@ static inline nlohmann::json convertFlow(const common::globalBase::tFlow& flow)
result["type"] = "route_tunnel";
result["id"] = flow.data.routeId;
}
else if (flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
result["type"] = "route_tunnel_ipip";
result["id"] = flow.data.routeId;
}
else if (flow.type == common::globalBase::eFlowType::acl_egress)
{
result["type"] = "acl_egress";
Expand Down
22 changes: 11 additions & 11 deletions dataplane/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ inline void cWorker::logicalPort_ingress_flow(rte_mbuf* mbuf,
{
route_entry(mbuf);
}
else if (flow.type == common::globalBase::eFlowType::route_tunnel)
else if (flow.type == common::globalBase::eFlowType::route_tunnel || flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
route_tunnel_entry(mbuf);
}
Expand Down Expand Up @@ -1774,7 +1774,7 @@ inline void cWorker::acl_ingress_flow(rte_mbuf* mbuf,
{
route_entry(mbuf);
}
else if (flow.type == common::globalBase::eFlowType::route_tunnel)
else if (flow.type == common::globalBase::eFlowType::route_tunnel || flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
route_tunnel_entry(mbuf);
}
Expand Down Expand Up @@ -1951,7 +1951,7 @@ inline void cWorker::tun64_flow(rte_mbuf* mbuf,
{
route_entry(mbuf);
}
else if (flow.type == common::globalBase::eFlowType::route_tunnel)
else if (flow.type == common::globalBase::eFlowType::route_tunnel || flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
route_tunnel_entry(mbuf);
}
Expand Down Expand Up @@ -2021,7 +2021,7 @@ inline void cWorker::decap_flow(rte_mbuf* mbuf,
{
route_entry(mbuf);
}
else if (flow.type == common::globalBase::eFlowType::route_tunnel)
else if (flow.type == common::globalBase::eFlowType::route_tunnel || flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
route_tunnel_entry(mbuf);
}
Expand Down Expand Up @@ -3176,7 +3176,7 @@ inline void cWorker::nat64stateful_lan_flow(rte_mbuf* mbuf,
{
route_entry(mbuf);
}
else if (flow.type == common::globalBase::eFlowType::route_tunnel)
else if (flow.type == common::globalBase::eFlowType::route_tunnel || flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
route_tunnel_entry(mbuf);
}
Expand Down Expand Up @@ -3335,7 +3335,7 @@ inline void cWorker::nat64stateful_wan_flow(rte_mbuf* mbuf,
{
route_entry(mbuf);
}
else if (flow.type == common::globalBase::eFlowType::route_tunnel)
else if (flow.type == common::globalBase::eFlowType::route_tunnel || flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
route_tunnel_entry(mbuf);
}
Expand Down Expand Up @@ -3415,7 +3415,7 @@ inline void cWorker::nat64stateless_ingress_flow(rte_mbuf* mbuf,
{
route_entry(mbuf);
}
else if (flow.type == common::globalBase::eFlowType::route_tunnel)
else if (flow.type == common::globalBase::eFlowType::route_tunnel || flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
route_tunnel_entry(mbuf);
}
Expand Down Expand Up @@ -3534,7 +3534,7 @@ inline void cWorker::nat64stateless_egress_flow(rte_mbuf* mbuf,
{
route_entry(mbuf);
}
else if (flow.type == common::globalBase::eFlowType::route_tunnel)
else if (flow.type == common::globalBase::eFlowType::route_tunnel || flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
route_tunnel_entry(mbuf);
}
Expand Down Expand Up @@ -3706,7 +3706,7 @@ inline void cWorker::nat46clat_lan_flow(rte_mbuf* mbuf,
{
route_entry(mbuf);
}
else if (flow.type == common::globalBase::eFlowType::route_tunnel)
else if (flow.type == common::globalBase::eFlowType::route_tunnel || flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
route_tunnel_entry(mbuf);
}
Expand Down Expand Up @@ -3785,7 +3785,7 @@ inline void cWorker::nat46clat_wan_flow(rte_mbuf* mbuf,
{
route_entry(mbuf);
}
else if (flow.type == common::globalBase::eFlowType::route_tunnel)
else if (flow.type == common::globalBase::eFlowType::route_tunnel || flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
route_tunnel_entry(mbuf);
}
Expand Down Expand Up @@ -5829,7 +5829,7 @@ YANET_NEVER_INLINE void cWorker::slowWorkerFlow(rte_mbuf* mbuf,
{
route_entry(mbuf);
}
else if (flow.type == common::globalBase::eFlowType::route_tunnel)
else if (flow.type == common::globalBase::eFlowType::route_tunnel || flow.type == common::globalBase::eFlowType::route_tunnel_ipip)
{
route_tunnel_entry(mbuf);
}
Comment on lines -5832 to 5847
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, these functions can be greatly simplified if we'll just use switch instead of if-else.
It might even be better from performance point and we can utilize fallthrough instead of else if (a || b)

YANET_NEVER_INLINE void cWorker::slowWorkerFlow(rte_mbuf* mbuf,
                                                const common::globalBase::tFlow& flow)
{
	using common::globalBase::eFlowType;
	dataplane::metadata* metadata = YADECAP_METADATA(mbuf);
	metadata->flow = flow;

	switch (flow.type)
	{
		case eFlowType::acl_ingress:
			acl_ingress_entry(mbuf);
			break;

		case eFlowType::tun64_ipv4_checked:
			tun64_ipv4_checked(mbuf);
			break;

		case eFlowType::tun64_ipv6_checked:
			tun64_ipv6_checked(mbuf);
			break;

		case eFlowType::decap_checked:
			decap_entry_checked(mbuf);
			break;

		case eFlowType::nat64stateless_ingress_checked:
			nat64stateless_ingress_entry_checked(mbuf);
			break;

		case eFlowType::nat64stateless_ingress_icmp:
			nat64stateless_ingress_entry_icmp(mbuf);
			break;

		case eFlowType::nat64stateless_ingress_fragmentation:
			nat64stateless_ingress_entry_fragmentation(mbuf);
			break;

		case eFlowType::nat64stateless_egress_checked:
			nat64stateless_egress_entry_checked(mbuf);
			break;

		case eFlowType::nat64stateless_egress_icmp:
			nat64stateless_egress_entry_icmp(mbuf);
			break;

		case eFlowType::nat64stateless_egress_fragmentation:
			nat64stateless_egress_entry_fragmentation(mbuf);
			break;

		case eFlowType::nat64stateless_egress_farm:
			slowWorkerFarmHandleFragment(mbuf);
			break;

		case eFlowType::route:
			route_entry(mbuf);
			break;

		case eFlowType::route_tunnel:
		case eFlowType::route_tunnel_ipip:
			route_tunnel_entry(mbuf);
			break;

		case eFlowType::logicalPort_egress:
			logicalPort_egress_entry(mbuf);
			break;

		case eFlowType::controlPlane:
			controlPlane(mbuf);
			break;

		default:
			drop(mbuf);
			break;
	}
}

And same with similar functions

Expand Down