Skip to content

Commit

Permalink
Match src port
Browse files Browse the repository at this point in the history
  • Loading branch information
bingwang-ms committed Dec 1, 2022
1 parent f0996a9 commit eb4176d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
10 changes: 10 additions & 0 deletions tests/acl/custom_acl_table/acl_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@
"PACKET_ACTION": "FORWARD",
"PRIORITY": "9996"
},
"CUSTOM_TABLE|RULE_5": {
"L4_SRC_PORT": "8080",
"PACKET_ACTION": "FORWARD",
"PRIORITY": "9995"
},
"CUSTOM_TABLE|RULE_6": {
"L4_DST_PORT": "8080",
"PACKET_ACTION": "FORWARD",
"PRIORITY": "9994"
},
"CUSTOM_TABLE|RULE_7": {
"L4_SRC_PORT_RANGE": "8081-8090",
"PACKET_ACTION": "FORWARD",
"PRIORITY": "9993"
},
"CUSTOM_TABLE|RULE_8": {
"L4_DST_PORT_RANGE": "8081-8090",
"PACKET_ACTION": "FORWARD",
Expand Down
2 changes: 1 addition & 1 deletion tests/acl/custom_acl_table/custom_acl_table.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ACL_TABLE_TYPE": {
"CUSTOM_TYPE": {
"MATCHES": "DST_IP,DST_IPV6,ETHER_TYPE,IP_TYPE,IP_PROTOCOL,NEXT_HEADER,L4_DST_PORT,L4_DST_PORT_RANGE",
"MATCHES": "DST_IP,DST_IPV6,ETHER_TYPE,IP_TYPE,IP_PROTOCOL,NEXT_HEADER,L4_SRC_PORT,L4_DST_PORT,L4_SRC_PORT_RANGE,L4_DST_PORT_RANGE",
"ACTIONS": "PACKET_ACTION,COUNTER",
"BIND_POINTS": "PORT"
}
Expand Down
17 changes: 11 additions & 6 deletions tests/acl/custom_acl_table/test_custom_acl_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ def build_testing_pkts(router_mac):
Generate packet for IO test
"""
# The IPs and ports must be exactly the same with rules defined in acl_rules.json
SRC_IP = "192.168.0.2"
SRC_IPV6 = "fc02:1000::2"
DST_IP = "103.23.2.1"
DST_IPV6 = "103:23:2:1::1"
SRC_PORT = 8080
Expand All @@ -177,15 +175,22 @@ def build_testing_pkts(router_mac):
test_packets['RULE_4'] = testutils.simple_tcpv6_packet(eth_dst=router_mac,
ipv6_src='fc02:1000::3',
ipv6_dst=DST_IPV6)


# Verify matching source port (IPV4)
test_packets['RULE_5'] = testutils.simple_tcp_packet(eth_dst=router_mac,
ip_src='192.168.0.3',
ip_dst='1.1.1.1',
tcp_sport=SRC_PORT)
# Verify matching destination port (IPV6)
test_packets['RULE_6'] = testutils.simple_tcpv6_packet(eth_dst=router_mac,
ipv6_src='fc02:1000::3',
ipv6_dst='103:23:2:1::2',
tcp_dport=DST_PORT)

# Verify matching destination port (IPV6)
# Verify matching source port range (IPV4)
test_packets['RULE_7'] = testutils.simple_tcp_packet(eth_dst=router_mac,
ip_src='192.168.0.3',
ip_dst='1.1.1.1',
tcp_sport=SRC_RANGE_PORT)
# Verify matching destination port range (IPV6)
test_packets['RULE_8'] = testutils.simple_tcpv6_packet(eth_dst=router_mac,
ipv6_src='fc02:1000::3',
ipv6_dst='103:23:2:1::2',
Expand Down

0 comments on commit eb4176d

Please sign in to comment.