Skip to content

Commit

Permalink
Added autotest for random source address in route tunnel
Browse files Browse the repository at this point in the history
  • Loading branch information
stal76 committed Dec 15, 2024
1 parent c9f0cbb commit 7b034c7
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 1 deletion.
4 changes: 3 additions & 1 deletion autotest/units/001_one_port/076_rfc_5549_route/autotest.yaml
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
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"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"
]
},
"decap0": {
"type": "decap",
"ipv6DestinationPrefixes": [
"3333::1"
],
"nextModule": "route0"
},
"route0": {
"type": "route",
"ipv4SourceAddress": "10.50.0.1",
"ipv6SourceAddress": "3333::1",
"udpDestinationPort": 6635,
"random_source": true,
"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"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/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 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)/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:03", src="00:11:22:33:44:55")/Dot1Q(vlan=300)/IPv6(dst="4444::1", src="3333::a00:102:0: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::a00:102:0: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::a00:202:0: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::a00:202:0: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())

0 comments on commit 7b034c7

Please sign in to comment.