aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--resources/libraries/python/honeycomb/HcAPIKwACL.py63
-rw-r--r--resources/test_data/honeycomb/ietf_acl.py124
-rw-r--r--tests/func/honeycomb/081_ietf_acl_traffic.robot147
3 files changed, 279 insertions, 55 deletions
diff --git a/resources/libraries/python/honeycomb/HcAPIKwACL.py b/resources/libraries/python/honeycomb/HcAPIKwACL.py
index 1042adc872..82a953e128 100644
--- a/resources/libraries/python/honeycomb/HcAPIKwACL.py
+++ b/resources/libraries/python/honeycomb/HcAPIKwACL.py
@@ -281,14 +281,19 @@ class ACLKeywords(object):
:rtype: bytearray
:raises HoneycombError: If the operation fails.
"""
- if layer.lower() == "l2":
- suffix = "eth"
- elif layer.lower() in ("l3_ip4", "l3_ip6", "l4"):
+ layer = layer.lower()
+ suffix_dict = {"l2": "eth",
+ "l3_ip4": "ipv4",
+ "l3_ip6": "ipv6"
+ }
+ if layer == "l4":
raise NotImplementedError
- else:
+ try:
+ suffix = suffix_dict[layer]
+ except KeyError:
raise ValueError("Unexpected value of layer argument {0}."
- "Valid options are: L2, L3_IP4, L3_IP6, L4."
- .format(layer))
+ "Valid options are: {1}"
+ .format(layer, suffix_dict.keys()))
path = "/acl/ietf-access-control-list:{0}-acl/{1}".format(
suffix, list_name)
@@ -328,6 +333,7 @@ class ACLKeywords(object):
:raises HoneycombError: If the operation fails.
"""
+ layer = layer.lower()
interface = Topology.convert_interface_reference(
node, interface, "name")
@@ -341,30 +347,33 @@ class ACLKeywords(object):
path = "/interface/{0}/ietf-acl/{1}/access-lists".format(
interface, direction)
- data = {
- "access-lists": {
- "acl": [{
- "type": None,
- "name": list_name
- }],
- "default-action": default_action,
- "mode": None
- }
- }
-
- acl_type = "ietf-access-control-list:{suffix}-acl"
-
- if layer.lower() == "l2":
- data["access-lists"]["mode"] = "l2"
- data["access-lists"]["acl"][0]["type"] = \
- acl_type.format(suffix="eth")
+ layers = {
+ "l2": {"mode": "l2", "suffix": "eth"},
+ "l3_ip4": {"mode": "l3", "suffix": "ipv4"},
+ "l3_ip6": {"mode": "l3", "suffix": "ipv6"}
+ }
- elif layer.lower() in ("l3_ip4", "l3_ip6", "L4"):
+ if layer == "L4":
raise NotImplementedError
else:
- raise ValueError("Unknown network layer {0}. "
- "Valid options are: "
- "L2, L3_IP4, L3_IP6, L4.".format(layer))
+ try:
+ data = {
+ "access-lists": {
+ "acl": [
+ {
+ "type": "ietf-access-control-list:{0}-acl"
+ .format(layers[layer]['suffix']),
+ "name": list_name
+ }
+ ],
+ "default-action": default_action,
+ "mode": layers[layer]['mode']
+ }
+ }
+ except KeyError:
+ raise ValueError("Unknown network layer {0}. "
+ "Valid options are: {1}".format(
+ layer, layers.keys()))
status_code, resp = HcUtil.put_honeycomb_data(
node, "config_vpp_interfaces", data, path)
diff --git a/resources/test_data/honeycomb/ietf_acl.py b/resources/test_data/honeycomb/ietf_acl.py
index d5c3040d7a..672bca3199 100644
--- a/resources/test_data/honeycomb/ietf_acl.py
+++ b/resources/test_data/honeycomb/ietf_acl.py
@@ -28,8 +28,9 @@ def get_variables(test_case, name):
:rtype: dict
"""
+ test_case = test_case.lower()
variables = {
- # generic packet data
+ # Variables for control packet, should always pass through DUT
"src_ip": "16.0.0.1",
"dst_ip": "16.0.1.1",
"dst_net": "16.0.1.0",
@@ -38,17 +39,51 @@ def get_variables(test_case, name):
"src_mac": "01:02:03:04:05:06",
"dst_mac": "10:20:30:40:50:60"}
- if test_case.lower() == "l2":
- classify_vars = {
+ test_vars = {
+ "l2": {
+ # MACs classified directly
"classify_src": "12:23:34:45:56:67",
"classify_dst": "89:9A:AB:BC:CD:DE",
+ # MACs classified through mask
"classify_src2": "01:02:03:04:56:67",
"classify_dst2": "89:9A:AB:BC:50:60",
"src_mask": "00:00:00:00:FF:FF",
- "dst_mask": "FF:FF:FF:FF:00:00",
- }
-
- acl_settings = {
+ "dst_mask": "FF:FF:FF:FF:00:00"
+ },
+ "l3_ip4": {
+ # IPs for DUT interface setup
+ "dut_to_tg_if1_ip": "16.0.0.2",
+ "dut_to_tg_if2_ip": "192.168.0.2",
+ "gateway": "192.168.0.1",
+ # classified networks
+ "classify_src_net": "16.0.2.0",
+ "classify_dst_net": "16.0.3.0",
+ # IPs in classified networks
+ "classify_src": "16.0.2.1",
+ "classify_dst": "16.0.3.1",
+ "prefix_length": 24
+ },
+ "l3_ip6": {
+ # Override control packet addresses with IPv6
+ "src_ip": "10::1",
+ "dst_ip": "11::1",
+ "dst_net": "11::",
+ # IPs for DUT interface setup
+ "dut_to_tg_if1_ip": "10::2",
+ "dut_to_tg_if2_ip": "20::2",
+ "gateway": "20::1",
+ # classified networks
+ "classify_src_net": "12::",
+ "classify_dst_net": "13::",
+ # IPs in classified networks
+ "classify_src": "12::1",
+ "classify_dst": "13::1",
+ "prefix_length": 64
+ }
+ }
+ acl_data = {
+ # ACL configuration for L2 tests
+ "l2": {
"acl": [{
"acl-type":
"ietf-access-control-list:eth-acl",
@@ -57,13 +92,63 @@ def get_variables(test_case, name):
"rule-name": "rule1",
"matches": {
"source-mac-address":
- classify_vars["classify_src"],
+ test_vars["l2"]["classify_src"],
"source-mac-address-mask":
- classify_vars["src_mask"],
+ test_vars["l2"]["src_mask"],
"destination-mac-address":
- classify_vars["classify_dst"],
+ test_vars["l2"]["classify_dst"],
"destination-mac-address-mask":
- classify_vars["dst_mask"]
+ test_vars["l2"]["dst_mask"]
+ },
+ "actions": {
+ "deny": {}
+ }
+ }]}
+ }]
+ },
+ # ACL configuration for L3 IPv4 tests
+ "l3_ip4": {
+ "acl": [{
+ "acl-type":
+ "ietf-access-control-list:ipv4-acl",
+ "acl-name": name,
+ "access-list-entries": {"ace": [{
+ "rule-name": "rule1",
+ "matches": {
+ "source-ipv4-network":
+ "{0}/{1}".format(
+ test_vars["l3_ip4"]["classify_src_net"],
+ test_vars["l3_ip4"]["prefix_length"]),
+ "destination-ipv4-network":
+ "{0}/{1}".format(
+ test_vars["l3_ip4"]["classify_dst_net"],
+ test_vars["l3_ip4"]["prefix_length"]),
+ "protocol": 17
+ },
+ "actions": {
+ "deny": {}
+ }
+ }]}
+ }]
+ },
+ # ACL settings for L3 IPv6 tests
+ "l3_ip6": {
+ "acl": [{
+ "acl-type":
+ "ietf-access-control-list:ipv6-acl",
+ "acl-name": name,
+ "access-list-entries": {"ace": [{
+ "rule-name": "rule1",
+ "matches": {
+ "source-ipv6-network":
+ "{0}/{1}".format(
+ test_vars["l3_ip6"]["classify_src_net"],
+ test_vars["l3_ip6"]["prefix_length"]),
+ "destination-ipv6-network":
+ "{0}/{1}".format(
+ test_vars["l3_ip6"]["classify_dst_net"],
+ test_vars["l3_ip6"]["prefix_length"]),
+ "protocol": 17
},
"actions": {
"deny": {}
@@ -71,12 +156,15 @@ def get_variables(test_case, name):
}]}
}]
}
+ }
+ try:
+ variables.update(test_vars[test_case])
+ variables.update(
+ {"acl_settings": acl_data[test_case]}
+ )
+ except KeyError:
+ raise Exception("Unrecognized test case {0}."
+ " Valid options are: {1}".format(
+ test_case, acl_data.keys()))
- elif test_case.lower() in ("l3_ip4", "l3_ip6", "l4"):
- raise NotImplementedError
- else:
- raise Exception("Unrecognized test case {0}".format(test_case))
-
- variables.update(classify_vars)
- variables["acl_settings"] = acl_settings
return variables
diff --git a/tests/func/honeycomb/081_ietf_acl_traffic.robot b/tests/func/honeycomb/081_ietf_acl_traffic.robot
index a6672ea1c4..53d4bddc95 100644
--- a/tests/func/honeycomb/081_ietf_acl_traffic.robot
+++ b/tests/func/honeycomb/081_ietf_acl_traffic.robot
@@ -20,6 +20,8 @@
| &{bd_if_settings}= | split_horizon_group=${0} | bvi=${False}
# Names for AC lists
| ${acl_name_l2}= | acl_l2
+| ${acl_name_l3_ip4}= | acl_l3_ip4
+| ${acl_name_l3_ip6}= | acl_l3_ip6
*** Settings ***
| Resource | resources/libraries/robot/default.robot
@@ -31,6 +33,13 @@
| Resource | resources/libraries/robot/traffic.robot
| Library | resources.libraries.python.honeycomb.HcAPIKwACL.ACLKeywords
| Library | resources.libraries.python.Trace
+| Library | resources.libraries.python.IPv4Setup
+| Library | resources.libraries.python.IPv4Util
+| Library | resources.libraries.python.IPv6Util
+| Library | resources.libraries.python.Routing
+| Test Teardown | Run Keywords | Clear IETF-ACL settings
+| ... | ${node} | ${dut_to_tg_if1} | AND
+| ... | Show Packet Trace on All DUTs | ${nodes}
| Suite Teardown | Run Keyword If Any Tests Failed
| ... | Restart Honeycomb And VPP And Clear Persisted Configuration | ${node}
| Documentation | *Honeycomb access control lists test suite for IETF-ACL node.*
@@ -51,17 +60,8 @@
| | ... | Show Packet Trace on All DUTs | ${nodes} | AND
| | ... | Honeycomb removes all bridge domains
| | ... | ${node} | ${dut_to_tg_if1} | ${dut_to_tg_if2}
-| | Given Path For 2-node Testing Is Set
-| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
-| | And Import Variables | resources/test_data/honeycomb/ietf_acl.py
+| | Given Setup interfaces and bridge domain for ietf-ACL test
| | ... | L2 | ${acl_name_l2}
-| | And Honeycomb Sets Interface State | ${dut_node} | ${dut_to_tg_if1} | up
-| | And Honeycomb Sets Interface State | ${dut_node} | ${dut_to_tg_if2} | up
-| | And Honeycomb Creates L2 Bridge Domain
-| | ... | ${dut_node} | ${bd_name} | ${bd_settings}
-| | And Honeycomb Adds Interfaces To Bridge Domain
-| | ... | ${dut_node} | ${dut_to_tg_if1} | ${dut_to_tg_if2}
-| | ... | ${bd_name} | ${bd_if_settings}
| | When Honeycomb creates ACL chain through IETF node
| | ... | ${dut_node} | ${acl_name_l2} | L2 | ${acl_settings}
| | And Honeycomb assigns IETF-ACL chain to interface
@@ -81,3 +81,130 @@
| | ... | ${tg_to_dut_if1} | ${classify_src2}
| | ... | ${tg_to_dut_if2} | ${classify_dst2}
| | ... | TCP | ${src_port} | ${dst_port}
+
+| TC02: Honeycomb can configure L3 ACL IPv4 filtering through IETF-ACL node
+| | [Documentation]
+| | ... | [Top] TG=DUT1=TG.
+| | ... | [Enc] Eth-IPv4-TCP.
+| | ... | [Cfg] (Using Honeycomb API) On DUT1 set IPv4 addresses on both\
+| | ... | interfaces to TG, add ARP entry and routes, and configure L3 IPv4 ACL\
+| | ... | on ingress interface with src/dst IP and protocol.
+| | ... | [Ver] Send simple TCP packets from one TG interface to the other,\
+| | ... | using different IPv4 IPs. Receive all packets except those with\
+| | ... | IPs in the filtered ranges and UDP protocol payload.
+| | Given Setup interface IPs and routes for IPv4 ietf-ACL test
+| | ... | L3_IP4 | ${acl_name_l3_ip4}
+| | When Honeycomb creates ACL chain through IETF node
+| | ... | ${dut_node} | ${acl_name_l3_ip4} | L3_IP4 | ${acl_settings}
+| | And Honeycomb assigns IETF-ACL chain to interface
+| | ... | ${dut_node} | ${dut_to_tg_if1} | L3_IP4 | ingress | ${acl_name_l3_ip4}
+| | ... | permit
+| | Then Send TCP or UDP packet | ${tg_node}
+| | ... | ${src_ip} | ${dst_ip}
+| | ... | ${tg_to_dut_if1} | ${tg_to_dut_if1_mac}
+| | ... | ${tg_to_dut_if2} | ${dut_to_tg_if1_mac}
+| | ... | UDP | ${src_port} | ${dst_port}
+| | And Send TCP or UDP packet | ${tg_node}
+| | ... | ${classify_src} | ${classify_dst}
+| | ... | ${tg_to_dut_if1} | ${tg_to_dut_if1_mac}
+| | ... | ${tg_to_dut_if2} | ${dut_to_tg_if1_mac}
+| | ... | TCP | ${src_port} | ${dst_port}
+| | And Run keyword and expect error | TCP/UDP Rx timeout
+| | ... | Send TCP or UDP packet | ${tg_node}
+| | ... | ${classify_src} | ${classify_dst}
+| | ... | ${tg_to_dut_if1} | ${tg_to_dut_if1_mac}
+| | ... | ${tg_to_dut_if2} | ${dut_to_tg_if1_mac}
+| | ... | UDP | ${src_port} | ${dst_port}
+
+| TC03: Honeycomb can configure L3 ACL IPv6 filtering through IETF-ACL node
+| | [Documentation]
+| | ... | [Top] TG=DUT1=TG.
+| | ... | [Enc] Eth-IPv4-TCP.
+| | ... | [Cfg] (Using Honeycomb API) On DUT1 set IPv6 addresses on both\
+| | ... | interfaces to TG, add IP neighbor entry and routes, and configure\
+| | ... | L3 IPv6 ACL on ingress interface with src/dst IP and next-header.
+| | ... | [Ver] Send simple TCP packets from one TG interface to the other,\
+| | ... | using different IPv6 IPs. Receive all packets except those with\
+| | ... | IPs in the filtered ranges and UDP protocol payload.
+| | Given Path for 2-node testing is set
+| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
+| | And Import Variables | resources/test_data/honeycomb/ietf_acl.py
+| | ... | L3_IP6 | ${acl_name_l3_ip6}
+| | And Honeycomb sets interface state | ${dut_node} | ${dut_to_tg_if1} | up
+| | And Honeycomb sets interface state | ${dut_node} | ${dut_to_tg_if2} | up
+# TODO: Configure addresses through Honeycomb when implemented. (Honeycomb-102)
+| | And Set Interface Address | ${dut_node}
+| | ... | ${dut_to_tg_if1} | ${dut_to_tg_if1_ip} | ${prefix_length}
+| | And Set Interface Address | ${dut_node}
+| | ... | ${dut_to_tg_if2} | ${dut_to_tg_if2_ip} | ${prefix_length}
+| | And VPP RA suppress link layer | ${dut_node} | ${dut_to_tg_if2}
+# TODO: Configure route through Honeycomb when implemented.(Honeycomb-58)
+| | And Add IP Neighbor
+| | ... | ${node} | ${dut_to_tg_if2} | ${gateway} | ${tg_to_dut_if2_mac}
+| | And VPP Route Add | ${node} | ${dst_net} | ${prefix_length}
+| | ... | ${gateway} | interface=${dut_to_tg_if2} | use_sw_index=False
+| | And VPP Route Add | ${node} | ${classify_dst_net} | ${prefix_length}
+| | ... | ${gateway} | interface=${dut_to_tg_if2} | use_sw_index=False
+| | When Honeycomb creates ACL chain through IETF node
+| | ... | ${dut_node} | ${acl_name_l3_ip6} | L3_IP6 | ${acl_settings}
+| | And Honeycomb assigns IETF-ACL chain to interface
+| | ... | ${dut_node} | ${dut_to_tg_if1} | L3_IP6 | ingress | ${acl_name_l3_ip6}
+| | ... | permit
+| | Then Send TCP or UDP packet | ${tg_node}
+| | ... | ${src_ip} | ${dst_ip}
+| | ... | ${tg_to_dut_if1} | ${tg_to_dut_if1_mac}
+| | ... | ${tg_to_dut_if2} | ${dut_to_tg_if1_mac}
+| | ... | UDP | ${src_port} | ${dst_port}
+| | And Send TCP or UDP packet | ${tg_node}
+| | ... | ${classify_src} | ${classify_dst}
+| | ... | ${tg_to_dut_if1} | ${tg_to_dut_if1_mac}
+| | ... | ${tg_to_dut_if2} | ${dut_to_tg_if1_mac}
+| | ... | TCP | ${src_port} | ${dst_port}
+| | And Run keyword and expect error | TCP/UDP Rx timeout
+| | ... | Send TCP or UDP packet | ${tg_node}
+| | ... | ${classify_src} | ${classify_dst}
+| | ... | ${tg_to_dut_if1} | ${tg_to_dut_if1_mac}
+| | ... | ${tg_to_dut_if2} | ${dut_to_tg_if1_mac}
+| | ... | UDP | ${src_port} | ${dst_port}
+
+# TODO: Test case for L4 ACL port-based filtering
+# TODO: Test case for multiple classify rules and rule ordering
+
+*** Keywords ***
+| Setup interface IPs and routes for IPv4 ietf-ACL test
+| | [Arguments] | ${test_data_id} | ${acl_name}
+| | Path for 2-node testing is set
+| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
+| | Import Variables | resources/test_data/honeycomb/ietf_acl.py
+| | ... | ${test_data_id} | ${acl_name}
+| | Honeycomb sets interface state | ${dut_node} | ${dut_to_tg_if1} | up
+| | Honeycomb sets interface state | ${dut_node} | ${dut_to_tg_if2} | up
+| | Honeycomb sets interface ipv4 address with prefix | ${dut_node}
+| | ... | ${dut_to_tg_if1} | ${dut_to_tg_if1_ip}
+| | ... | ${prefix_length} | ${if_settings}
+| | Honeycomb sets interface ipv4 address with prefix | ${dut_node}
+| | ... | ${dut_to_tg_if2} | ${dut_to_tg_if2_ip}
+| | ... | ${prefix_length} | ${if_settings}
+# TODO: Configure routes through Honeycomb when implemented.(Honeycomb-58)
+| | Add ARP on DUT
+| | ... | ${node} | ${dut_to_tg_if2} | ${gateway} | ${tg_to_dut_if2_mac}
+| | VPP Route Add
+| | ... | ${node} | ${dst_net} | ${prefix_length} | ${gateway}
+| | ... | interface=${dut_to_tg_if2} | use_sw_index=False
+| | VPP Route Add
+| | ... | ${node} | ${classify_dst_net} | ${prefix_length} | ${gateway}
+| | ... | interface=${dut_to_tg_if2} | use_sw_index=False
+
+| Setup interfaces and bridge domain for ietf-ACL test
+| | [Arguments] | ${test_data_id} | ${acl_name}
+| | Path For 2-node Testing Is Set
+| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
+| | Import Variables | resources/test_data/honeycomb/ietf_acl.py
+| | ... | ${test_data_id} | ${acl_name}
+| | Honeycomb Sets Interface State | ${dut_node} | ${dut_to_tg_if1} | up
+| | Honeycomb Sets Interface State | ${dut_node} | ${dut_to_tg_if2} | up
+| | Honeycomb Creates L2 Bridge Domain
+| | ... | ${dut_node} | ${bd_name} | ${bd_settings}
+| | Honeycomb Adds Interfaces To Bridge Domain
+| | ... | ${dut_node} | ${dut_to_tg_if1} | ${dut_to_tg_if2}
+| | ... | ${bd_name} | ${bd_if_settings} \ No newline at end of file