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
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ steps:
- port: kni0
send: 001-send.pcap
expect: 001-expect.pcap

- cli:
- rib static remove default 1.0.0.0/24 c0de::200:1 1001

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 0.0.0.0/0 4444::1 1100 10000 1 1
- rib_insert:
attribute:
protocol: autotest
Expand All @@ -12,19 +10,16 @@ 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 @@ -14,44 +14,70 @@
"macAddress": "00:11:22:33:44:55",
"nextModule": "acl0"
},
"lp0.300": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "300",
"macAddress": "00:11:22:33:44:55",
"nextModule": "acl0"
},
"acl0": {
"type": "acl",
"nextModules": [
"decap0"
"decap0",
"route0:tunnel"
]
},
"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"
],
"acl": "acl0",
"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"
],
"acl": "acl0",
"neighborIPv4Address": "10.0.2.2",
"neighborMacAddress": "00:00:00:00:00:02",
"nextModule": "lp0.200"
},
"kni0.300": {
"ipAddresses": [
"3333::1/96"
],
"acl": "acl0",
"neighborIPv6Address": "3333::2",
"neighborMacAddress": "00:00:00:00:00:03",
"nextModule": "lp0.300"
}
},
"peers": {
"1": "A",
"2": "B",
"3": "C"
}
},
"localPrefixes": [
"10.0.1.0/24",
"10.0.2.0/24"
]
}
}
}
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 route tunnel mpls over udp
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: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("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: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")/UDP(dport=6635, sport=0xf621, chksum=0)/MPLS(label=1100, ttl=255)/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")/UDP(dport=6635, sport=0xcc3f, chksum=0)/MPLS(label=1200, ttl=255)/IP(dst="2.0.0.1", src="10.0.2.2", ttl=63)/ICMP())

# No tunnel is established between local prefixes
write_pcap("002-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IP(dst="10.0.1.2", src="10.0.2.2", ttl=64)/ICMP(),
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:03")/Dot1Q(vlan=100)/IP(dst="10.0.2.2", src="10.0.1.2", ttl=64)/ICMP())

write_pcap("002-expect.pcap",
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.0.2.2", 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.0.1.2", ttl=63)/ICMP())
Binary file not shown.
Binary file not shown.
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
@@ -0,0 +1,15 @@
steps:
- cli:
- rib prefixes
- sendPackets:
- port: kni0
send: 001-send.pcap
expect: 001-expect.pcap
- sendPackets:
- port: kni0
send: 002-send.pcap
expect: 002-expect.pcap
- sendPackets:
- port: kni0
send: 003-send.pcap
expect: 003-expect.pcap
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"modules": {
"lp0.100": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "100",
"macAddress": "00:11:22:33:44:55",
"nextModule": "acl0"
},
"lp0.200": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "200",
"macAddress": "00:11:22:33:44:55",
"nextModule": "acl0"
},
"lp0.300": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "300",
"macAddress": "00:11:22:33:44:55",
"nextModule": "acl0"
},
"acl0": {
"type": "acl",
"nextModules": [
"decap0",
"route0:tunnel_ipip"
]
},
"decap0": {
"type": "decap",
"ipv6DestinationPrefixes": [
"3333::1"
],
"nextModule": "route0"
},
"route0": {
"type": "route",
"ipv4SourceAddress": "10.50.0.1",
"ipv6SourceAddress": "3333::1",
"udpDestinationPort": 6635,
"interfaces": {
"kni0.100": {
"ipAddresses": [
"10.0.1.1/24"
],
"acl": "acl0",
"neighborIPv4Address": "10.0.1.2",
"neighborMacAddress": "00:00:00:00:00:01",
"nextModule": "lp0.100"
},
"kni0.200": {
"ipAddresses": [
"10.0.2.1/24"
],
"acl": "acl0",
"neighborIPv4Address": "10.0.2.2",
"neighborMacAddress": "00:00:00:00:00:02",
"nextModule": "lp0.200"
},
"kni0.300": {
"ipAddresses": [
"3333::1/96"
],
"acl": "acl0",
"neighborIPv6Address": "3333::2",
"neighborMacAddress": "00:00:00:00:00:03",
"nextModule": "lp0.300"
}
},
"peers": {
"1": "A",
"2": "B",
"3": "C"
},
"localPrefixes": [
"10.0.1.0/24",
"10.0.2.0/24"
]
}
},
"rib": {
"defaullt": [
{
"prefix": "::/0",
"nexthop": "3333::2"
},
{
"prefix": "1.0.0.0/24",
"nexthop": "4444::1",
"tunnel": true
},
{
"prefix": "2.0.0.0/24",
"nexthop": "5555::1",
"tunnel": true
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from scapy.all import *
from scapy.contrib.mpls import MPLS


def write_pcap(filename, *packetsList):
if len(packetsList) == 0:
PcapWriter(filename)._write_header(Ether())
return

PcapWriter(filename)

for packets in packetsList:
if type(packets) == list:
for packet in packets:
packet.time = 0
wrpcap(filename, [p for p in packet], append=True)
else:
packets.time = 0
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: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: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 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")/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")/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())

# No tunnel is established between local prefixes
write_pcap("003-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IP(dst="10.0.1.2", src="10.0.2.2", ttl=64)/ICMP(),
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:03")/Dot1Q(vlan=100)/IP(dst="10.0.2.2", src="10.0.1.2", ttl=64)/ICMP())

write_pcap("003-expect.pcap",
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.0.2.2", 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.0.1.2", ttl=63)/ICMP())
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
@@ -0,0 +1,27 @@
steps:
- ipv6Update: "::/0 -> 3333::2"
- cli:
- rib static insert default 1.0.0.0/24 4444::1 1100 10000 1 1
- rib_insert:
attribute:
protocol: autotest
tables:
- table_name: ipv6 mpls-vpn
large_communities:
- 13238:1:1
prefixes:
- nexthop: 5555::1
prefix: 2.0.0.0/24
path_information: 55.55.55.1:10001
labels:
- 1200
- cli:
- rib prefixes
- sendPackets:
- port: kni0
send: 001-send.pcap
expect: 001-expect.pcap
- sendPackets:
- port: kni0
send: 002-send.pcap
expect: 002-expect.pcap
Loading
Loading