Skip to content

Commit

Permalink
add more autotests
Browse files Browse the repository at this point in the history
- decap + nat64stateless
- multi acls + modules
- nat64stateless with range ports
- multi decaps modules
- firewall ruleset
- firewall with nat64stateless
- fragment on nat64stateless
- fragment on decap
- dregress
  • Loading branch information
Timur Aitov committed Oct 9, 2023
1 parent 2d30d83 commit 99ab773
Show file tree
Hide file tree
Showing 152 changed files with 2,194 additions and 1 deletion.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,31 @@
steps:
- ipv4Update: "0.0.0.0/0 -> 200.0.0.1"
- ipv6Update: "::/0 -> fe80::1"
- 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
- sendPackets:
- port: kni0
send: 004-send.pcap
expect: 004-expect.pcap
- sendPackets:
- port: kni0
send: 005-send.pcap
expect: 005-expect.pcap
- sendPackets:
- port: kni0
send: 006-send.pcap
expect: 006-expect.pcap
- sendPackets:
- port: kni0
send: 007-send.pcap
expect: 007-expect.pcap
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"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"
},
"acl0": {
"type": "acl",
"nextModules": [
"nat64stateless0",
"decap0",
"vrf0"
]
},
"decap0": {
"type": "decap",
"ipv6DestinationPrefixes": [
"1234::abcd/128"
],
"nextModule": "vrf0"
},
"nat64stateless0": {
"type": "nat64stateless",
"translations": [
{
"ipv6Address": "2000::",
"ipv6DestinationAddress": "64:ff9b::",
"ipv4Address": "10.0.0.0"
}
],
"firewall": "false",
"nextModule": "vrf0"
},
"vrf0": {
"type": "route",
"interfaces": {
"lo0": {
"ipAddresses": [
"1234::abcd"
],
"nextModule": "controlPlane"
},
"kni0.100": {
"ipAddresses": [
"fe80::2"
],
"neighborIPv6Address": "fe80::1",
"neighborMacAddress": "00:00:00:00:00:01",
"nextModule": "lp0.100"
},
"kni0.200": {
"ipAddresses": [
"200.0.0.2"
],
"neighborIPv4Address": "200.0.0.1",
"neighborMacAddress": "00:00:00:00:00:02",
"nextModule": "lp0.200"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from scapy.all import *


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)


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="64:ff9b::1.1.0.0", src="2000::", hlim=64)/TCP(dport=80, sport=2048))

write_pcap("001-expect.pcap",
Ether(dst="00:00:00:00:00:02", src="00:11:22:33:44:55")/Dot1Q(vlan=200)/IP(dst="1.1.0.0", src="10.0.0.0", ttl=63, id=0)/TCP(dport=80, sport=2048))


write_pcap("002-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IPv6(dst="1234::abcd", src="2000::", hlim=64)/IP(dst="1.1.0.1", src="0.0.0.0", ttl=64)/TCP(dport=80, sport=2048))

write_pcap("002-expect.pcap",
Ether(dst="00:00:00:00:00:02", src="00:11:22:33:44:55")/Dot1Q(vlan=200)/IP(dst="1.1.0.1", src="0.0.0.0", ttl=63)/TCP(dport=80, sport=2048))


write_pcap("003-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IP(dst="1.1.0.2", src="0.0.0.0", ttl=64)/TCP(dport=80, sport=2048),
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IPv6(dst="::ffff", src="2000::", hlim=64)/TCP(dport=80, sport=2048))

write_pcap("003-expect.pcap",
Ether(dst="00:00:00:00:00:02", src="00:11:22:33:44:55")/Dot1Q(vlan=200)/IP(dst="1.1.0.2", src="0.0.0.0", ttl=63)/TCP(dport=80, sport=2048),
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IPv6(dst="::ffff", src="2000::", hlim=63)/TCP(dport=80, sport=2048))


write_pcap("004-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IP(dst="10.0.0.0", src="1.1.0.3", ttl=64)/TCP(dport=2048, sport=80))

write_pcap("004-expect.pcap",
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IPv6(dst="2000::", src="64:ff9b::1.1.0.3", hlim=63, fl=0)/TCP(dport=2048, sport=80))


write_pcap("005-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IP(dst="1.1.0.5", src="0.0.0.0", ttl=64)/TCP(dport=80, sport=2048),
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IPv6(dst="::fffe", src="2000::", hlim=64)/TCP(dport=80, sport=2048))

write_pcap("005-expect.pcap",
Ether(dst="00:00:00:00:00:02", src="00:11:22:33:44:55")/Dot1Q(vlan=200)/IP(dst="1.1.0.5", src="0.0.0.0", ttl=63)/TCP(dport=80, sport=2048),
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IPv6(dst="::fffe", src="2000::", hlim=63)/TCP(dport=80, sport=2048))


write_pcap("006-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IP(dst="200.0.0.9", src="1.1.0.6", ttl=64)/TCP(dport=2048, sport=80))

write_pcap("006-expect.pcap",
Ether(dst="00:00:00:00:00:02", src="00:11:22:33:44:55")/Dot1Q(vlan=200)/IP(dst="200.0.0.9", src="1.1.0.6", ttl=63)/TCP(dport=2048, sport=80))


write_pcap("007-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IPv6(dst="1234::abcd", src="2000::", hlim=64)/TCP(dport=80, sport=2048))

write_pcap("007-expect.pcap",
Ether(dst="71:71:71:71:71:71", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IPv6(dst="1234::abcd", src="2000::", hlim=64)/TCP(dport=80, sport=2048))
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,35 @@
steps:
- ipv4Update: "0.0.0.0/0 -> 200.0.0.1"
- ipv6Update: "::/0 -> fe80::1"
- 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
- sendPackets:
- port: kni0
send: 004-send.pcap
expect: 004-expect.pcap
- sendPackets:
- port: kni0
send: 005-send.pcap
expect: 005-expect.pcap
- sendPackets:
- port: kni0
send: 006-send.pcap
expect: 006-expect.pcap
- sendPackets:
- port: kni0
send: 007-send.pcap
expect: 007-expect.pcap
- sendPackets:
- port: kni0
send: 008-send.pcap
expect: 008-expect.pcap
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"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": "acl1"
},
"acl0": {
"type": "acl",
"nextModules": [
"nat64stateless0:ingress",
"decap0"
]
},
"acl1": {
"type": "acl",
"nextModules": [
"nat64stateless0:egress"
]
},
"decap0": {
"type": "decap",
"ipv6DestinationPrefixes": [
"1234::abcd/128"
],
"nextModule": "vrf0"
},
"nat64stateless0": {
"type": "nat64stateless",
"translations": [
{
"ipv6Address": "2000::",
"ipv6DestinationAddress": "64:ff9b::",
"ipv4Address": "10.0.0.0"
}
],
"firewall": "false",
"nextModule": "vrf0"
},
"vrf0": {
"type": "route",
"interfaces": {
"kni0.100": {
"ipv6Prefix": "fe80::2/64",
"neighborIPv6Address": "fe80::1",
"neighborMacAddress": "00:00:00:00:00:01",
"nextModule": "lp0.100"
},
"kni0.200": {
"ipv4Prefix": "200.0.0.2/24",
"neighborIPv4Address": "200.0.0.1",
"neighborMacAddress": "00:00:00:00:00:02",
"nextModule": "lp0.200"
}
}
}
}
}
74 changes: 74 additions & 0 deletions autotest/units/001_one_port/021_acls_decap_nat64stateless/gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from scapy.all import *


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)


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="64:ff9b::1.1.0.0", src="2000::", hlim=64)/TCP(dport=80, sport=2048))

write_pcap("001-expect.pcap",
Ether(dst="00:00:00:00:00:02", src="00:11:22:33:44:55")/Dot1Q(vlan=200)/IP(dst="1.1.0.0", src="10.0.0.0", ttl=63, id=0)/TCP(dport=80, sport=2048))


write_pcap("002-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IPv6(dst="1234::abcd", src="2000::", hlim=64)/IP(dst="1.1.0.1", src="0.0.0.0", ttl=64)/TCP(dport=80, sport=2048))

write_pcap("002-expect.pcap",
Ether(dst="00:00:00:00:00:02", src="00:11:22:33:44:55")/Dot1Q(vlan=200)/IP(dst="1.1.0.1", src="0.0.0.0", ttl=63)/TCP(dport=80, sport=2048))


write_pcap("003-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IP(dst="1.1.0.2", src="0.0.0.0", ttl=64)/TCP(dport=80, sport=2048),
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IPv6(dst="::ffff", src="2000::", hlim=64)/TCP(dport=80, sport=2048))

write_pcap("003-expect.pcap")


write_pcap("004-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IP(dst="10.0.0.0", src="1.1.0.3", ttl=64)/TCP(dport=2048, sport=80))

write_pcap("004-expect.pcap",
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IPv6(dst="2000::", src="64:ff9b::1.1.0.3", hlim=63, fl=0)/TCP(dport=2048, sport=80))


write_pcap("005-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IP(dst="1.1.0.5", src="0.0.0.0", ttl=64)/TCP(dport=80, sport=2048),
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IPv6(dst="::fffe", src="2000::", hlim=64)/TCP(dport=80, sport=2048))

write_pcap("005-expect.pcap")


write_pcap("006-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:01")/Dot1Q(vlan=100)/IP(dst="10.0.0.0", src="1.1.0.6", ttl=64)/TCP(dport=2048, sport=80))

write_pcap("006-expect.pcap")


write_pcap("007-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IPv6(dst="64:ff9b::1.1.0.0", src="2000::", hlim=64)/TCP(dport=80, sport=2048))

write_pcap("007-expect.pcap")


write_pcap("008-send.pcap",
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IPv6(dst="1234::abcd", src="2000::", hlim=64)/IP(dst="1.1.0.1", src="0.0.0.0", ttl=64)/TCP(dport=80, sport=2048))

write_pcap("008-expect.pcap")
Binary file not shown.
Binary file not shown.
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,19 @@
steps:
- ipv4Update: "0.0.0.0/0 -> 200.0.0.1"
- ipv6Update: "::/0 -> fe80::1"
- 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
- sendPackets:
- port: kni0
send: 004-send.pcap
expect: 004-expect.pcap
Loading

0 comments on commit 99ab773

Please sign in to comment.