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
Open

Ipv4 connectivity #262

wants to merge 9 commits into from

Conversation

stal76
Copy link
Collaborator

@stal76 stal76 commented Dec 15, 2024

The following functionality has been added to this PR:

  • a new tunnel type - IpIp;
  • the ability to communicate between local subnets with route tunnel;
  • the ability to set route tunnel routes in controlplane.conf;
  • the ability to use random source address in route tunnel.

- Numeric values have been replaced in the code with the use of this constant.
- It would be nice to add the ability to set AS in the configuration file, but
  this is also used in the cli.
In this commit, only the definition of a new tunnel type has been added, the
behavior is still the same as for MPLS over UDP. The implementation of the
new behavior is done in the next commit.
In controlplane.conf, it was possible to set static routes for route. Added
the ability to also set routes for route tunnel, to do this, set the route:
	"tunnel": true
One can also set the path_information and label parameters. If these parameters
are not set, the default values will be used.
- Added comments to some type fields.
- Formatting of long function definitions has been changed.
- Replaced std::tuple<std::string, uint32_t> with rib:: vrf_priority_t.
When route tunnel is enabled, tunneling will be used for all subnets. But this
does not need to be done for local subnets. To do this, the subnet must be set
in the localPrefixes section.
The old autotest for ipv4/ipv6 MPLS over UDP has also been simplified.
A similar feature was available in tun64 and balancer. The ipv6 src address
from 65 to 96 bits is written to the ipv4 src of the original packet.
Comment on lines +122 to +124
#define YANET_DEFAULT_BGP_AS ((uint32_t)13238)
#define YANET_DEFAULT_ROUTE_TUNNEL_LABEL ((uint32_t)3199)
#define YANET_DEFAULT_ROUTE_TUNNEL_PATH_INFORMATION "127.0.0.1:10000"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#define YANET_DEFAULT_BGP_AS ((uint32_t)13238)
#define YANET_DEFAULT_ROUTE_TUNNEL_LABEL ((uint32_t)3199)
#define YANET_DEFAULT_ROUTE_TUNNEL_PATH_INFORMATION "127.0.0.1:10000"
inline constexpr uint32_t YANET_DEFAULT_BGP_AS = 13238;
inline constexpr uint32_t YANET_DEFAULT_ROUTE_TUNNEL_LABEL = 3199;
inline constexpr auto YANET_DEFAULT_ROUTE_TUNNEL_PATH_INFORMATION = "127.0.0.1:10000";

Comment on lines -5832 to 5835
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);
}
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

Comment on lines +1903 to +1908
base_rib.is_tunnel = (exist(json_rib_item, "tunnel") && json_rib_item["tunnel"].get<bool>());
if (base_rib.is_tunnel)
{
base_rib.path_information = (exist(json_rib_item, "path_information") ? json_rib_item["path_information"].get<std::string>() : YANET_DEFAULT_ROUTE_TUNNEL_PATH_INFORMATION);
base_rib.label = (exist(json_rib_item, "label") ? json_rib_item["label"].get<uint32_t>() : YANET_DEFAULT_ROUTE_TUNNEL_LABEL);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

nlohman lib has value method for this purpose, to extract value if it exists, or set default value if it does not:

base_rib.is_tunnel = json_rib_item.value("tunnel", false);

if (base_rib.is_tunnel)
{
    base_rib.path_information = json_rib_item.value("path_information", YANET_DEFAULT_ROUTE_TUNNEL_PATH_INFORMATION);
    base_rib.label = json_rib_item.value("label", YANET_DEFAULT_ROUTE_TUNNEL_LABEL);
}

Comment on lines +370 to +373
if (exist(moduleJson, "random_source"))
{
route.random_source = moduleJson["random_source"].get<bool>();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (exist(moduleJson, "random_source"))
{
route.random_source = moduleJson["random_source"].get<bool>();
}
route.random_source = moduleJson.value("random_source", false);

@ol-imorozko
Copy link
Collaborator

overall LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants