Skip to content

Commit

Permalink
Changes to the ipv4 connectivity task:
Browse files Browse the repository at this point in the history
- For route tunnel, the ability to set the IpIp type (new flow type) has been added
- In controlplane.conf, the ability to set the tunnel type for writing route table has been added
  • Loading branch information
stal76 committed Nov 19, 2024
1 parent bc540b7 commit 88335ed
Show file tree
Hide file tree
Showing 19 changed files with 147 additions and 54 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
steps:
- ipv6Update: "::/0 -> 3333::2"
- cli:
- neighbor insert route0 kni0.200 c0de::200:1 00:00:00:00:00:02
- neighbor flush
- cli:
- rib static insert default 1.0.0.0/24 8888::1 1100 10000 1 1
- rib static insert default 1.0.0.0/24 4444::1 1100 10000 1 1
- rib_insert:
attribute:
protocol: autotest
Expand All @@ -12,19 +10,18 @@ steps:
large_communities:
- 13238:1:1
prefixes:
- nexthop: 8888::2
- nexthop: 5555::1
prefix: 2.0.0.0/24
path_information: 88.88.88.1:10001
path_information: 55.55.55.1:10001
labels:
- 1200
- ipv6Update:
- "::/0 -> c0de::200:1"
- cli:
- rib prefixes
- route tunnel lookup route0 1.0.0.1
- route tunnel lookup route0 2.0.0.1
- sendPackets:
- port: kni0
send: 001-send.pcap
expect: 001-expect.pcap

- sendPackets:
- port: kni0
send: 002-send.pcap
expect: 002-expect.pcap
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,35 @@
"physicalPort": "kni0",
"vlanId": "100",
"macAddress": "00:11:22:33:44:55",
"nextModule": "acl0"
"nextModule": "acl_route_tunnel"
},
"lp0.200": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "200",
"macAddress": "00:11:22:33:44:55",
"nextModule": "acl0"
"nextModule": "acl_route_tunnel_ipip"
},
"acl0": {
"lp0.300": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "300",
"macAddress": "00:11:22:33:44:55",
"nextModule": "acl_decap"
},
"acl_route_tunnel": {
"type": "acl",
"nextModules": [
"route0:tunnel"
]
},
"acl_route_tunnel_ipip": {
"type": "acl",
"nextModules": [
"route0:tunnel_ipip"
]
},
"acl_decap": {
"type": "acl",
"nextModules": [
"decap0"
Expand All @@ -23,28 +42,39 @@
"decap0": {
"type": "decap",
"ipv6DestinationPrefixes": [
"2222::cccc/128"
"3333::1"
],
"ipv6_enabled": true,
"nextModule": "route0:tunnel"
"nextModule": "route0"
},
"route0": {
"type": "route",
"ipv4SourceAddress": "10.50.0.1",
"ipv6SourceAddress": "2222:1111:0:1234:5678:0101:ca11:ca11",
"ipv6SourceAddress": "3333::1",
"udpDestinationPort": 6635,
"interfaces": {
"kni0.100": {
"ipAddresses": [
"11.0.0.2/24"
"10.0.1.1/24"
],
"neighborIPv4Address": "10.0.1.2",
"neighborMacAddress": "00:00:00:00:00:01",
"nextModule": "lp0.100"
},
"kni0.200": {
"ipAddresses": [
"c0de::200:2/96"
"10.0.2.1/24"
],
"neighborIPv4Address": "10.0.2.2",
"neighborMacAddress": "00:00:00:00:00:02",
"nextModule": "lp0.200"
},
"kni0.300": {
"ipAddresses": [
"3333::1/96"
],
"neighborIPv6Address": "3333::2",
"neighborMacAddress": "00:00:00:00:00:03",
"nextModule": "lp0.300"
}
},
"peers": {
Expand Down
24 changes: 18 additions & 6 deletions autotest/units/001_one_port/076_rfc_5549_route_tunnel/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,24 @@ def write_pcap(filename, *packetsList):
wrpcap(filename, [p for p in packets], append=True)


# Check decapsulator for IpIp tunnel
write_pcap("001-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IPv6(dst="2222::cccc", src="::1")/IP(dst="1.0.0.1", src="0.0.0.0", ttl=64)/ICMP(),
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IPv6(dst="2222::cccc", src="::1", fl=1)/IP(dst="1.0.0.1", src="0.0.0.0", ttl=64, tos=17)/ICMP(),
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IPv6(dst="2222::cccc", src="::1")/IP(dst="2.0.0.1", src="0.0.0.0", ttl=64)/ICMP())
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:0c:00")/Dot1Q(vlan=300)/IPv6(dst="3333::1", src="4444::1")/IP(dst="10.0.1.2", src="10.10.0.10", ttl=64)/ICMP(),
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:0c:00")/Dot1Q(vlan=300)/IPv6(dst="3333::1", src="4444::1")/IP(dst="10.0.2.2", src="10.10.0.10", ttl=64)/ICMP())

write_pcap("001-expect.pcap",
Ether(dst="00:00:00:00:00:02", src="00:11:22:33:44:55")/Dot1Q(vlan=200)/IPv6(dst="8888::1", src="2222:1111:0:1234:5678:0101:ca11:ca11")/UDP(dport=6635, sport=0xaa6c | 0xc000, chksum=0)/MPLS(label=1100, ttl=255)/IP(dst="1.0.0.1", src="0.0.0.0", ttl=63)/ICMP(),
Ether(dst="00:00:00:00:00:02", src="00:11:22:33:44:55")/Dot1Q(vlan=200)/IPv6(dst="8888::1", src="2222:1111:0:1234:5678:0101:ca11:ca11", tc=17)/UDP(dport=6635, sport=0x00d4 | 0xc000, chksum=0)/MPLS(label=1100, ttl=255)/IP(dst="1.0.0.1", src="0.0.0.0", ttl=63, tos=17)/ICMP(),
Ether(dst="00:00:00:00:00:02", src="00:11:22:33:44:55")/Dot1Q(vlan=200)/IPv6(dst="8888::2", src="2222:1111:0:1234:5678:0101:ca11:ca11")/UDP(dport=6635, sport=0x1072 | 0xc000, chksum=0)/MPLS(label=1200, ttl=255)/IP(dst="2.0.0.1", src="0.0.0.0", ttl=63)/ICMP())
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IP(dst="10.0.1.2", src="10.10.0.10", ttl=63)/ICMP(),
Ether(dst="00:00:00:00:00:02", src="00:11:22:33:44:55")/Dot1Q(vlan=200)/IP(dst="10.0.2.2", src="10.10.0.10", ttl=63)/ICMP())

# Check route tunnel mpls over udp + tunnel ipip
write_pcap("002-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IP(dst="1.0.0.1", src="10.0.1.2", ttl=64)/ICMP(),
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IP(dst="2.0.0.1", src="10.0.1.2", ttl=64)/ICMP(),
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IP(dst="1.0.0.1", src="10.0.2.2", ttl=64)/ICMP(),
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IP(dst="2.0.0.1", src="10.0.2.2", ttl=64)/ICMP())

write_pcap("002-expect.pcap",
Ether(dst="00:00:00:00:00:03", src="00:11:22:33:44:55")/Dot1Q(vlan=300)/IPv6(dst="4444::1", src="3333::1")/UDP(dport=6635, sport=0xca71, chksum=0)/MPLS(label=1100, ttl=255)/IP(dst="1.0.0.1", src="10.0.1.2", ttl=63)/ICMP(),
Ether(dst="00:00:00:00:00:03", src="00:11:22:33:44:55")/Dot1Q(vlan=300)/IPv6(dst="5555::1", src="3333::1")/UDP(dport=6635, sport=0xf06f, chksum=0)/MPLS(label=1200, ttl=255)/IP(dst="2.0.0.1", src="10.0.1.2", ttl=63)/ICMP(),
Ether(dst="00:00:00:00:00:03", src="00:11:22:33:44:55")/Dot1Q(vlan=300)/IPv6(dst="4444::1", src="3333::1")/IP(dst="1.0.0.1", src="10.0.2.2", ttl=63)/ICMP(),
Ether(dst="00:00:00:00:00:03", src="00:11:22:33:44:55")/Dot1Q(vlan=300)/IPv6(dst="5555::1", src="3333::1")/IP(dst="2.0.0.1", src="10.0.2.2", ttl=63)/ICMP())
2 changes: 1 addition & 1 deletion cli/rib.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void insert(const std::string& vrf,
std::set<common::large_community_t> large_communities;
if (weight)
{
large_communities.emplace(13238, 1, *weight); ///< @todo: DEFINE
large_communities.emplace(YANET_DEFAULT_BGP_AS, 1, *weight);
}

common::icp::rib_update::insert insert = {"static",
Expand Down
4 changes: 4 additions & 0 deletions common/define.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ extern LogPriority logPriority;
#define YANET_RIB_PRIORITY_ROUTE_TUNNEL_FALLBACK ((uint32_t)11000)
#define YANET_RIB_PRIORITY_ROUTE_REPEAT ((uint32_t)12000)

#define YANET_DEFAULT_BGP_AS 13238
#define YANET_STATIC_ROUTE_TUNNEL_LABEL 3199
#define YANET_STATIC_ROUTE_TUNNEL_PATH_INFORMATION "127.0.0.1:10000"

#define YANET_NETWORK_FLAG_FRAGMENT ((uint8_t)(1u << 0))
#define YANET_NETWORK_FLAG_NOT_FIRST_FRAGMENT ((uint8_t)(1u << 1))
#define YANET_NETWORK_FLAG_HAS_EXTENSION ((uint8_t)(1u << 2))
Expand Down
3 changes: 3 additions & 0 deletions common/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,7 @@ enum class eFlowType : uint8_t
route,
route_local,
route_tunnel,
route_tunnel_ipip,
acl_egress,
dregress,
controlPlane,
Expand Down Expand Up @@ -2201,6 +2202,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
1 change: 1 addition & 0 deletions controlplane/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ class base_rib
public:
ip_prefix_t prefix;
ip_address_t nexthop;
bool is_tunnel;
};

//
Expand Down
18 changes: 18 additions & 0 deletions controlplane/configconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ void config_converter_t::convertToFlow(const std::string& nextModule,
throw error_result_t(eResult::invalidFlow, "invalid entry (tunnel not configured)");
}
}
else if (entry == "tunnel_ipip")
{
flow.type = common::globalBase::eFlowType::route_tunnel_ipip;

if (!it->second.tunnel_enabled)
{
throw error_result_t(eResult::invalidFlow, "invalid entry (tunnel not configured)");
}
}
else
{
throw error_result_t(eResult::invalidFlow, "invalid entry: " + entry);
Expand Down Expand Up @@ -460,6 +469,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 @@ -490,6 +500,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 @@ -515,6 +526,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 @@ -539,6 +551,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 @@ -598,6 +611,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 @@ -768,6 +782,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
1 change: 1 addition & 0 deletions controlplane/configparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,7 @@ void config_parser_t::loadConfig_rib(controlplane::base_t& baseNext,
controlplane::base_rib base_rib;
base_rib.prefix = json_rib_item["prefix"].get<std::string>();
base_rib.nexthop = json_rib_item["nexthop"].get<std::string>();
base_rib.is_tunnel = (exist(json_rib_item, "tunnel") && json_rib_item["tunnel"].get<bool>());

vrf.emplace_back(std::move(base_rib));
}
Expand Down
2 changes: 1 addition & 1 deletion controlplane/dregress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void dregress_t::prefix_insert(const std::tuple<std::string, uint32_t>& vrf_prio
{
try
{
communities.emplace(13238, std::stoll(path_info.substr(pi_it + 1), nullptr, 0)); ///< @todo: remove 13238, and use RD
communities.emplace(YANET_DEFAULT_BGP_AS, std::stoll(path_info.substr(pi_it + 1), nullptr, 0));
}
catch (...)
{
Expand Down
19 changes: 15 additions & 4 deletions controlplane/rib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,21 @@ void rib_t::reload(const controlplane::base_t& base_prev,

for (const auto& rib_item : rib_items)
{
auto& prefixes = std::get<3>(request_insert)[{ip_address_t("::"), "", 0, {}, {}, {}, 0}]
[""]
[rib_item.nexthop];
prefixes.emplace_back(rib_item.prefix, "", std::vector<uint32_t>());
if (rib_item.is_tunnel)
{
common::large_community_t large_community(YANET_DEFAULT_BGP_AS, 1, 1);
auto& prefixes = std::get<3>(request_insert)[{ip_address_t("::"), "", 0, {}, {}, {large_community}, 0}]
[""]
[rib_item.nexthop];
prefixes.emplace_back(rib_item.prefix, YANET_STATIC_ROUTE_TUNNEL_PATH_INFORMATION, std::vector<uint32_t>(1, YANET_STATIC_ROUTE_TUNNEL_LABEL));
}
else
{
auto& prefixes = std::get<3>(request_insert)[{ip_address_t("::"), "", 0, {}, {}, {}, 0}]
[""]
[rib_item.nexthop];
prefixes.emplace_back(rib_item.prefix, "", std::vector<uint32_t>());
}
}

request.emplace_back(std::move(request_insert));
Expand Down
4 changes: 2 additions & 2 deletions controlplane/route.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ void route_t::tunnel_prefix_update(const std::tuple<std::string, uint32_t>& vrf_

for (const auto& large_community : large_communities)
{
if (large_community.value[0] == 13238 && ///< @todo: DEFINE
if (large_community.value[0] == YANET_DEFAULT_BGP_AS &&
large_community.value[1] == 1) ///< @todo: DEFINE
{
weight = large_community.value[2];
}

if (large_community.value[0] == 13238 && ///< @todo: DEFINE
if (large_community.value[0] == YANET_DEFAULT_BGP_AS &&
large_community.value[1] == 1000) ///< @todo: DEFINE
{
override_length = large_community.value[2];
Expand Down
8 changes: 7 additions & 1 deletion dataplane/globalbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,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 @@ -862,6 +863,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 @@ -964,6 +966,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 @@ -1134,6 +1137,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 @@ -1235,6 +1239,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 @@ -1343,6 +1348,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 @@ -542,6 +542,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
Loading

0 comments on commit 88335ed

Please sign in to comment.