From patchwork Fri Sep 8 08:42:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Balogh X-Patchwork-Id: 811387 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.onmicrosoft.com header.i=@ericsson.onmicrosoft.com header.b="BcoTiMfC"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xpW6y672xz9rxl for ; Fri, 8 Sep 2017 18:43:05 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B6329989; Fri, 8 Sep 2017 08:43:01 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 01E212C for ; Fri, 8 Sep 2017 08:43:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sessmg23.ericsson.net (sessmg23.ericsson.net [193.180.251.45]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3C885D3 for ; Fri, 8 Sep 2017 08:42:58 +0000 (UTC) X-AuditID: c1b4fb2d-11bff700000057a4-2a-59b2581160e9 Received: from ESESSHC017.ericsson.se (Unknown_Domain [153.88.183.69]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id CE.4A.22436.11852B95; Fri, 8 Sep 2017 10:42:57 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.69) with Microsoft SMTP Server (TLS) id 14.3.352.0; Fri, 8 Sep 2017 10:42:56 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.onmicrosoft.com; s=selector1-ericsson-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/JaAR9ibW6qEVk7kQQEFiQOq3lVYe9zla33nBKMVUPU=; b=BcoTiMfCZoOtmFblyrMftKEzPFFRl2pnDqkqOz/0JXj+Vaq5BEJaoNem82rupFb+82SpJI/WC/BoW7TZ+q2Nm6dWRfgEqpwliVDqyyvV4lQZwioKB3FYh+Rg0f3qW6jcMZFVjroqWLKe5E5WVPZnsks1JVn1MIDl4X7lnwf42Cs= Received: from AM2PR07MB1042.eurprd07.prod.outlook.com (10.162.37.27) by AM2PR07MB0801.eurprd07.prod.outlook.com (10.161.71.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.4; Fri, 8 Sep 2017 08:42:55 +0000 Received: from AM2PR07MB1042.eurprd07.prod.outlook.com ([fe80::7e:2b4e:3774:4ef3]) by AM2PR07MB1042.eurprd07.prod.outlook.com ([fe80::7e:2b4e:3774:4ef3%13]) with mapi id 15.20.0035.016; Fri, 8 Sep 2017 08:42:55 +0000 From: =?iso-8859-1?q?Zolt=E1n_Balogh?= To: "'dev@openvswitch.org'" Thread-Topic: [PATCH v2] netdev-dpdk: reset packet_type for reused dp_packets Thread-Index: AdMoflc3rkong2eUT/Ok4X9eNdHLYA== Date: Fri, 8 Sep 2017 08:42:55 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [91.82.100.59] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM2PR07MB0801; 6:WWGVFBKcvpQ+WohzAqB45dsTv9c0z8FZveVhgsk1IT27tycxffCW26pi45jYpTsIBLpCVjosfgWnOECEqxwrGKEVWVH5y7fwlLzAnYsOvDk7R1hXbO9APZTnJawBljekZtQWxRRlp2OIRGf9eKUm1DCkB3i03xcCWbXA3Z6/3TUoB1Shz+d0N4ScqKaJsJzxciIyY+ci2ZFXfTPzpRYilrwns3NQCVM4chE1Kt8c05gXjaBfSAZKqHeP4eeUvDWqriuem71b9NcumiomJdXIbnIPCxjBuVegimLw3hg/D3Jc30LCjB0zUvTiDtOWVS+bmV1EmQu7HNnFbFaj+adaFg==; 5:yGktcj0i9us2DKloh1wVZvzs3wDJ8/2fGBsxegTrIh4qkZAzumNUiUi43bm7pzkxIqtqUqgMfyNkl4D8tcOYpA8AnzxDK1VXB4J4TmgcnRAM/SmSDhd5X/PSfInOGa/AXI1CVE7RVkl/4PeJuwU5gQ==; 24:2MLXzhhIDFleu2ywaYv/CZn+XBqMp8ei5UWN7MHlf3/1L2CaK7ERf7s/IKsPHd3tvhDC3rS0cJFfFREey7ymAcsaNkiU4v/ECETAICDigto=; 7:qniiDxzqq8a6S9+s9W5cKupLuOZ8DhwRtloNx/akvWJXPRdxc98YQ+jx+l/FO550X/FTP+Ao7NRfpftMIrotfwyg6WvlumsgsMl9drSIowfk72iXmLcDroH9lAmUI5mmhQgE/XJtUPvLgAuTcmWH35UZazIg0j3XdKGE7/N5PwLyw7Z7mKSUMA6YX7blNMyHEjWAN4imTzLy9SuQCmT/LjYH0o7+gSB1ISYIha9eNxI= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: c2ea0c7b-0efe-4665-6880-08d4f69599d7 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM2PR07MB0801; x-ms-traffictypediagnostic: AM2PR07MB0801: x-exchange-antispam-report-test: UriScan:(37575265505322)(228905959029699); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123562025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM2PR07MB0801; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM2PR07MB0801; x-forefront-prvs: 04244E0DC5 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(199003)(189002)(6436002)(99286003)(2900100001)(5660300001)(86362001)(53936002)(189998001)(66066001)(97736004)(55016002)(14454004)(106356001)(74316002)(110136004)(8936002)(7736002)(68736007)(105586002)(305945005)(9686003)(33656002)(2906002)(50986999)(81166006)(101416001)(81156014)(7696004)(54356999)(5250100002)(3280700002)(478600001)(3846002)(6506006)(3660700001)(25786009)(6916009)(6116002)(8676002)(102836003)(491001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM2PR07MB0801; H:AM2PR07MB1042.eurprd07.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=zoltan.balogh@ericsson.com; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Sep 2017 08:42:55.6267 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM2PR07MB0801 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA02Se0hTcRTH+d17t12Hg+tyepgGMqQ/LOejFUUlkxCFUgb9M3uQKy86nFN2 19D+CFto5cjUMtESlR5GJdZUCpLyleI035FlqdQyhorLB6K1ane/Bf33Oed8z5NDk9JflJzW G82syagzKIRiqkb7PCk6SGtPj7Vuhu17M9hBqlHK/Ic/SIOOiw9msga9hTXFJGSIs2cmHhL5 nfKCPs8IKkIOWSkKoIFRgd25KCxFYlrK9CJott+isNGP4NuiS8QbFHONBM/cdxGOVBKwtdHm l80gqHg2LOKLCZnD8P6lS8hzMBMH45UDAp63MSlgvdtCYX8qvG7t9WuU4Lze7/NTTCTMvr1I 8CxhTsLY02kfIyYENhxPfEwyofDRWU/gwRm41zFCYpaB6+tvAeYIsDcsizBvh/F6G+IHBaZE BGOTnRQOKKG9YglhToUeTx+BRV8IKBnd9HeIgtV2j7/SEagqq/Mn5MDCjR5/wqAAZtzl3ta0 1wgH11QG1qxTsDan4VnKsNDUXIzwNqegutgmxFeRw+fJq6gcRdX+txxmJUxV3RRi3gkPGhfI Wt9hgmCgxkk1IOoRknEsx+Vmxe9Wsib9WY7LMyqNrNmOvD/R1fYz+gV6vJDYjRgaKQIlKNme LhXoLFxhbjcCmlQES8bSvC5Jpq7wPGvKO206Z2C5bhRGU4pQifrVqFbKZOnMbA7L5rOmf1GC DpAXIcv8D+0Fa/LlE0YVKthVN3zUJllJXI5R3ykbtBUPbR1QKVfTd3LuHa2xzlzCOPTJEbRH r06KM69MpyXMX+rcKMqwNB2aaFm6wqY5xG0FjsDIRtlaV7wr0BKtgmp1r1sTsR6iIc/05Eeo BXvBffuYYeWdPHx/hRVG5dOz9xUUl62LiyJNnO4v+Q3sQQ8DAAA= X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_MED autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2] netdev-dpdk: reset packet_type for reused dp_packets X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org DPDK uses dp-packet pool for storing received packets. The pool is reused by rxq_recv funcions of the DPDK netdevs. The datapath is capable to modify the packet_type property of packets. For instance when encapsulated L3 packets are received on a ptap gre port. In this case the packet_type property of struct dp_packet can be modified and later the same dp_packet with the modified packet_type can be reused in the rxq_rec function, so it can contain corrupted data. The dp_packet_batch_init_cutlen() in the rxq_recv functions iterates over dp_packets and sets their cutlen. So I modified this function to set packet_type to Ethernet for the dp_packets as well. I also renamed this function because of the added functionality. The dp_packet_batch_init_cutlen() iterates over batch->count dp_packet. Therefore setting of batch->count = nb_rx needs to be done before the former function is invoked. This is an additional fix. This commit also removes initialization of packet_type from dp_packet_init__(), since that was moved to dp_packet_init_dpdk() before. Signed-off-by: Zoltan Balogh Signed-off-by: Laszlo Suru Co-authored-by: Laszlo Suru CC: Jan Scheurich CC: Sugesh Chandran CC: Darrell Ball --- lib/dp-packet.c | 2 -- lib/dp-packet.h | 3 ++- lib/netdev-dpdk.c | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/dp-packet.c b/lib/dp-packet.c index e5d16a6..21dfe39 100644 --- a/lib/dp-packet.c +++ b/lib/dp-packet.c @@ -33,8 +33,6 @@ dp_packet_init__(struct dp_packet *b, size_t allocated, enum dp_packet_source so dp_packet_rss_invalidate(b); dp_packet_mbuf_init(b); dp_packet_reset_cutlen(b); - /* By default assume the packet type to be Ethernet. */ - b->packet_type = htonl(PT_ETH); } static void diff --git a/lib/dp-packet.h b/lib/dp-packet.h index 046f3ab..b4b721c 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -805,12 +805,13 @@ dp_packet_delete_batch(struct dp_packet_batch *batch, bool may_steal) } static inline void -dp_packet_batch_init_cutlen(struct dp_packet_batch *batch) +dp_packet_batch_init_packet_fields(struct dp_packet_batch *batch) { struct dp_packet *packet; DP_PACKET_BATCH_FOR_EACH (packet, batch) { dp_packet_reset_cutlen(packet); + packet->packet_type = htonl(PT_ETH); } } diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index f58e9be..ccccb9a 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1644,8 +1644,9 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq, nb_rx, dropped); rte_spinlock_unlock(&dev->stats_lock); - dp_packet_batch_init_cutlen(batch); - batch->count = (int) nb_rx; + batch->count = nb_rx; + dp_packet_batch_init_packet_fields(batch); + return 0; } @@ -1684,8 +1685,8 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct dp_packet_batch *batch) rte_spinlock_unlock(&dev->stats_lock); } - dp_packet_batch_init_cutlen(batch); batch->count = nb_rx; + dp_packet_batch_init_packet_fields(batch); return 0; }