From patchwork Fri Dec 11 02:33:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, BoX C" X-Patchwork-Id: 84991 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 576BAA04DB; Fri, 11 Dec 2020 03:34:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3FBCDAC9C; Fri, 11 Dec 2020 03:34:45 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 73E3FAC9B for ; Fri, 11 Dec 2020 03:34:42 +0100 (CET) IronPort-SDR: LYzUm7GlQgcRvun/Y8M318qohOIiSRwYErigVvoZlJqXNb+v8FS/Ocx+lfnanotokbpA7Xy6Cf 1vP5ZOBK8A+Q== X-IronPort-AV: E=McAfee;i="6000,8403,9831"; a="259082648" X-IronPort-AV: E=Sophos;i="5.78,409,1599548400"; d="scan'208";a="259082648" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2020 18:34:41 -0800 IronPort-SDR: UnPOnfiUz59eApLh2MPi3PdcTJytc+FLtGby4mS68+1ywWHFZ0urbA7nNET9iU7ibwD7Ujfp4i l8AqMQEWCzqA== X-IronPort-AV: E=Sophos;i="5.78,409,1599548400"; d="scan'208";a="544389188" Received: from unknown (HELO cb-dts.sh.intel.com) ([10.240.183.58]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2020 18:34:39 -0800 From: ChenBo To: dts@dpdk.org Cc: ChenBo Date: Fri, 11 Dec 2020 10:33:17 +0800 Message-Id: <20201211023317.13817-1-box.c.chen@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dts] [PATCH V1] tests/cvl_dcf_switch_filter: add drop action test case X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Add test cases to test the drop action function of DCF. Signed-off-by: ChenBo Tested-by: Chen, BoX C Acked-by: Xueqin Lin --- tests/TestSuite_cvl_dcf_switch_filter.py | 176 +++++++++++++++++++++++ 1 file changed, 176 insertions(+) diff --git a/tests/TestSuite_cvl_dcf_switch_filter.py b/tests/TestSuite_cvl_dcf_switch_filter.py index a65b73a3..be2e6cd6 100644 --- a/tests/TestSuite_cvl_dcf_switch_filter.py +++ b/tests/TestSuite_cvl_dcf_switch_filter.py @@ -1216,6 +1216,156 @@ tv_mac_vlan_pppoe_ipcp_pay = { "expect_results":{"expect_pkts":0}} } +tv_mac_ipv4_drop = { + "name": "tv_mac_ipv4_drop", + "rte_flow_pattern": "flow create 0 priority 0 ingress pattern eth / ipv4 src is 192.168.0.1 / end actions drop / end", + "matched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.1")/Raw("x"*80)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 0}}, + "mismatched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.2")/Raw("x"*80)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 1}} +} + +tv_mac_ipv4_mask_drop = { + "name": "tv_mac_ipv4_drop", + "rte_flow_pattern": "flow create 0 ingress pattern eth / ipv4 dst spec 224.0.0.0 dst mask 240.0.0.0 / end actions drop / end", + "matched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55")/IP(dst="239.0.0.0")/TCP()/Raw("x"*80)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 0}}, + "mismatched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55")/IP(dst="128.0.0.0")/TCP()/Raw("x"*80)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 1}} +} + +tv_mac_nvgre_drop = { + "name": "tv_mac_nvgre_drop", + "rte_flow_pattern": "flow create 0 ingress pattern eth / ipv4 dst is 192.168.0.1 / nvgre tni is 2 / eth / ipv4 src is 192.168.1.2 dst is 192.168.1.3 / end actions drop / end", + "matched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55")/IP(dst="192.168.0.1")/NVGRE(TNI=2)/Ether()/IP(src="192.168.1.2", dst="192.168.1.3")/Raw("x"*80)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 0}}, + "mismatched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55")/IP(dst="192.168.0.1")/NVGRE(TNI=1)/Ether()/IP(src="192.168.1.2", dst="192.168.1.3")/Raw("x"*80)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 1}} +} + +tv_mac_ppoes_drop = { + "name": "tv_mac_ppoes_drop", + "rte_flow_pattern": "flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / vlan tci is 1 / pppoes seid is 3 / pppoe_proto_id is 0x0021 / end actions drop / end", + "matched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55",type=0x8100)/Dot1Q(vlan=1,type=0x8864)/PPPoE(sessionid=3)/PPP(b"\\x00\\x21")/IP()/Raw("x" * 80)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 0}}, + "mismatched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55",type=0x8100)/Dot1Q(vlan=1,type=0x8864)/PPPoE(sessionid=2)/PPP(b"\\x00\\x21")/IP()/Raw("x" * 80)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 1}} +} + +tv_mac_pfcp_drop = { + "name": "tv_mac_pfcp_drop", + "rte_flow_pattern": "flow create 0 ingress pattern eth / ipv4 / udp / pfcp s_field is 0 / end actions drop / end", + "matched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55")/IP()/UDP(dport=8805)/PFCP(S=0)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 0}}, + "mismatched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55")/IP()/UDP(dport=8805)/PFCP(S=1)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 1}} +} + +tv_mac_vlan_drop = { + "name": "tv_mac_vlan_drop", + "rte_flow_pattern": "flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / vlan tci is 1 / end actions drop / end", + "matched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55",type=0x8100)/Dot1Q(vlan=1)/IP(src="192.168.0.1",dst="192.168.0.2",tos=4,ttl=2)/TCP()/Raw("X"*80)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 0}}, + "mismatched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55",type=0x8100)/Dot1Q(vlan=2)/IP(src="192.168.0.1",dst="192.168.0.2",tos=4,ttl=2)/TCP()/Raw("X"*80)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 1}} +} + +tv_mac_l2tp_drop = { + "name": "tv_mac_l2tp_drop", + "rte_flow_pattern": "flow create 0 priority 0 ingress pattern eth / ipv4 src is 192.168.0.2 / l2tpv3oip session_id is 1 / end actions drop / end", + "matched": {"scapy_str": ["Ether(dst='00:11:22:33:44:55')/IP(src='192.168.0.2', proto=115)/L2TP(b'\\x00\\x00\\x00\\x01')/('X'*480)"], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 0}}, + "mismatched": {"scapy_str": ["Ether(dst='00:11:22:33:44:55')/IP(src='192.168.0.2', proto=115)/L2TP(b'\\x00\\x00\\x00\\x02')/('X'*480)"], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 1}} +} + +tv_mac_esp_drop = { + "name": "tv_mac_l2tp_drop", + "rte_flow_pattern": "flow create 0 priority 0 ingress pattern eth / ipv4 src is 192.168.0.2 / esp spi is 1 / end actions drop / end", + "matched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.2", proto=50)/ESP(spi=1)/("X"*480)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 0}}, + "mismatched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.2", proto=50)/ESP(spi=2)/("X"*480)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 1}} +} + +tv_mac_blend_pkg_drop = { + "name": "tv_mac_blend_pkg_drop", + "rte_flow_pattern": ["flow create 0 priority 0 ingress pattern eth / ipv4 src is 192.168.0.1 / end actions drop / end", + "flow create 0 ingress pattern eth / ipv4 dst spec 224.0.0.0 dst mask 240.0.0.0 / end actions drop / end", + "flow create 0 ingress pattern eth / ipv4 dst is 192.168.0.3 / nvgre tni is 2 / eth / ipv4 src is 192.168.1.2 dst is 192.168.1.3 / end actions drop / end", + "flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / vlan tci is 1 / pppoes seid is 3 / pppoe_proto_id is 0x0021 / end actions drop / end", + "flow create 0 ingress pattern eth / ipv4 / udp / pfcp s_field is 0 / end actions drop / end", + "flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / vlan tci is 1 / end actions drop / end", + "flow create 0 priority 0 ingress pattern eth / ipv4 src is 192.168.0.4 / l2tpv3oip session_id is 1 / end actions drop / end", + "flow create 0 priority 0 ingress pattern eth / ipv4 src is 192.168.0.5 / esp spi is 1 / end actions drop / end"], + "matched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.1")/Raw("x"*80)', + 'Ether(dst="00:11:22:33:44:55")/IP(dst="239.0.0.0")/TCP()/Raw("x"*80)', + 'Ether(dst="00:11:22:33:44:55")/IP(dst="192.168.0.3")/NVGRE(TNI=2)/Ether()/IP(src="192.168.1.2", dst="192.168.1.3")/Raw("x"*80)', + 'Ether(dst="00:11:22:33:44:55",type=0x8100)/Dot1Q(vlan=1,type=0x8864)/PPPoE(sessionid=3)/PPP(b"\\x00\\x21")/IP()/Raw("X" * 80)', + 'Ether(dst="00:11:22:33:44:55")/IP()/UDP(dport=8805)/PFCP(S=0)', + 'Ether(dst="00:11:22:33:44:55",type=0x8100)/Dot1Q(vlan=1)/IP(src="192.168.0.1",dst="192.168.0.2",tos=4,ttl=2)/TCP()/Raw("X"*80)', + 'Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.4", proto=115)/L2TP(b"\\x00\\x00\\x00\\x01")/("X"*480)', + 'Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.5", proto=50)/ESP(spi=1)/("X"*80)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 0}}, + "mismatched": {"scapy_str": ['Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.6")/Raw("x"*80)', + 'Ether(dst="00:11:22:33:44:55")/IP(dst="128.0.0.0")/TCP()/Raw("x"*80)', + 'Ether(dst="00:11:22:33:44:55")/IP(dst="192.168.0.8")/NVGRE(TNI=1)/Ether()/IP(src="192.168.1.2", dst="192.168.1.3")/Raw("x"*80)', + 'Ether(dst="00:11:22:33:44:55",type=0x8100)/Dot1Q(vlan=1,type=0x8864)/PPPoE(sessionid=2)/PPP(b"\\x00\\x21")/IP()/Raw("x" * 80)', + 'Ether(dst="00:11:22:33:44:55")/IP()/UDP(dport=8805)/PFCP(S=1)', + 'Ether(dst="00:11:22:33:44:55",type=0x8100)/Dot1Q(vlan=2)/IP(src="192.168.0.9",dst="192.168.0.2",tos=4,ttl=2)/TCP()/Raw("X"*80)', + 'Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.10", proto=115)/L2TP(b"\\x00\\x00\\x00\\x02")/("X"*480)', + 'Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.11", proto=50)/ESP(spi=2)/("X"*80)'], + "check_func": {"func": rfc.check_vf_rx_packets_number, + "param": {"expect_port": 1, "expect_queues": "null"}}, + "expect_results": {"expect_pkts": 8}} +} + +sv_mac_test_drop_action = [ + tv_mac_ipv4_drop, + tv_mac_ipv4_mask_drop, + tv_mac_nvgre_drop, + tv_mac_ppoes_drop, + tv_mac_pfcp_drop, + tv_mac_vlan_drop, + tv_mac_l2tp_drop, + tv_mac_esp_drop, + tv_mac_blend_pkg_drop +] + class CVLDCFSwitchFilterTest(TestCase): def bind_nics_driver(self, ports, driver=""): @@ -2175,6 +2325,32 @@ class CVLDCFSwitchFilterTest(TestCase): self.setup_1pf_vfs_env() self._rte_flow_validate_pattern(tv_mac_vlan_pppoe_ipcp_pay) + def test_mac_drop_action(self): + self.setup_1pf_vfs_env() + self.dut.send_expect('ip link set %s vf 1 mac "00:11:22:33:44:55"' % self.pf0_intf, '# ') + self.launch_testpmd() + for pattern in sv_mac_test_drop_action: + # validate a rule + self.validate_switch_filter_rule(pattern["rte_flow_pattern"]) + # create a rule + rule_list = self.create_switch_filter_rule(pattern["rte_flow_pattern"]) # create a rule + self.check_switch_filter_rule_list(0, rule_list) + # send matched packets and check + matched_dic = pattern["matched"] + self.send_and_check_packets(matched_dic) + # send mismatched packets and check + mismatched_dic = pattern["mismatched"] + self.send_and_check_packets(mismatched_dic) + # destroy rule and send matched packets + self.destroy_switch_filter_rule(0, rule_list) + self.check_switch_filter_rule_list(0, []) + # send matched packets and check + destroy_dict = copy.deepcopy(matched_dic) + destroy_dict["expect_results"]["expect_pkts"] = len(pattern["matched"]["scapy_str"]) + self.send_and_check_packets(destroy_dict) + self.dut.send_expect("flow flush 0", "testpmd> ", 15) + self.dut.send_expect("clear port stats all", "testpmd> ", 15) + def tear_down(self): """ Run after each test case.