2019-10-31 13:31:07 -05:00
|
|
|
#!/usr/bin/env python3
|
2017-05-02 20:08:51 +02:00
|
|
|
""" ACL plugin extended stateful tests """
|
|
|
|
|
|
|
|
import unittest
|
2021-05-31 16:08:53 +02:00
|
|
|
from config import config
|
2023-08-31 00:47:44 -04:00
|
|
|
from framework import VppTestCase
|
2017-08-09 11:28:02 +02:00
|
|
|
from scapy.layers.inet import IP, UDP, TCP
|
2017-05-02 20:08:51 +02:00
|
|
|
from scapy.packet import Packet
|
2023-08-31 00:47:44 -04:00
|
|
|
from socket import AF_INET, AF_INET6
|
|
|
|
from scapy.layers.inet6 import IPv6
|
2017-09-07 13:22:24 +02:00
|
|
|
from util import L4_Conn
|
2020-03-27 06:55:06 +01:00
|
|
|
from ipaddress import ip_network
|
|
|
|
|
|
|
|
from vpp_acl import AclRule, VppAcl, VppAclInterface
|
2017-05-02 20:08:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
def to_acl_rule(self, is_permit, wildcard_sport=False):
|
|
|
|
p = self
|
|
|
|
rule_family = AF_INET6 if p.haslayer(IPv6) else AF_INET
|
|
|
|
rule_prefix_len = 128 if p.haslayer(IPv6) else 32
|
|
|
|
rule_l3_layer = IPv6 if p.haslayer(IPv6) else IP
|
|
|
|
rule_l4_sport = p.sport
|
|
|
|
rule_l4_dport = p.dport
|
|
|
|
if p.haslayer(IPv6):
|
|
|
|
rule_l4_proto = p[IPv6].nh
|
|
|
|
else:
|
|
|
|
rule_l4_proto = p[IP].proto
|
|
|
|
|
|
|
|
if wildcard_sport:
|
|
|
|
rule_l4_sport_first = 0
|
|
|
|
rule_l4_sport_last = 65535
|
|
|
|
else:
|
|
|
|
rule_l4_sport_first = rule_l4_sport
|
|
|
|
rule_l4_sport_last = rule_l4_sport
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
new_rule = AclRule(
|
|
|
|
is_permit=is_permit,
|
|
|
|
proto=rule_l4_proto,
|
|
|
|
src_prefix=ip_network((p[rule_l3_layer].src, rule_prefix_len)),
|
|
|
|
dst_prefix=ip_network((p[rule_l3_layer].dst, rule_prefix_len)),
|
|
|
|
sport_from=rule_l4_sport_first,
|
|
|
|
sport_to=rule_l4_sport_last,
|
|
|
|
dport_from=rule_l4_dport,
|
|
|
|
dport_to=rule_l4_dport,
|
|
|
|
)
|
2020-03-27 06:55:06 +01:00
|
|
|
|
2017-05-02 20:08:51 +02:00
|
|
|
return new_rule
|
|
|
|
|
2020-03-27 06:55:06 +01:00
|
|
|
|
2017-05-02 20:08:51 +02:00
|
|
|
Packet.to_acl_rule = to_acl_rule
|
|
|
|
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
class IterateWithSleep:
|
2017-05-02 20:08:51 +02:00
|
|
|
def __init__(self, testcase, n_iters, description, sleep_sec):
|
|
|
|
self.curr = 0
|
|
|
|
self.testcase = testcase
|
|
|
|
self.n_iters = n_iters
|
|
|
|
self.sleep_sec = sleep_sec
|
|
|
|
self.description = description
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
for x in range(0, self.n_iters):
|
|
|
|
yield x
|
|
|
|
self.testcase.sleep(self.sleep_sec)
|
|
|
|
|
|
|
|
|
2017-09-07 13:22:24 +02:00
|
|
|
class Conn(L4_Conn):
|
2017-05-02 20:08:51 +02:00
|
|
|
def apply_acls(self, reflect_side, acl_side):
|
|
|
|
pkts = []
|
|
|
|
pkts.append(self.pkt(0))
|
|
|
|
pkts.append(self.pkt(1))
|
|
|
|
pkt = pkts[reflect_side]
|
|
|
|
|
|
|
|
r = []
|
|
|
|
r.append(pkt.to_acl_rule(2, wildcard_sport=True))
|
|
|
|
r.append(self.wildcard_rule(0))
|
2020-03-27 06:55:06 +01:00
|
|
|
reflect_acl = VppAcl(self.testcase, r)
|
|
|
|
reflect_acl.add_vpp_config()
|
2017-05-02 20:08:51 +02:00
|
|
|
|
|
|
|
r = []
|
|
|
|
r.append(self.wildcard_rule(0))
|
2020-03-27 06:55:06 +01:00
|
|
|
deny_acl = VppAcl(self.testcase, r)
|
|
|
|
deny_acl.add_vpp_config()
|
2017-05-02 20:08:51 +02:00
|
|
|
|
|
|
|
if reflect_side == acl_side:
|
2022-04-26 19:02:15 +02:00
|
|
|
acl_if0 = VppAclInterface(
|
|
|
|
self.testcase,
|
|
|
|
self.ifs[acl_side].sw_if_index,
|
|
|
|
[reflect_acl, deny_acl],
|
|
|
|
n_input=1,
|
|
|
|
)
|
|
|
|
acl_if1 = VppAclInterface(
|
|
|
|
self.testcase, self.ifs[1 - acl_side].sw_if_index, [], n_input=0
|
|
|
|
)
|
2020-03-27 06:55:06 +01:00
|
|
|
acl_if0.add_vpp_config()
|
|
|
|
acl_if1.add_vpp_config()
|
2017-05-02 20:08:51 +02:00
|
|
|
else:
|
2022-04-26 19:02:15 +02:00
|
|
|
acl_if0 = VppAclInterface(
|
|
|
|
self.testcase,
|
|
|
|
self.ifs[acl_side].sw_if_index,
|
|
|
|
[deny_acl, reflect_acl],
|
|
|
|
n_input=1,
|
|
|
|
)
|
|
|
|
acl_if1 = VppAclInterface(
|
|
|
|
self.testcase, self.ifs[1 - acl_side].sw_if_index, [], n_input=0
|
|
|
|
)
|
2020-03-27 06:55:06 +01:00
|
|
|
acl_if0.add_vpp_config()
|
|
|
|
acl_if1.add_vpp_config()
|
2017-05-02 20:08:51 +02:00
|
|
|
|
|
|
|
def wildcard_rule(self, is_permit):
|
|
|
|
any_addr = ["0.0.0.0", "::"]
|
|
|
|
rule_family = self.address_family
|
|
|
|
is_ip6 = 1 if rule_family == AF_INET6 else 0
|
2022-04-26 19:02:15 +02:00
|
|
|
new_rule = AclRule(
|
|
|
|
is_permit=is_permit,
|
|
|
|
proto=0,
|
|
|
|
src_prefix=ip_network((any_addr[is_ip6], 0)),
|
|
|
|
dst_prefix=ip_network((any_addr[is_ip6], 0)),
|
|
|
|
sport_from=0,
|
|
|
|
sport_to=65535,
|
|
|
|
dport_from=0,
|
|
|
|
dport_to=65535,
|
|
|
|
)
|
2017-05-02 20:08:51 +02:00
|
|
|
return new_rule
|
|
|
|
|
|
|
|
|
2021-05-31 16:08:53 +02:00
|
|
|
@unittest.skipUnless(config.extended, "part of extended tests")
|
2017-05-02 20:08:51 +02:00
|
|
|
class ACLPluginConnTestCase(VppTestCase):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""ACL plugin connection-oriented extended testcases"""
|
2017-05-02 20:08:51 +02:00
|
|
|
|
|
|
|
@classmethod
|
2018-11-24 21:57:08 -08:00
|
|
|
def setUpClass(cls):
|
|
|
|
super(ACLPluginConnTestCase, cls).setUpClass()
|
2017-05-02 20:08:51 +02:00
|
|
|
# create pg0 and pg1
|
2018-11-24 21:57:08 -08:00
|
|
|
cls.create_pg_interfaces(range(2))
|
2018-02-05 17:27:57 +01:00
|
|
|
cmd = "set acl-plugin session table event-trace 1"
|
2018-11-24 21:57:08 -08:00
|
|
|
cls.logger.info(cls.vapi.cli(cmd))
|
|
|
|
for i in cls.pg_interfaces:
|
2017-05-02 20:08:51 +02:00
|
|
|
i.admin_up()
|
|
|
|
i.config_ip4()
|
|
|
|
i.config_ip6()
|
|
|
|
i.resolve_arp()
|
|
|
|
i.resolve_ndp()
|
|
|
|
|
2019-01-25 14:05:48 -08:00
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
super(ACLPluginConnTestCase, cls).tearDownClass()
|
|
|
|
|
acl-plugin: bihash-based ACL lookup
Add a bihash-based ACL lookup mechanism and make it a new default.
This changes the time required to lookup a 5-tuple match
from O(total_N_entries) to O(total_N_mask_types), where
"mask type" is an overall mask on the 5-tuple required
to represent an ACE.
For testing/comparison there is a temporary debug CLI
"set acl-plugin use-hash-acl-matching {0|1}", which,
when set to 0, makes the plugin use the "old" linear lookup,
and when set to 1, makes it use the hash-based lookup.
Based on the discussions on vpp-dev mailing list,
prevent assigning the ACL index to an interface,
when the ACL with that index is not defined,
also prevent deleting an ACL if that ACL is applied.
Also, for the easier debugging of the state, there are
new debug CLI commands to see the ACL plugin state at
several layers:
"show acl-plugin acl [index N]" - show a high-level
ACL representation, used for the linear lookup and
as a base for building the hashtable-based lookup.
Also shows if a given ACL is applied somewhere.
"show acl-plugin interface [sw_if_index N]" - show
which interfaces have which ACL(s) applied.
"show acl-plugin tables" - a lower-level debug command
used to see the state of all of the related data structures
at once. There are specifiers possible, which make
for a more focused and maybe augmented output:
"show acl-plugin tables acl [index N]"
show the "bitmask-ready" representations of the ACLs,
we well as the mask types and their associated indices.
"show acl-plutin tables mask"
show the derived mask types and their indices only.
"show acl-plugin tables applied [sw_if_index N]"
show the table of all of the ACEs applied for a given
sw_if_index or all interfaces.
"show acl-plugin tables hash [verbose N]"
show the 48x8 bihash used for the ACL lookup.
Change-Id: I89fff051424cb44bcb189e3cee04c1b8f76efc28
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
2017-05-24 13:20:47 +02:00
|
|
|
def tearDown(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Run standard test teardown and log various show commands"""
|
acl-plugin: bihash-based ACL lookup
Add a bihash-based ACL lookup mechanism and make it a new default.
This changes the time required to lookup a 5-tuple match
from O(total_N_entries) to O(total_N_mask_types), where
"mask type" is an overall mask on the 5-tuple required
to represent an ACE.
For testing/comparison there is a temporary debug CLI
"set acl-plugin use-hash-acl-matching {0|1}", which,
when set to 0, makes the plugin use the "old" linear lookup,
and when set to 1, makes it use the hash-based lookup.
Based on the discussions on vpp-dev mailing list,
prevent assigning the ACL index to an interface,
when the ACL with that index is not defined,
also prevent deleting an ACL if that ACL is applied.
Also, for the easier debugging of the state, there are
new debug CLI commands to see the ACL plugin state at
several layers:
"show acl-plugin acl [index N]" - show a high-level
ACL representation, used for the linear lookup and
as a base for building the hashtable-based lookup.
Also shows if a given ACL is applied somewhere.
"show acl-plugin interface [sw_if_index N]" - show
which interfaces have which ACL(s) applied.
"show acl-plugin tables" - a lower-level debug command
used to see the state of all of the related data structures
at once. There are specifiers possible, which make
for a more focused and maybe augmented output:
"show acl-plugin tables acl [index N]"
show the "bitmask-ready" representations of the ACLs,
we well as the mask types and their associated indices.
"show acl-plutin tables mask"
show the derived mask types and their indices only.
"show acl-plugin tables applied [sw_if_index N]"
show the table of all of the ACEs applied for a given
sw_if_index or all interfaces.
"show acl-plugin tables hash [verbose N]"
show the 48x8 bihash used for the ACL lookup.
Change-Id: I89fff051424cb44bcb189e3cee04c1b8f76efc28
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
2017-05-24 13:20:47 +02:00
|
|
|
super(ACLPluginConnTestCase, self).tearDown()
|
2019-03-13 09:23:05 -07:00
|
|
|
|
|
|
|
def show_commands_at_teardown(self):
|
2019-09-30 10:53:31 +00:00
|
|
|
self.logger.info(self.vapi.cli("show ip neighbors"))
|
2019-03-13 09:23:05 -07:00
|
|
|
self.logger.info(self.vapi.cli("show ip6 neighbors"))
|
|
|
|
self.logger.info(self.vapi.cli("show acl-plugin sessions"))
|
|
|
|
self.logger.info(self.vapi.cli("show acl-plugin acl"))
|
|
|
|
self.logger.info(self.vapi.cli("show acl-plugin interface"))
|
|
|
|
self.logger.info(self.vapi.cli("show acl-plugin tables"))
|
|
|
|
self.logger.info(self.vapi.cli("show event-logger all"))
|
acl-plugin: bihash-based ACL lookup
Add a bihash-based ACL lookup mechanism and make it a new default.
This changes the time required to lookup a 5-tuple match
from O(total_N_entries) to O(total_N_mask_types), where
"mask type" is an overall mask on the 5-tuple required
to represent an ACE.
For testing/comparison there is a temporary debug CLI
"set acl-plugin use-hash-acl-matching {0|1}", which,
when set to 0, makes the plugin use the "old" linear lookup,
and when set to 1, makes it use the hash-based lookup.
Based on the discussions on vpp-dev mailing list,
prevent assigning the ACL index to an interface,
when the ACL with that index is not defined,
also prevent deleting an ACL if that ACL is applied.
Also, for the easier debugging of the state, there are
new debug CLI commands to see the ACL plugin state at
several layers:
"show acl-plugin acl [index N]" - show a high-level
ACL representation, used for the linear lookup and
as a base for building the hashtable-based lookup.
Also shows if a given ACL is applied somewhere.
"show acl-plugin interface [sw_if_index N]" - show
which interfaces have which ACL(s) applied.
"show acl-plugin tables" - a lower-level debug command
used to see the state of all of the related data structures
at once. There are specifiers possible, which make
for a more focused and maybe augmented output:
"show acl-plugin tables acl [index N]"
show the "bitmask-ready" representations of the ACLs,
we well as the mask types and their associated indices.
"show acl-plutin tables mask"
show the derived mask types and their indices only.
"show acl-plugin tables applied [sw_if_index N]"
show the table of all of the ACEs applied for a given
sw_if_index or all interfaces.
"show acl-plugin tables hash [verbose N]"
show the 48x8 bihash used for the ACL lookup.
Change-Id: I89fff051424cb44bcb189e3cee04c1b8f76efc28
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
2017-05-24 13:20:47 +02:00
|
|
|
|
2017-05-02 20:08:51 +02:00
|
|
|
def run_basic_conn_test(self, af, acl_side):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Basic conn timeout test"""
|
2017-05-02 20:08:51 +02:00
|
|
|
conn1 = Conn(self, self.pg0, self.pg1, af, UDP, 42001, 4242)
|
|
|
|
conn1.apply_acls(0, acl_side)
|
|
|
|
conn1.send_through(0)
|
|
|
|
# the return packets should pass
|
|
|
|
conn1.send_through(1)
|
|
|
|
# send some packets on conn1, ensure it doesn't go away
|
|
|
|
for i in IterateWithSleep(self, 20, "Keep conn active", 0.3):
|
|
|
|
conn1.send_through(1)
|
|
|
|
# allow the conn to time out
|
|
|
|
for i in IterateWithSleep(self, 30, "Wait for timeout", 0.1):
|
|
|
|
pass
|
|
|
|
# now try to send a packet on the reflected side
|
|
|
|
try:
|
|
|
|
p2 = conn1.send_through(1).command()
|
|
|
|
except:
|
|
|
|
# If we asserted while waiting, it's good.
|
|
|
|
# the conn should have timed out.
|
|
|
|
p2 = None
|
|
|
|
self.assert_equal(p2, None, "packet on long-idle conn")
|
|
|
|
|
|
|
|
def run_active_conn_test(self, af, acl_side):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Idle connection behind active connection test"""
|
|
|
|
base = 10000 + 1000 * acl_side
|
2017-05-02 20:08:51 +02:00
|
|
|
conn1 = Conn(self, self.pg0, self.pg1, af, UDP, base + 1, 2323)
|
|
|
|
conn2 = Conn(self, self.pg0, self.pg1, af, UDP, base + 2, 2323)
|
|
|
|
conn3 = Conn(self, self.pg0, self.pg1, af, UDP, base + 3, 2323)
|
|
|
|
conn1.apply_acls(0, acl_side)
|
|
|
|
conn1.send(0)
|
|
|
|
conn1.recv(1)
|
|
|
|
# create and check that the conn2/3 work
|
|
|
|
self.sleep(0.1)
|
|
|
|
conn2.send_pingpong(0)
|
|
|
|
self.sleep(0.1)
|
|
|
|
conn3.send_pingpong(0)
|
|
|
|
# send some packets on conn1, keep conn2/3 idle
|
|
|
|
for i in IterateWithSleep(self, 20, "Keep conn active", 0.2):
|
|
|
|
conn1.send_through(1)
|
|
|
|
try:
|
|
|
|
p2 = conn2.send_through(1).command()
|
|
|
|
except:
|
|
|
|
# If we asserted while waiting, it's good.
|
|
|
|
# the conn should have timed out.
|
|
|
|
p2 = None
|
|
|
|
# We should have not received the packet on a long-idle
|
|
|
|
# connection, because it should have timed out
|
|
|
|
# If it didn't - it is a problem
|
|
|
|
self.assert_equal(p2, None, "packet on long-idle conn")
|
|
|
|
|
2017-06-21 11:24:25 +02:00
|
|
|
def run_clear_conn_test(self, af, acl_side):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Clear the connections via CLI"""
|
2017-06-21 11:24:25 +02:00
|
|
|
conn1 = Conn(self, self.pg0, self.pg1, af, UDP, 42001, 4242)
|
|
|
|
conn1.apply_acls(0, acl_side)
|
|
|
|
conn1.send_through(0)
|
|
|
|
# the return packets should pass
|
|
|
|
conn1.send_through(1)
|
|
|
|
# send some packets on conn1, ensure it doesn't go away
|
|
|
|
for i in IterateWithSleep(self, 20, "Keep conn active", 0.3):
|
|
|
|
conn1.send_through(1)
|
|
|
|
# clear all connections
|
|
|
|
self.vapi.ppcli("clear acl-plugin sessions")
|
|
|
|
# now try to send a packet on the reflected side
|
|
|
|
try:
|
|
|
|
p2 = conn1.send_through(1).command()
|
|
|
|
except:
|
|
|
|
# If we asserted while waiting, it's good.
|
|
|
|
# the conn should have timed out.
|
|
|
|
p2 = None
|
|
|
|
self.assert_equal(p2, None, "packet on supposedly deleted conn")
|
|
|
|
|
2017-08-09 11:28:02 +02:00
|
|
|
def run_tcp_transient_setup_conn_test(self, af, acl_side):
|
|
|
|
conn1 = Conn(self, self.pg0, self.pg1, af, TCP, 53001, 5151)
|
|
|
|
conn1.apply_acls(0, acl_side)
|
2022-04-26 19:02:15 +02:00
|
|
|
conn1.send_through(0, "S")
|
2017-08-09 11:28:02 +02:00
|
|
|
# the return packets should pass
|
2022-04-26 19:02:15 +02:00
|
|
|
conn1.send_through(1, "SA")
|
2017-08-09 11:28:02 +02:00
|
|
|
# allow the conn to time out
|
|
|
|
for i in IterateWithSleep(self, 30, "Wait for timeout", 0.1):
|
|
|
|
pass
|
|
|
|
# ensure conn times out
|
|
|
|
try:
|
|
|
|
p2 = conn1.send_through(1).command()
|
|
|
|
except:
|
|
|
|
# If we asserted while waiting, it's good.
|
|
|
|
# the conn should have timed out.
|
|
|
|
p2 = None
|
|
|
|
self.assert_equal(p2, None, "packet on supposedly deleted conn")
|
|
|
|
|
|
|
|
def run_tcp_established_conn_test(self, af, acl_side):
|
|
|
|
conn1 = Conn(self, self.pg0, self.pg1, af, TCP, 53002, 5052)
|
|
|
|
conn1.apply_acls(0, acl_side)
|
2022-04-26 19:02:15 +02:00
|
|
|
conn1.send_through(0, "S")
|
2017-08-09 11:28:02 +02:00
|
|
|
# the return packets should pass
|
2022-04-26 19:02:15 +02:00
|
|
|
conn1.send_through(1, "SA")
|
2017-08-09 11:28:02 +02:00
|
|
|
# complete the threeway handshake
|
|
|
|
# (NB: sequence numbers not tracked, so not set!)
|
2022-04-26 19:02:15 +02:00
|
|
|
conn1.send_through(0, "A")
|
2017-08-09 11:28:02 +02:00
|
|
|
# allow the conn to time out if it's in embryonic timer
|
|
|
|
for i in IterateWithSleep(self, 30, "Wait for transient timeout", 0.1):
|
|
|
|
pass
|
|
|
|
# Try to send the packet from the "forbidden" side - it must pass
|
2022-04-26 19:02:15 +02:00
|
|
|
conn1.send_through(1, "A")
|
2017-08-09 11:28:02 +02:00
|
|
|
# ensure conn times out for real
|
|
|
|
for i in IterateWithSleep(self, 130, "Wait for timeout", 0.1):
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
p2 = conn1.send_through(1).command()
|
|
|
|
except:
|
|
|
|
# If we asserted while waiting, it's good.
|
|
|
|
# the conn should have timed out.
|
|
|
|
p2 = None
|
|
|
|
self.assert_equal(p2, None, "packet on supposedly deleted conn")
|
|
|
|
|
|
|
|
def run_tcp_transient_teardown_conn_test(self, af, acl_side):
|
|
|
|
conn1 = Conn(self, self.pg0, self.pg1, af, TCP, 53002, 5052)
|
|
|
|
conn1.apply_acls(0, acl_side)
|
2022-04-26 19:02:15 +02:00
|
|
|
conn1.send_through(0, "S")
|
2017-08-09 11:28:02 +02:00
|
|
|
# the return packets should pass
|
2022-04-26 19:02:15 +02:00
|
|
|
conn1.send_through(1, "SA")
|
2017-08-09 11:28:02 +02:00
|
|
|
# complete the threeway handshake
|
|
|
|
# (NB: sequence numbers not tracked, so not set!)
|
2022-04-26 19:02:15 +02:00
|
|
|
conn1.send_through(0, "A")
|
2017-08-09 11:28:02 +02:00
|
|
|
# allow the conn to time out if it's in embryonic timer
|
|
|
|
for i in IterateWithSleep(self, 30, "Wait for transient timeout", 0.1):
|
|
|
|
pass
|
|
|
|
# Try to send the packet from the "forbidden" side - it must pass
|
2022-04-26 19:02:15 +02:00
|
|
|
conn1.send_through(1, "A")
|
2017-08-09 11:28:02 +02:00
|
|
|
# Send the FIN to bounce the session out of established
|
2022-04-26 19:02:15 +02:00
|
|
|
conn1.send_through(1, "FA")
|
2017-08-09 11:28:02 +02:00
|
|
|
# If conn landed on transient timer it will time out here
|
|
|
|
for i in IterateWithSleep(self, 30, "Wait for transient timeout", 0.1):
|
|
|
|
pass
|
|
|
|
# Now it should have timed out already
|
|
|
|
try:
|
|
|
|
p2 = conn1.send_through(1).command()
|
|
|
|
except:
|
|
|
|
# If we asserted while waiting, it's good.
|
|
|
|
# the conn should have timed out.
|
|
|
|
p2 = None
|
|
|
|
self.assert_equal(p2, None, "packet on supposedly deleted conn")
|
|
|
|
|
2017-05-02 20:08:51 +02:00
|
|
|
def test_0000_conn_prepare_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Prepare the settings"""
|
2017-05-02 20:08:51 +02:00
|
|
|
self.vapi.ppcli("set acl-plugin session timeout udp idle 1")
|
|
|
|
|
|
|
|
def test_0001_basic_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv4: Basic conn timeout test reflect on ingress"""
|
2017-05-02 20:08:51 +02:00
|
|
|
self.run_basic_conn_test(AF_INET, 0)
|
|
|
|
|
|
|
|
def test_0002_basic_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv4: Basic conn timeout test reflect on egress"""
|
2017-05-02 20:08:51 +02:00
|
|
|
self.run_basic_conn_test(AF_INET, 1)
|
|
|
|
|
2017-06-21 11:24:25 +02:00
|
|
|
def test_0005_clear_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv4: reflect egress, clear conn"""
|
2017-06-21 11:24:25 +02:00
|
|
|
self.run_clear_conn_test(AF_INET, 1)
|
|
|
|
|
|
|
|
def test_0006_clear_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv4: reflect ingress, clear conn"""
|
2017-06-21 11:24:25 +02:00
|
|
|
self.run_clear_conn_test(AF_INET, 0)
|
|
|
|
|
2017-05-02 20:08:51 +02:00
|
|
|
def test_0011_active_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv4: Idle conn behind active conn, reflect on ingress"""
|
2017-05-02 20:08:51 +02:00
|
|
|
self.run_active_conn_test(AF_INET, 0)
|
|
|
|
|
|
|
|
def test_0012_active_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv4: Idle conn behind active conn, reflect on egress"""
|
2017-05-02 20:08:51 +02:00
|
|
|
self.run_active_conn_test(AF_INET, 1)
|
|
|
|
|
|
|
|
def test_1001_basic_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv6: Basic conn timeout test reflect on ingress"""
|
2017-05-02 20:08:51 +02:00
|
|
|
self.run_basic_conn_test(AF_INET6, 0)
|
|
|
|
|
|
|
|
def test_1002_basic_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv6: Basic conn timeout test reflect on egress"""
|
2017-05-02 20:08:51 +02:00
|
|
|
self.run_basic_conn_test(AF_INET6, 1)
|
|
|
|
|
2017-06-21 11:24:25 +02:00
|
|
|
def test_1005_clear_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv6: reflect egress, clear conn"""
|
2017-06-21 11:24:25 +02:00
|
|
|
self.run_clear_conn_test(AF_INET6, 1)
|
|
|
|
|
|
|
|
def test_1006_clear_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv6: reflect ingress, clear conn"""
|
2017-06-21 11:24:25 +02:00
|
|
|
self.run_clear_conn_test(AF_INET6, 0)
|
|
|
|
|
2017-05-02 20:08:51 +02:00
|
|
|
def test_1011_active_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv6: Idle conn behind active conn, reflect on ingress"""
|
2017-05-02 20:08:51 +02:00
|
|
|
self.run_active_conn_test(AF_INET6, 0)
|
|
|
|
|
|
|
|
def test_1012_active_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv6: Idle conn behind active conn, reflect on egress"""
|
2017-05-02 20:08:51 +02:00
|
|
|
self.run_active_conn_test(AF_INET6, 1)
|
2017-08-09 11:28:02 +02:00
|
|
|
|
|
|
|
def test_2000_prepare_for_tcp_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Prepare for TCP session tests"""
|
2017-08-09 11:28:02 +02:00
|
|
|
# ensure the session hangs on if it gets treated as UDP
|
|
|
|
self.vapi.ppcli("set acl-plugin session timeout udp idle 200")
|
|
|
|
# let the TCP connection time out at 5 seconds
|
|
|
|
self.vapi.ppcli("set acl-plugin session timeout tcp idle 10")
|
|
|
|
self.vapi.ppcli("set acl-plugin session timeout tcp transient 1")
|
|
|
|
|
|
|
|
def test_2001_tcp_transient_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv4: transient TCP session (incomplete 3WHS), ref. on ingress"""
|
2017-08-09 11:28:02 +02:00
|
|
|
self.run_tcp_transient_setup_conn_test(AF_INET, 0)
|
|
|
|
|
|
|
|
def test_2002_tcp_transient_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv4: transient TCP session (incomplete 3WHS), ref. on egress"""
|
2017-08-09 11:28:02 +02:00
|
|
|
self.run_tcp_transient_setup_conn_test(AF_INET, 1)
|
|
|
|
|
|
|
|
def test_2003_tcp_transient_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv4: established TCP session (complete 3WHS), ref. on ingress"""
|
2017-08-09 11:28:02 +02:00
|
|
|
self.run_tcp_established_conn_test(AF_INET, 0)
|
|
|
|
|
|
|
|
def test_2004_tcp_transient_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv4: established TCP session (complete 3WHS), ref. on egress"""
|
2017-08-09 11:28:02 +02:00
|
|
|
self.run_tcp_established_conn_test(AF_INET, 1)
|
|
|
|
|
|
|
|
def test_2005_tcp_transient_teardown_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv4: transient TCP session (3WHS,ACK,FINACK), ref. on ingress"""
|
2017-08-09 11:28:02 +02:00
|
|
|
self.run_tcp_transient_teardown_conn_test(AF_INET, 0)
|
|
|
|
|
|
|
|
def test_2006_tcp_transient_teardown_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv4: transient TCP session (3WHS,ACK,FINACK), ref. on egress"""
|
2017-08-09 11:28:02 +02:00
|
|
|
self.run_tcp_transient_teardown_conn_test(AF_INET, 1)
|
|
|
|
|
|
|
|
def test_3001_tcp_transient_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv6: transient TCP session (incomplete 3WHS), ref. on ingress"""
|
2017-08-09 11:28:02 +02:00
|
|
|
self.run_tcp_transient_setup_conn_test(AF_INET6, 0)
|
|
|
|
|
|
|
|
def test_3002_tcp_transient_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv6: transient TCP session (incomplete 3WHS), ref. on egress"""
|
2017-08-09 11:28:02 +02:00
|
|
|
self.run_tcp_transient_setup_conn_test(AF_INET6, 1)
|
|
|
|
|
|
|
|
def test_3003_tcp_transient_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv6: established TCP session (complete 3WHS), ref. on ingress"""
|
2017-08-09 11:28:02 +02:00
|
|
|
self.run_tcp_established_conn_test(AF_INET6, 0)
|
|
|
|
|
|
|
|
def test_3004_tcp_transient_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv6: established TCP session (complete 3WHS), ref. on egress"""
|
2017-08-09 11:28:02 +02:00
|
|
|
self.run_tcp_established_conn_test(AF_INET6, 1)
|
|
|
|
|
|
|
|
def test_3005_tcp_transient_teardown_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv6: transient TCP session (3WHS,ACK,FINACK), ref. on ingress"""
|
2017-08-09 11:28:02 +02:00
|
|
|
self.run_tcp_transient_teardown_conn_test(AF_INET6, 0)
|
|
|
|
|
|
|
|
def test_3006_tcp_transient_teardown_conn_test(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""IPv6: transient TCP session (3WHS,ACK,FINACK), ref. on egress"""
|
2017-08-09 11:28:02 +02:00
|
|
|
self.run_tcp_transient_teardown_conn_test(AF_INET6, 1)
|