From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70078.outbound.protection.outlook.com [40.107.7.78]) by dpdk.org (Postfix) with ESMTP id CFC892B92 for ; Tue, 28 Aug 2018 22:58:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nnbBax5pjPXtwBRjQw1lCLi9itkX3hoypCXit97P1gE=; b=gX8YU+RYdL16EQsAUcja+i1n63/agnpErPkfzpobqXSsWX4SmpQ/FCPhAvSm72I8pvoxpJBmLpE3gZRcLVPPxKMtJyIW6ZBvRQKM54P5uS+8wee6LW58WZjvUNUxj1tByyKx+iNIE9KaShKhiZlvzMYD7WriiwQT+JAvLNjQRYk= Received: from AM6PR08MB3672.eurprd08.prod.outlook.com (20.177.115.29) by AM6PR08MB3063.eurprd08.prod.outlook.com (52.135.163.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Tue, 28 Aug 2018 20:58:36 +0000 Received: from AM6PR08MB3672.eurprd08.prod.outlook.com ([fe80::649b:b10d:ef69:7fd2]) by AM6PR08MB3672.eurprd08.prod.outlook.com ([fe80::649b:b10d:ef69:7fd2%4]) with mapi id 15.20.1080.015; Tue, 28 Aug 2018 20:58:36 +0000 From: Honnappa Nagarahalli To: Malvika Gupta , "konstantin.ananyev@intel.com" CC: "dev@dpdk.org" , Gavin Hu , Brian Brooks , nd , Malvika Gupta , Malvika Gupta Thread-Topic: [PATCH] test/bpf: use hton instead of __builtin_bswap Thread-Index: AQHUPxBK27tA9dejKke/KxwYRnAkuKTVpObQ Date: Tue, 28 Aug 2018 20:58:35 +0000 Message-ID: References: <20180828204620.1862-1-Malvika.Gupta@arm.com> In-Reply-To: <20180828204620.1862-1-Malvika.Gupta@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; x-originating-ip: [217.140.111.135] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM6PR08MB3063; 6:81FiQjlPdUUZEyK7Gf5d+efHuqCmZUtyiahGJ8FM0FZdsjmMsTDYHVNUoSk6yUvPQjDTpOetZ2h+d05h8MAWj81pAPRy4cDR4pw0pZKotBIp+cayOQGny9MU/ZY2dXjoPREDDfpCmY5Yr6TbuZoF5Gn2PvaKJ2BqYCTqlg+eVrU5CnV9j1cBrvM7aonaGAk+VGJbewH8YpO2gSN3VE4Y9GuxeLPmCzAVqGrqVzBpHQCplT0QSq8ivWW4002bnEd7XMQ5HZnQXjxFyrH1DP93GVsE1FHPjmkiMoXIpZmN17EQ2Cs8VY4dGUpbdzwTIemcUMpmNFDgzUVHC1S4OtDI6C+eCHXRax0TkcOxeYH549pGOTRv6/gF8sE74a483mSC/rEmkX+idIcsp8voFNXFInlGIcU4MUit/wz2BuXyBVZMxCpf7ogivQoKsMWlyyRBc9BfOMvK0WOpJbaKfVEi8Q==; 5:CCRGXeNs7Myo5UqTB4TIyw1h1M//gjZlA2QNXp5l8Yrd/VD/s2NXvsUkuAHviA/uUez9EJLAh/z5IbjKK4eLj9eHpzP0kp62aHIqsrGUWWKeELiqXCVNF+uAP58U2mrhwZOFQvDfuv/QE5QQB8Ssj0jEXC+Yur1fKhb+rpOQzDI=; 7:Kr1czlbw/hTziFcfb6vRzRL7nbpibyaBHlWlf3GMEXM4rbJy4AoPCzTKjvQwhx7tGZUocu1zx7n+g0Zn71BGgMiQMc1udIMYfmUcOjjZf4oi7YUtWALtLDjg59GZSXNIUhMCMfiae9NxS870FEqAmIAU0BbM1DybZ7PVNvm+y2r1sdLpFWrZpxSzeimLZ3eKl0oHQ3AZrK079XyaFsrJfxgCsuYeo63muZUJRvD67bmTCwsqEK6d0fYPgkWRy/Bt x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-ms-office365-filtering-correlation-id: 6333e635-7b77-4585-606b-08d60d2905c2 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM6PR08MB3063; x-ms-traffictypediagnostic: AM6PR08MB3063: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(201708071742011)(7699016); SRVR:AM6PR08MB3063; BCL:0; PCL:0; RULEID:; SRVR:AM6PR08MB3063; x-forefront-prvs: 077884B8B5 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(136003)(366004)(376002)(39860400002)(396003)(189003)(199004)(13464003)(305945005)(256004)(68736007)(7696005)(97736004)(53936002)(6436002)(33656002)(2906002)(106356001)(11346002)(229853002)(6246003)(9686003)(2501003)(446003)(55016002)(105586002)(76176011)(4326008)(99286004)(476003)(5250100002)(25786009)(478600001)(81166006)(81156014)(3846002)(110136005)(54906003)(316002)(6506007)(53546011)(486006)(8936002)(14454004)(2900100001)(66066001)(8676002)(72206003)(5660300001)(86362001)(7736002)(74316002)(26005)(6116002)(102836004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR08MB3063; H:AM6PR08MB3672.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: L97M7ktlw8yn/WPqtx7ILvaKz/6/930aZuaChdqPFR3E2NkAqS3SmAbBqEqtgYmymisNmlImtzGwupwbRkIrdfRK0/FzWdUcwzrcJbpBjzGTKjWmiCubj2Ybya7KTYAv5GZqLNApR6m4L2YRoOHeLeFihKZ+ywQaeK/RWvJiOk3p/fCsoGlf2CMKXlzvmLw/KfVhGS1dAs2Fy9qEo2Drst9le+4Lq6w4kZliJQKs6yQbPblEJrcwtgkxPFHomObeNBcHmHIWL6nzSNEHRMoA5lHYPj8zIiyxqjkxfNawP/oDux0MG70rXnSzCxxQj8gxUJ+7qeXIOHJKvqXJBfaMHtO/BOExApNyy8WYp5kYStA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6333e635-7b77-4585-606b-08d60d2905c2 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Aug 2018 20:58:36.0278 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3063 Subject: Re: [dpdk-dev] [PATCH] test/bpf: use hton instead of __builtin_bswap 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: , X-List-Received-Date: Tue, 28 Aug 2018 20:58:38 -0000 -----Original Message----- From: Malvika Gupta =20 Sent: Tuesday, August 28, 2018 3:46 PM To: konstantin.ananyev@intel.com Cc: dev@dpdk.org; Gavin Hu ; Honnappa Nagarahalli ; Brian Brooks ; nd ; Malvika Gupta ; Malvika Gupta Subject: [PATCH] test/bpf: use hton instead of __builtin_bswap Convert host machine endianness to networking endianness for comparison of = incoming packets with BPF filter Signed-off-by: Malvika Gupta Reviewed-by: Gavin Hu Reviewed-by: Brian Brooks Suggested-by: Brian Brooks --- test/bpf/t1.c | 7 ++++--- test/bpf/t3.c | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/bpf/t1.c b/test/bpf/t1.c index 60f9434ab..7943fcf34 10064= 4 --- a/test/bpf/t1.c +++ b/test/bpf/t1.c @@ -28,24 +28,25 @@ #include #include #include +#include =20 uint64_t entry(void *pkt) { struct ether_header *ether_header =3D (void *)pkt; =20 - if (ether_header->ether_type !=3D __builtin_bswap16(0x0800)) + if (ether_header->ether_type !=3D htons(0x0800)) return 0; =20 struct iphdr *iphdr =3D (void *)(ether_header + 1); if (iphdr->protocol !=3D 17 || (iphdr->frag_off & 0x1ffff) !=3D 0 || - iphdr->daddr !=3D __builtin_bswap32(0x1020304)) + iphdr->daddr !=3D htonl(0x1020304)) return 0; =20 int hlen =3D iphdr->ihl * 4; struct udphdr *udphdr =3D (void *)iphdr + hlen; =20 - if (udphdr->dest !=3D __builtin_bswap16(5000)) + if (udphdr->dest !=3D htons(5000)) return 0; =20 return 1; diff --git a/test/bpf/t3.c b/test/bpf/t3.c index 531b9cb8c..24298b7c7 10064= 4 --- a/test/bpf/t3.c +++ b/test/bpf/t3.c @@ -17,6 +17,7 @@ #include #include #include "mbuf.h" +#include =20 extern void rte_pktmbuf_dump(FILE *, const struct rte_mbuf *, unsigned int= ); =20 @@ -29,7 +30,7 @@ entry(const void *pkt) mb =3D pkt; eth =3D rte_pktmbuf_mtod(mb, const struct ether_header *); =20 - if (eth->ether_type =3D=3D __builtin_bswap16(ETHERTYPE_ARP)) + if (eth->ether_type =3D=3D htons(ETHERTYPE_ARP)) rte_pktmbuf_dump(stdout, mb, 64); =20 return 1; -- 2.17.1 Compiled and tested. Acked-by: Honnappa Nagarahalli