From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AACD0A0C43; Tue, 19 Oct 2021 08:54:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9020240142; Tue, 19 Oct 2021 08:54:54 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 86A604003E for ; Tue, 19 Oct 2021 08:54:52 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10141"; a="215361703" X-IronPort-AV: E=Sophos;i="5.85,383,1624345200"; d="scan'208";a="215361703" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2021 23:54:51 -0700 X-IronPort-AV: E=Sophos;i="5.85,383,1624345200"; d="scan'208";a="661676049" Received: from unknown (HELO dpdk-zhaohy-t.sh.intel.com) ([10.240.183.68]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2021 23:54:50 -0700 From: Jiale Song To: dts@dpdk.org Cc: Jiale Song Date: Tue, 19 Oct 2021 15:08:36 +0800 Message-Id: <1634627316-181227-1-git-send-email-songx.jiale@intel.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dts] [PATCH V1] tests/dcf_lifecycle: modify the acl rule creation method X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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" as the priority of switch rule becomes higher, some rules that support switch cannot be downloaded directly to acl. modify the method of creating acl rule Signed-off-by: Jiale Song --- tests/TestSuite_dcf_lifecycle.py | 53 +++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/tests/TestSuite_dcf_lifecycle.py b/tests/TestSuite_dcf_lifecycle.py index d47ef2b..c7cc79b 100755 --- a/tests/TestSuite_dcf_lifecycle.py +++ b/tests/TestSuite_dcf_lifecycle.py @@ -315,6 +315,7 @@ class TestDcfLifeCycle(TestCase): "-c {core_mask} " "-n {mem_channel} " "{allowlist} " + "--log-level=ice,7 " "--file-prefix={prefix} " "-- -i ").format(**{ 'bin': ''.join(['./',self.vf_dcf_testpmd]), @@ -374,6 +375,7 @@ class TestDcfLifeCycle(TestCase): "-c {core_mask} " "-n {mem_channel} " "{allowlist} " + "--log-level=ice,7 " "--file-prefix={prefix} " "-- -i ").format(**{ 'bin': ''.join(['./',self.vf_testpmd2]), @@ -1020,6 +1022,54 @@ class TestDcfLifeCycle(TestCase): self.preset_pmd_res() self.vf_create() + def create_acl_filter_rule(self, rules, session_name="", check_stats=True): + """ + create acl filter rules + """ + if session_name == "": + session_name = self.dut + p = re.compile(r"Flow rule #(\d+) created") + rule_list = [] + switch_rule = "Succeeded to create (2) flow" + acl_rule = "Succeeded to create (4) flow" + if isinstance(rules, list): + for rule in rules: + # create switch rule + switch_out = session_name.send_expect(rule, "testpmd> ") + self.verify(switch_rule in switch_out, 'switch rule create failed') + switch_id = p.findall(switch_out)[0] + # create acl rule + acl_out = session_name.send_expect(rule, "testpmd> ") + # destory switch rule + session_name.send_expect("flow destroy %d rule %d" % (0, switch_id), "testpmd> ") + if acl_rule in acl_out: + m = p.search(acl_out) + if m: + rule_list.append(m.group(1)) + else: + rule_list.append(False) + else: + # create switch rule + switch_out = session_name.send_expect(rules, "testpmd> ") + self.verify(switch_rule in switch_out, 'switch rule create failed') + switch_id = p.findall(switch_out)[0] + # create acl rule + acl_out = session_name.send_expect(rules, "testpmd> ") + # destory switch rule + session_name.send_expect("flow destroy %s rule %s" % (0, switch_id), "testpmd> ") + if acl_rule in acl_out: + m = p.search(acl_out) + if m: + rule_list.append(m.group(1)) + else: + rule_list.append(False) + + if check_stats: + self.verify(all(rule_list), "some rules not created successfully, result %s, rule %s" % (rule_list, rules)) + else: + self.verify(not any(rule_list), "all rules should create failed, result %s" % rule_list) + return rule_list + def destroy_resource(self): try: self.vf_destroy() @@ -1232,7 +1282,8 @@ class TestDcfLifeCycle(TestCase): def pretest_handle_acl_filter(self): # Create an ACL rule, and send packet with dst mac of VF1, then it will dropped by VF1. rule = 'flow create 0 priority 0 ingress pattern eth / ipv4 / tcp src spec 8010 src mask 65520 / end actions drop / end' - self.d_con([rule, "testpmd> ", 15]) + # acl rule + self.create_acl_filter_rule(rule, check_stats=True) self.check_rule_list() self.send_pkt_to_vf1_first(self.dmac) out = self.vf_pmd2_con(['stop', "testpmd> ", 15]) -- 2.17.1