From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9545CA2EFC for ; Mon, 14 Oct 2019 16:09:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6150E1C1C2; Mon, 14 Oct 2019 16:09:20 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 1E4FF1C11C for ; Mon, 14 Oct 2019 16:09:18 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9EDxxa1010123; Mon, 14 Oct 2019 07:09:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=pfpt0818; bh=DZW86A4U0Li4zAOVkPYikv8AwdtIsH9YmAobg6TtwqE=; b=lrQ2SfVFkWyfC6UsEC8RsU8rQHP7SR9anobbVsLDeg87PdtqSyNXFWo7UeVZmAMapkVo T3HccCVWbQwrTxLPwzLeDXWhKUE9XpJUB9S0R3pnNNqR8GcuRt5JOEbpmfHceB8AZJRw aVjzI0Ax/YKKLgSoUcS4rCIxwaTNqkPZlz1l/wQB21a1+A716lQWxobWeMMVT85hATX+ 5cZW7onW0Q4Dcux+KFb4/hNQhdSRLdCPGYBLnplzjp3z27lkAZk11S3tpjA8LhDpeKrw CdYvLbU1hO+Jzslisutzwa35QQCXEkbarw5NaxkXDZ+tabBaISiMcX0dvLl1RPsAw+6T jw== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 2vkc6r6rh7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 14 Oct 2019 07:09:17 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 14 Oct 2019 07:09:16 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.36.58) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 14 Oct 2019 07:09:16 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W07z9YCTDt9KGttVHG8Yl3MJr4DsuueDn/4v/8VX4mD2SuLyilFAe3s6bMG6hs0uAAOAh1ReSosgQKXUX2F/Pr/GAG/4rY5o83T/S/pttDvzbqpeINc46KOd2nJZCrzyTjt/aPrshsYrK1q0nf4UK5pw0Lzh2C+WO3+B3otKKM5B7XDr8F1h6gPuSpHrM/dVNfBd6NdSYzpT9aaaC38nBOtJYkxEYIbS6WK/pWLVjes/oefgg/ZFM4P4VAx2n+LwpSWVPy64jLV7ye6InHF9zdUXSxO6M4nvhYJ1sSk8NOlsJWQvEoSshW0rCeKZA3feQhiaWDxa1C5PhRGnkBZoqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DZW86A4U0Li4zAOVkPYikv8AwdtIsH9YmAobg6TtwqE=; b=NSjpf2bQjvaPY9UQEaj2YUCIvtpXxvZXj18Ig0UrmG9H+FS1UcMli4MxHDCstXx+ztDiwMclo7w8dfjcOYhc0dzY16KhK+7d8nZn3PB3FzoZzU0b1EliSZmrMh4Sh9q7mP/V6Y48caODjT5bK8Lhbu5/JqpQS/R+jzlY4+YDb04mhGoe+C60IwenK26RZzMe+jClQVXcpq91OclHcpNHcF5YhGzjlbYIAMjsuEnZlvX+ADQ9u/SHjIDPJqD71MV1dcoWv+DYKd0d7A73Gg7l6T0ExfvPSDGjrA32p/zSHqst/RHR44RdGkg3TG/hhbbZXJYMKvIbIepn//BhT+vzVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DZW86A4U0Li4zAOVkPYikv8AwdtIsH9YmAobg6TtwqE=; b=TcTTW/+30mGLxxaL7zQ8kJUZL8gWjvE/DDwcG2DYYofw36NKznDGJ98S9u6U3qC1stySEl17HNKbTVxP+VJqzlctzN/9eJRanp7sHcmQ5WqXgPiRgOjgWVVOT3yhtciftCm73PyDKevJEi74pNFZ7MPQfO7agg4u1dlV+4x/f0I= Received: from MN2PR18MB2848.namprd18.prod.outlook.com (20.179.21.149) by MN2PR18MB3312.namprd18.prod.outlook.com (10.255.237.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.19; Mon, 14 Oct 2019 14:09:14 +0000 Received: from MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::cc97:455d:adca:ef1e]) by MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::cc97:455d:adca:ef1e%4]) with mapi id 15.20.2347.023; Mon, 14 Oct 2019 14:09:13 +0000 From: Harman Kalra To: Konstantin Ananyev CC: "dev@dpdk.org" Thread-Topic: [PATCH v2] test/bpf: add new test cases Thread-Index: AQHVc44M/bLPpx4k1kqz4AaEhQCmZqdaSrqA Date: Mon, 14 Oct 2019 14:09:13 +0000 Message-ID: <20191014140855.GA94663@outlook.office365.com> References: <2601191342CEEE43887BDE71AB9772580191969C75@irsmsx105.ger.corp.intel.com> <1569408128-7408-1-git-send-email-hkalra@marvell.com> In-Reply-To: <1569408128-7408-1-git-send-email-hkalra@marvell.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PN1PR0101CA0052.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::14) To MN2PR18MB2848.namprd18.prod.outlook.com (2603:10b6:208:3e::21) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [115.113.156.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1aee0fe0-8922-4147-9138-08d750b01789 x-ms-traffictypediagnostic: MN2PR18MB3312: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1850; x-forefront-prvs: 01901B3451 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(366004)(39860400002)(346002)(136003)(396003)(199004)(189003)(229853002)(478600001)(6486002)(6246003)(486006)(476003)(6512007)(9686003)(1076003)(6506007)(25786009)(6436002)(30864003)(5660300002)(316002)(86362001)(3846002)(11346002)(446003)(2906002)(6116002)(386003)(81156014)(14454004)(6916009)(66946007)(66476007)(66446008)(66556008)(64756008)(33656002)(8936002)(8676002)(256004)(19627235002)(14444005)(55236004)(7736002)(305945005)(99286004)(76176011)(102836004)(52116002)(81166006)(26005)(186003)(4326008)(66066001)(71200400001)(71190400001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB3312; H:MN2PR18MB2848.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: LkCGS4B8GFRxwTppjO7WFhXkyjxKbWh7JId62E1m75KuSt7pcLrBe6yzN+PBt51/FZ9GT0lt6D7UqbdfIzWXKmRJeyE0dE8QoVZPxCVw+bvbiU0orJxrJdZYKKQxC3kA/vDiqTklCmvMrFB06zkmUEIJh1dq0FBOfAJ0bFOcQCBrMS+gO3BtbbpI+rmTHYn93Pb5VMsIMjJmNHo3NzOgKvfHFJjbOSIKwFmRCYE8i/fDCcSYSmzJxMmZVckhswGYd1ATN6qz2gz/UcmIj3riqG7AAPD/NEjKsDrH/Lmacw/fwI0gsgMxhSV1H1y4JhQ18/s55bART0t2c9ezU9/k8m50KD0f3NWyZtpVhtC/7wkD2NYHgwYfrN4SKfbo2bXaI1/+0kjvDQL27IbLMG/25aIFPooq3u1uY56/YketlRE= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-ID: <4C7B3D70416F6849AB04B130841C5924@namprd18.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 1aee0fe0-8922-4147-9138-08d750b01789 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Oct 2019 14:09:13.8170 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: R28Y8cHci3eJLsAK39ezlEbHzoPnWKi40zPXyObmGT7Cy32qX2imlIZ0gNYGJaYn+YFEKGPiQZl/5vo95Hzy+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB3312 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-14_08:2019-10-11,2019-10-14 signatures=0 Subject: Re: [dpdk-dev] [PATCH v2] test/bpf: add new test cases X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Ping.. On Wed, Sep 25, 2019 at 04:13:21PM +0530, Harman Kalra wrote: > This patch implements following new test cases: > - test_call4: test case to verify if stack corruption occurs > across with multiple function calls. > - test_jump2: test case with a default packet in memory, parse > the packet and check if dest ip is part of a subnet. > - test_call5: test case with string data in the stack and > calling string comaprision. >=20 > Signed-off-by: Harman Kalra > --- > V2 Changes: > * Maintaining uniformity across the code by using cmp_res rather than > individual if statements. >=20 > app/test/test_bpf.c | 619 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 619 insertions(+) >=20 > diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c > index e8841800a..ee534687a 100644 > --- a/app/test/test_bpf.c > +++ b/app/test/test_bpf.c > @@ -14,6 +14,8 @@ > #include > #include > #include > +#include > +#include > =20 > #include "test.h" > =20 > @@ -35,6 +37,12 @@ struct dummy_vect8 { > struct dummy_offset out[8]; > }; > =20 > +struct dummy_net { > + struct rte_ether_hdr eth_hdr; > + struct rte_vlan_hdr vlan_hdr; > + struct rte_ipv4_hdr ip_hdr; > +}; > + > #define TEST_FILL_1 0xDEADBEEF > =20 > #define TEST_MUL_1 21 > @@ -54,6 +62,20 @@ struct dummy_vect8 { > #define TEST_IMM_4 ((uint64_t)UINT32_MAX) > #define TEST_IMM_5 ((uint64_t)UINT32_MAX + 1) > =20 > +#define TEST_MEMFROB 0x2a2a2a2a > + > +#define STRING_GEEK 0x6B656567 > +#define STRING_WEEK 0x6B656577 > + > +#define TEST_NETMASK 0xffffff00 > +#define TEST_SUBNET 0xaca80200 > + > +uint8_t src_mac[] =3D { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF }; > +uint8_t dst_mac[] =3D { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA }; > + > +uint32_t ip_src_addr =3D (172U << 24) | (168U << 16) | (2 << 8) | 1; > +uint32_t ip_dst_addr =3D (172U << 24) | (168U << 16) | (2 << 8) | 2; > + > struct bpf_test { > const char *name; > size_t arg_sz; > @@ -866,6 +888,171 @@ test_jump1_check(uint64_t rc, const void *arg) > return cmp_res(__func__, rv, rc, &rv, &rc, sizeof(rv)); > } > =20 > +/* Jump test case - check ip4_dest in particular subnet */ > +static const struct ebpf_insn test_jump2_prog[] =3D { > + > + [0] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_K), > + .dst_reg =3D EBPF_REG_2, > + .imm =3D 0xe, > + }, > + [1] =3D { > + .code =3D (BPF_LDX | BPF_MEM | BPF_H), > + .dst_reg =3D EBPF_REG_3, > + .src_reg =3D EBPF_REG_1, > + .off =3D 12, > + }, > + [2] =3D { > + .code =3D (BPF_JMP | EBPF_JNE | BPF_K), > + .dst_reg =3D EBPF_REG_3, > + .off =3D 2, > + .imm =3D 0x81, > + }, > + [3] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_K), > + .dst_reg =3D EBPF_REG_2, > + .imm =3D 0x12, > + }, > + [4] =3D { > + .code =3D (BPF_LDX | BPF_MEM | BPF_H), > + .dst_reg =3D EBPF_REG_3, > + .src_reg =3D EBPF_REG_1, > + .off =3D 16, > + }, > + [5] =3D { > + .code =3D (EBPF_ALU64 | BPF_AND | BPF_K), > + .dst_reg =3D EBPF_REG_3, > + .imm =3D 0xffff, > + }, > + [6] =3D { > + .code =3D (BPF_JMP | EBPF_JNE | BPF_K), > + .dst_reg =3D EBPF_REG_3, > + .off =3D 9, > + .imm =3D 0x8, > + }, > + [7] =3D { > + .code =3D (EBPF_ALU64 | BPF_ADD | BPF_X), > + .dst_reg =3D EBPF_REG_1, > + .src_reg =3D EBPF_REG_2, > + }, > + [8] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_K), > + .dst_reg =3D EBPF_REG_0, > + .imm =3D 0, > + }, > + [9] =3D { > + .code =3D (BPF_LDX | BPF_MEM | BPF_W), > + .dst_reg =3D EBPF_REG_1, > + .src_reg =3D EBPF_REG_1, > + .off =3D 16, > + }, > + [10] =3D { > + .code =3D (BPF_ALU | EBPF_MOV | BPF_K), > + .dst_reg =3D EBPF_REG_3, > + .imm =3D TEST_NETMASK, > + }, > + [11] =3D { > + .code =3D (BPF_ALU | EBPF_END | EBPF_TO_BE), > + .dst_reg =3D EBPF_REG_3, > + .imm =3D sizeof(uint32_t) * CHAR_BIT, > + }, > + [12] =3D { > + .code =3D (BPF_ALU | BPF_AND | BPF_X), > + .dst_reg =3D EBPF_REG_1, > + .src_reg =3D EBPF_REG_3, > + }, > + [13] =3D { > + .code =3D (BPF_ALU | EBPF_MOV | BPF_K), > + .dst_reg =3D EBPF_REG_3, > + .imm =3D TEST_SUBNET, > + }, > + [14] =3D { > + .code =3D (BPF_ALU | EBPF_END | EBPF_TO_BE), > + .dst_reg =3D EBPF_REG_3, > + .imm =3D sizeof(uint32_t) * CHAR_BIT, > + }, > + [15] =3D { > + .code =3D (BPF_JMP | BPF_JEQ | BPF_X), > + .dst_reg =3D EBPF_REG_1, > + .src_reg =3D EBPF_REG_3, > + .off =3D 1, > + }, > + [16] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_K), > + .dst_reg =3D EBPF_REG_0, > + .imm =3D -1, > + }, > + [17] =3D { > + .code =3D (BPF_JMP | EBPF_EXIT), > + }, > +}; > + > +/* Preparing a vlan packet */ > +static void > +test_jump2_prepare(void *arg) > +{ > + struct dummy_net *dn; > + > + dn =3D arg; > + memset(dn, 0, sizeof(*dn)); > + > + /* > + * Initialize ether header. > + */ > + rte_ether_addr_copy((struct rte_ether_addr *)dst_mac, > + &dn->eth_hdr.d_addr); > + rte_ether_addr_copy((struct rte_ether_addr *)src_mac, > + &dn->eth_hdr.s_addr); > + dn->eth_hdr.ether_type =3D rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN); > + > + /* > + * Initialize vlan header. > + */ > + dn->vlan_hdr.eth_proto =3D rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); > + dn->vlan_hdr.vlan_tci =3D 32; > + > + /* > + * Initialize IP header. > + */ > + dn->ip_hdr.version_ihl =3D 0x45; /*IP_VERSION | IP_HDRLEN*/ > + dn->ip_hdr.time_to_live =3D 64; /* IP_DEFTTL */ > + dn->ip_hdr.next_proto_id =3D IPPROTO_TCP; > + dn->ip_hdr.packet_id =3D rte_cpu_to_be_16(0x463c); > + dn->ip_hdr.total_length =3D rte_cpu_to_be_16(60); > + dn->ip_hdr.src_addr =3D rte_cpu_to_be_32(ip_src_addr); > + dn->ip_hdr.dst_addr =3D rte_cpu_to_be_32(ip_dst_addr); > +} > + > +static int > +test_jump2_check(uint64_t rc, const void *arg) > +{ > + const struct rte_ether_hdr *eth_hdr =3D arg; > + const struct rte_ipv4_hdr *ipv4_hdr; > + const void *next =3D eth_hdr; > + uint16_t eth_type; > + uint64_t v =3D -1; > + > + if (eth_hdr->ether_type =3D=3D htons(0x8100)) { > + const struct rte_vlan_hdr *vlan_hdr =3D > + (const void *)(eth_hdr + 1); > + eth_type =3D vlan_hdr->eth_proto; > + next =3D vlan_hdr + 1; > + } else { > + eth_type =3D eth_hdr->ether_type; > + next =3D eth_hdr + 1; > + } > + > + if (eth_type =3D=3D htons(0x0800)) { > + ipv4_hdr =3D next; > + if ((ipv4_hdr->dst_addr & rte_cpu_to_be_32(TEST_NETMASK)) =3D=3D > + rte_cpu_to_be_32(TEST_SUBNET)) { > + v =3D 0; > + } > + } > + > + return cmp_res(__func__, v, rc, arg, arg, sizeof(arg)); > +} > + > /* alu (add, sub, and, or, xor, neg) test-cases */ > static const struct ebpf_insn test_alu1_prog[] =3D { > =20 > @@ -1889,6 +2076,388 @@ static const struct rte_bpf_xsym test_call3_xsym[= ] =3D { > }, > }; > =20 > +/* Test for stack corruption in multiple function calls */ > +static const struct ebpf_insn test_call4_prog[] =3D { > + { > + .code =3D (BPF_ST | BPF_MEM | BPF_B), > + .dst_reg =3D EBPF_REG_10, > + .off =3D -4, > + .imm =3D 1, > + }, > + { > + .code =3D (BPF_ST | BPF_MEM | BPF_B), > + .dst_reg =3D EBPF_REG_10, > + .off =3D -3, > + .imm =3D 2, > + }, > + { > + .code =3D (BPF_ST | BPF_MEM | BPF_B), > + .dst_reg =3D EBPF_REG_10, > + .off =3D -2, > + .imm =3D 3, > + }, > + { > + .code =3D (BPF_ST | BPF_MEM | BPF_B), > + .dst_reg =3D EBPF_REG_10, > + .off =3D -1, > + .imm =3D 4, > + }, > + { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_X), > + .dst_reg =3D EBPF_REG_1, > + .src_reg =3D EBPF_REG_10, > + }, > + { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_K), > + .dst_reg =3D EBPF_REG_2, > + .imm =3D 4, > + }, > + { > + .code =3D (EBPF_ALU64 | BPF_SUB | BPF_X), > + .dst_reg =3D EBPF_REG_1, > + .src_reg =3D EBPF_REG_2, > + }, > + { > + .code =3D (BPF_JMP | EBPF_CALL), > + .imm =3D 0, > + }, > + { > + .code =3D (BPF_LDX | BPF_MEM | BPF_B), > + .dst_reg =3D EBPF_REG_1, > + .src_reg =3D EBPF_REG_10, > + .off =3D -4, > + }, > + { > + .code =3D (BPF_LDX | BPF_MEM | BPF_B), > + .dst_reg =3D EBPF_REG_2, > + .src_reg =3D EBPF_REG_10, > + .off =3D -3, > + }, > + { > + .code =3D (BPF_LDX | BPF_MEM | BPF_B), > + .dst_reg =3D EBPF_REG_3, > + .src_reg =3D EBPF_REG_10, > + .off =3D -2, > + }, > + { > + .code =3D (BPF_LDX | BPF_MEM | BPF_B), > + .dst_reg =3D EBPF_REG_4, > + .src_reg =3D EBPF_REG_10, > + .off =3D -1, > + }, > + { > + .code =3D (BPF_JMP | EBPF_CALL), > + .imm =3D 1, > + }, > + { > + .code =3D (EBPF_ALU64 | BPF_XOR | BPF_K), > + .dst_reg =3D EBPF_REG_0, > + .imm =3D TEST_MEMFROB, > + }, > + { > + .code =3D (BPF_JMP | EBPF_EXIT), > + }, > +}; > + > +/* Gathering the bytes together */ > +static uint32_t > +dummy_func4_1(uint8_t a, uint8_t b, uint8_t c, uint8_t d) > +{ > + return (a << 24) | (b << 16) | (c << 8) | (d << 0); > +} > + > +/* Implementation of memfrob */ > +static uint32_t > +dummy_func4_0(uint32_t *s, uint8_t n) > +{ > + char *p =3D (char *) s; > + while (n-- > 0) > + *p++ ^=3D 42; > + return *s; > +} > + > + > +static int > +test_call4_check(uint64_t rc, const void *arg) > +{ > + uint8_t a[4] =3D {1, 2, 3, 4}; > + uint32_t s, v =3D 0; > + > + RTE_SET_USED(arg); > + > + s =3D dummy_func4_0((uint32_t *)a, 4); > + > + s =3D dummy_func4_1(a[0], a[1], a[2], a[3]); > + > + v =3D s ^ TEST_MEMFROB; > + > + return cmp_res(__func__, v, rc, &v, &rc, sizeof(v)); > +} > + > +static const struct rte_bpf_xsym test_call4_xsym[] =3D { > + [0] =3D { > + .name =3D RTE_STR(dummy_func4_0), > + .type =3D RTE_BPF_XTYPE_FUNC, > + .func =3D { > + .val =3D (void *)dummy_func4_0, > + .nb_args =3D 2, > + .args =3D { > + [0] =3D { > + .type =3D RTE_BPF_ARG_PTR, > + .size =3D 4 * sizeof(uint8_t), > + }, > + [1] =3D { > + .type =3D RTE_BPF_ARG_RAW, > + .size =3D sizeof(uint8_t), > + }, > + }, > + .ret =3D { > + .type =3D RTE_BPF_ARG_RAW, > + .size =3D sizeof(uint32_t), > + }, > + }, > + }, > + [1] =3D { > + .name =3D RTE_STR(dummy_func4_1), > + .type =3D RTE_BPF_XTYPE_FUNC, > + .func =3D { > + .val =3D (void *)dummy_func4_1, > + .nb_args =3D 4, > + .args =3D { > + [0] =3D { > + .type =3D RTE_BPF_ARG_RAW, > + .size =3D sizeof(uint8_t), > + }, > + [1] =3D { > + .type =3D RTE_BPF_ARG_RAW, > + .size =3D sizeof(uint8_t), > + }, > + [2] =3D { > + .type =3D RTE_BPF_ARG_RAW, > + .size =3D sizeof(uint8_t), > + }, > + [3] =3D { > + .type =3D RTE_BPF_ARG_RAW, > + .size =3D sizeof(uint8_t), > + }, > + }, > + .ret =3D { > + .type =3D RTE_BPF_ARG_RAW, > + .size =3D sizeof(uint32_t), > + }, > + }, > + }, > +}; > + > +/* string compare test case */ > +static const struct ebpf_insn test_call5_prog[] =3D { > + > + [0] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_K), > + .dst_reg =3D EBPF_REG_1, > + .imm =3D STRING_GEEK, > + }, > + [1] =3D { > + .code =3D (BPF_STX | BPF_MEM | BPF_W), > + .dst_reg =3D EBPF_REG_10, > + .src_reg =3D EBPF_REG_1, > + .off =3D -8, > + }, > + [2] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_K), > + .dst_reg =3D EBPF_REG_6, > + .imm =3D 0, > + }, > + [3] =3D { > + .code =3D (BPF_STX | BPF_MEM | BPF_B), > + .dst_reg =3D EBPF_REG_10, > + .src_reg =3D EBPF_REG_6, > + .off =3D -4, > + }, > + [4] =3D { > + .code =3D (BPF_STX | BPF_MEM | BPF_W), > + .dst_reg =3D EBPF_REG_10, > + .src_reg =3D EBPF_REG_6, > + .off =3D -12, > + }, > + [5] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_K), > + .dst_reg =3D EBPF_REG_1, > + .imm =3D STRING_WEEK, > + }, > + [6] =3D { > + .code =3D (BPF_STX | BPF_MEM | BPF_W), > + .dst_reg =3D EBPF_REG_10, > + .src_reg =3D EBPF_REG_1, > + .off =3D -16, > + }, > + [7] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_X), > + .dst_reg =3D EBPF_REG_1, > + .src_reg =3D EBPF_REG_10, > + }, > + [8] =3D { > + .code =3D (EBPF_ALU64 | BPF_ADD | BPF_K), > + .dst_reg =3D EBPF_REG_1, > + .imm =3D -8, > + }, > + [9] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_X), > + .dst_reg =3D EBPF_REG_2, > + .src_reg =3D EBPF_REG_1, > + }, > + [10] =3D { > + .code =3D (BPF_JMP | EBPF_CALL), > + .imm =3D 0, > + }, > + [11] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_X), > + .dst_reg =3D EBPF_REG_1, > + .src_reg =3D EBPF_REG_0, > + }, > + [12] =3D { > + .code =3D (BPF_ALU | EBPF_MOV | BPF_K), > + .dst_reg =3D EBPF_REG_0, > + .imm =3D -1, > + }, > + [13] =3D { > + .code =3D (EBPF_ALU64 | BPF_LSH | BPF_K), > + .dst_reg =3D EBPF_REG_1, > + .imm =3D 0x20, > + }, > + [14] =3D { > + .code =3D (EBPF_ALU64 | BPF_RSH | BPF_K), > + .dst_reg =3D EBPF_REG_1, > + .imm =3D 0x20, > + }, > + [15] =3D { > + .code =3D (BPF_JMP | EBPF_JNE | BPF_K), > + .dst_reg =3D EBPF_REG_1, > + .off =3D 11, > + .imm =3D 0, > + }, > + [16] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_X), > + .dst_reg =3D EBPF_REG_1, > + .src_reg =3D EBPF_REG_10, > + }, > + [17] =3D { > + .code =3D (EBPF_ALU64 | BPF_ADD | BPF_K), > + .dst_reg =3D EBPF_REG_1, > + .imm =3D -8, > + }, > + [18] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_X), > + .dst_reg =3D EBPF_REG_2, > + .src_reg =3D EBPF_REG_10, > + }, > + [19] =3D { > + .code =3D (EBPF_ALU64 | BPF_ADD | BPF_K), > + .dst_reg =3D EBPF_REG_2, > + .imm =3D -16, > + }, > + [20] =3D { > + .code =3D (BPF_JMP | EBPF_CALL), > + .imm =3D 0, > + }, > + [21] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_X), > + .dst_reg =3D EBPF_REG_1, > + .src_reg =3D EBPF_REG_0, > + }, > + [22] =3D { > + .code =3D (EBPF_ALU64 | BPF_LSH | BPF_K), > + .dst_reg =3D EBPF_REG_1, > + .imm =3D 0x20, > + }, > + [23] =3D { > + .code =3D (EBPF_ALU64 | BPF_RSH | BPF_K), > + .dst_reg =3D EBPF_REG_1, > + .imm =3D 0x20, > + }, > + [24] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_X), > + .dst_reg =3D EBPF_REG_0, > + .src_reg =3D EBPF_REG_1, > + }, > + [25] =3D { > + .code =3D (BPF_JMP | BPF_JEQ | BPF_X), > + .dst_reg =3D EBPF_REG_1, > + .src_reg =3D EBPF_REG_6, > + .off =3D 1, > + }, > + [26] =3D { > + .code =3D (EBPF_ALU64 | EBPF_MOV | BPF_K), > + .dst_reg =3D EBPF_REG_0, > + .imm =3D 0, > + }, > + [27] =3D { > + .code =3D (BPF_JMP | EBPF_EXIT), > + }, > +}; > + > +/* String comparision impelementation, return 0 if equal else difference= */ > +static uint32_t > +dummy_func5(const char *s1, const char *s2) > +{ > + while (*s1 && (*s1 =3D=3D *s2)) { > + s1++; > + s2++; > + } > + return *(const unsigned char *)s1 - *(const unsigned char *)s2; > +} > + > +static int > +test_call5_check(uint64_t rc, const void *arg) > +{ > + char a[] =3D "geek"; > + char b[] =3D "week"; > + uint32_t v; > + > + RTE_SET_USED(arg); > + > + v =3D dummy_func5(a, a); > + if (v !=3D 0) { > + v =3D -1; > + goto fail; > + } > + > + v =3D dummy_func5(a, b); > + if (v =3D=3D 0) > + goto fail; > + > + v =3D 0; > + > +fail: > + > + return cmp_res(__func__, v, rc, &v, &rc, sizeof(v)); > +} > + > +static const struct rte_bpf_xsym test_call5_xsym[] =3D { > + [0] =3D { > + .name =3D RTE_STR(dummy_func5), > + .type =3D RTE_BPF_XTYPE_FUNC, > + .func =3D { > + .val =3D (void *)dummy_func5, > + .nb_args =3D 2, > + .args =3D { > + [0] =3D { > + .type =3D RTE_BPF_ARG_PTR, > + .size =3D sizeof(char), > + }, > + [1] =3D { > + .type =3D RTE_BPF_ARG_PTR, > + .size =3D sizeof(char), > + }, > + }, > + .ret =3D { > + .type =3D RTE_BPF_ARG_RAW, > + .size =3D sizeof(uint32_t), > + }, > + }, > + }, > +}; > + > static const struct bpf_test tests[] =3D { > { > .name =3D "test_store1", > @@ -1988,6 +2557,20 @@ static const struct bpf_test tests[] =3D { > .prepare =3D test_jump1_prepare, > .check_result =3D test_jump1_check, > }, > + { > + .name =3D "test_jump2", > + .arg_sz =3D sizeof(struct dummy_net), > + .prm =3D { > + .ins =3D test_jump2_prog, > + .nb_ins =3D RTE_DIM(test_jump2_prog), > + .prog_arg =3D { > + .type =3D RTE_BPF_ARG_PTR, > + .size =3D sizeof(struct dummy_net), > + }, > + }, > + .prepare =3D test_jump2_prepare, > + .check_result =3D test_jump2_check, > + }, > { > .name =3D "test_alu1", > .arg_sz =3D sizeof(struct dummy_vect8), > @@ -2098,6 +2681,42 @@ static const struct bpf_test tests[] =3D { > /* for now don't support function calls on 32 bit platform */ > .allow_fail =3D (sizeof(uint64_t) !=3D sizeof(uintptr_t)), > }, > + { > + .name =3D "test_call4", > + .arg_sz =3D sizeof(struct dummy_offset), > + .prm =3D { > + .ins =3D test_call4_prog, > + .nb_ins =3D RTE_DIM(test_call4_prog), > + .prog_arg =3D { > + .type =3D RTE_BPF_ARG_PTR, > + .size =3D 2 * sizeof(struct dummy_offset), > + }, > + .xsym =3D test_call4_xsym, > + .nb_xsym =3D RTE_DIM(test_call4_xsym), > + }, > + .prepare =3D test_store1_prepare, > + .check_result =3D test_call4_check, > + /* for now don't support function calls on 32 bit platform */ > + .allow_fail =3D (sizeof(uint64_t) !=3D sizeof(uintptr_t)), > + }, > + { > + .name =3D "test_call5", > + .arg_sz =3D sizeof(struct dummy_offset), > + .prm =3D { > + .ins =3D test_call5_prog, > + .nb_ins =3D RTE_DIM(test_call5_prog), > + .prog_arg =3D { > + .type =3D RTE_BPF_ARG_PTR, > + .size =3D sizeof(struct dummy_offset), > + }, > + .xsym =3D test_call5_xsym, > + .nb_xsym =3D RTE_DIM(test_call5_xsym), > + }, > + .prepare =3D test_store1_prepare, > + .check_result =3D test_call5_check, > + /* for now don't support function calls on 32 bit platform */ > + .allow_fail =3D (sizeof(uint64_t) !=3D sizeof(uintptr_t)), > + }, > }; > =20 > static int > --=20 > 2.18.0 >=20