diff options
author | 2018-11-27 10:58:54 +0530 | |
---|---|---|
committer | 2018-11-28 20:06:28 +0530 | |
commit | 926062f08345c02d360414feae58c964de2b6415 (patch) | |
tree | 010ab395d80fa2c7cc092fd87428fd9c4769c684 /test | |
parent | missing.h: remove duplicate definition of 'struct ethtool_link_settings' (diff) | |
download | systemd-926062f08345c02d360414feae58c964de2b6415.tar.gz systemd-926062f08345c02d360414feae58c964de2b6415.tar.bz2 systemd-926062f08345c02d360414feae58c964de2b6415.zip |
networkd: add support to configure ip rule port range and protocol.
Please see:
iprule: support for ip_proto, sport and dport match options
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=f686f764682745daf6a93b0a6330ba42a961f858
Closes 10622
Diffstat (limited to 'test')
4 files changed, 42 insertions, 3 deletions
diff --git a/test/fuzz/fuzz-network-parser/25-fibrule-port-range.network b/test/fuzz/fuzz-network-parser/25-fibrule-port-range.network new file mode 100644 index 000000000..b0502175f --- /dev/null +++ b/test/fuzz/fuzz-network-parser/25-fibrule-port-range.network @@ -0,0 +1,11 @@ +[Match] +Name=test1 + +[RoutingPolicyRule] +TypeOfService=0x08 +Table=7 +From= 192.168.100.18 +Priority=111 +SourcePort = 1123-1150 +DestinationPort = 3224-3290 +Protocol = tcp diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index 766c76008..7508f693d 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -150,6 +150,9 @@ From= TypeOfService= Priority= FirewallMark= +SourcePort= +DestinationPort= +Protocol= [IPv6PrefixDelegation] RouterPreference= DNSLifetimeSec= diff --git a/test/test-network/conf/25-fibrule-port-range.network b/test/test-network/conf/25-fibrule-port-range.network new file mode 100644 index 000000000..b0502175f --- /dev/null +++ b/test/test-network/conf/25-fibrule-port-range.network @@ -0,0 +1,11 @@ +[Match] +Name=test1 + +[RoutingPolicyRule] +TypeOfService=0x08 +Table=7 +From= 192.168.100.18 +Priority=111 +SourcePort = 1123-1150 +DestinationPort = 3224-3290 +Protocol = tcp diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 73ecf6f73..f9372d27e 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -427,9 +427,9 @@ class NetworkdNetWorkTests(unittest.TestCase, Utilities): units = ['12-dummy.netdev', 'test-static.network', 'configure-without-carrier.network', '11-dummy.netdev', '23-primary-slave.network', '23-test1-bond199.network', '11-dummy.netdev', '23-bond199.network', '25-bond-active-backup-slave.netdev', '12-dummy.netdev', '23-active-slave.network', - 'routing-policy-rule.network', '25-address-section.network', '25-address-section-miscellaneous.network', - '25-route-section.network', '25-route-type.network', '25-route-tcp-window-settings.network', - '25-route-gateway.network', '25-route-gateway-on-link.network', + 'routing-policy-rule.network', '25-fibrule-port-range.network', '25-address-section.network', + '25-address-section-miscellaneous.network', '25-route-section.network', '25-route-type.network', + '25-route-tcp-window-settings.network', '25-route-gateway.network', '25-route-gateway-on-link.network', '25-address-link-section.network', '25-ipv6-address-label-section.network', '25-link-section-unmanaged.network', '25-sysctl.network'] @@ -496,6 +496,20 @@ class NetworkdNetWorkTests(unittest.TestCase, Utilities): self.assertRegex(output, 'oif test1') self.assertRegex(output, 'lookup 7') + def test_routing_policy_rule_port_range(self): + self.copy_unit_to_networkd_unit_path('25-fibrule-port-range.network', '11-dummy.netdev') + self.start_networkd() + + self.assertTrue(self.link_exits('test1')) + output = subprocess.check_output(['ip', 'rule']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, '111') + self.assertRegex(output, 'from 192.168.100.18') + self.assertRegex(output, '1123-1150') + self.assertRegex(output, '3224-3290') + self.assertRegex(output, 'tcp') + self.assertRegex(output, 'lookup 7') + def test_address_preferred_lifetime_zero_ipv6(self): self.copy_unit_to_networkd_unit_path('25-address-section-miscellaneous.network', '12-dummy.netdev') self.start_networkd() |