mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-20 02:38:43 +00:00
pf tests: ensure that we generate all permutations for SCTP multihome
The initial multihome implementation was a little simplistic, and failed to create all of the required states. Given a client with IP 1 and 2 and a server with IP 3 and 4 we end up creating states for 1 - 3 and 2 - 3, as well as 3 - 1 and 4 - 1, but not for 2 - 4. Check for this. MFC after: 1 week Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D42362
This commit is contained in:
parent
d6d38b02ee
commit
483d5c4075
@ -360,6 +360,37 @@ def test_multihome_asconf(self):
|
||||
states = ToolsHelper.get_output("/sbin/pfctl -ss")
|
||||
assert re.search(r"all sctp 192.0.2.1:.*192.0.2.3:1234.*SHUTDOWN", states)
|
||||
|
||||
|
||||
@pytest.mark.require_user("root")
|
||||
def test_permutation(self):
|
||||
# Test that we generate all permutations of src/dst addresses.
|
||||
# Assign two addresses to each end, and check for the expected states
|
||||
srv_vnet = self.vnet_map["vnet2"]
|
||||
|
||||
ifname = self.vnet_map["vnet1"].iface_alias_map["if1"].name
|
||||
ToolsHelper.print_output("/sbin/ifconfig %s inet alias 192.0.2.4/24" % ifname)
|
||||
|
||||
ToolsHelper.print_output("/sbin/pfctl -e")
|
||||
ToolsHelper.pf_rules([
|
||||
"block proto sctp",
|
||||
"pass inet proto sctp to 192.0.2.0/24"])
|
||||
|
||||
# Sanity check, we can communicate with the primary address.
|
||||
client = SCTPClient("192.0.2.3", 1234)
|
||||
client.send(b"hello", 0)
|
||||
rcvd = self.wait_object(srv_vnet.pipe)
|
||||
print(rcvd)
|
||||
assert rcvd['ppid'] == 0
|
||||
assert rcvd['data'] == "hello"
|
||||
|
||||
# Check that we have a state for 192.0.2.3 and 192.0.2.2 to 192.0.2.1, but also to 192.0.2.4
|
||||
states = ToolsHelper.get_output("/sbin/pfctl -ss")
|
||||
print(states)
|
||||
assert re.search(r"all sctp 192.0.2.1:.*192.0.2.3:1234", states)
|
||||
assert re.search(r"all sctp 192.0.2.1:.*192.0.2.2:1234", states)
|
||||
assert re.search(r"all sctp 192.0.2.4:.*192.0.2.3:1234", states)
|
||||
assert re.search(r"all sctp 192.0.2.4:.*192.0.2.2:1234", states)
|
||||
|
||||
class TestSCTPv6(VnetTestTemplate):
|
||||
REQUIRED_MODULES = ["sctp", "pf"]
|
||||
TOPOLOGY = {
|
||||
@ -476,3 +507,33 @@ def test_multihome_asconf(self):
|
||||
# Verify that the state is closing
|
||||
states = ToolsHelper.get_output("/sbin/pfctl -ss")
|
||||
assert re.search(r"all sctp 2001:db8::1\[.*2001:db8::3\[1234\].*SHUTDOWN", states)
|
||||
|
||||
@pytest.mark.require_user("root")
|
||||
def test_permutation(self):
|
||||
# Test that we generate all permutations of src/dst addresses.
|
||||
# Assign two addresses to each end, and check for the expected states
|
||||
srv_vnet = self.vnet_map["vnet2"]
|
||||
|
||||
ifname = self.vnet_map["vnet1"].iface_alias_map["if1"].name
|
||||
ToolsHelper.print_output("/sbin/ifconfig %s inet6 alias 2001:db8::4/64" % ifname)
|
||||
|
||||
ToolsHelper.print_output("/sbin/pfctl -e")
|
||||
ToolsHelper.pf_rules([
|
||||
"block proto sctp",
|
||||
"pass inet6 proto sctp to 2001:db8::0/64"])
|
||||
|
||||
# Sanity check, we can communicate with the primary address.
|
||||
client = SCTPClient("2001:db8::3", 1234)
|
||||
client.send(b"hello", 0)
|
||||
rcvd = self.wait_object(srv_vnet.pipe)
|
||||
print(rcvd)
|
||||
assert rcvd['ppid'] == 0
|
||||
assert rcvd['data'] == "hello"
|
||||
|
||||
# Check that we have a state for 2001:db8::3 and 2001:db8::2 to 2001:db8::1, but also to 2001:db8::4
|
||||
states = ToolsHelper.get_output("/sbin/pfctl -ss")
|
||||
print(states)
|
||||
assert re.search(r"all sctp 2001:db8::1\[.*2001:db8::2\[1234\]", states)
|
||||
assert re.search(r"all sctp 2001:db8::1\[.*2001:db8::3\[1234\]", states)
|
||||
assert re.search(r"all sctp 2001:db8::4\[.*2001:db8::2\[1234\]", states)
|
||||
assert re.search(r"all sctp 2001:db8::4\[.*2001:db8::3\[1234\]", states)
|
||||
|
Loading…
Reference in New Issue
Block a user