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 6466D436A9; Fri, 8 Dec 2023 13:42:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3A3DD402BF; Fri, 8 Dec 2023 13:42:44 +0100 (CET) Received: from m126.mail.126.com (m126.mail.126.com [220.181.12.36]) by mails.dpdk.org (Postfix) with ESMTP id 5A46D4029E for ; Fri, 8 Dec 2023 13:42:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=AHgkG rAWjKpxc6aHnTN5vO5WwVCzOmDSCdfL1mUUG5o=; b=kxf6WWIsGorMyKvaDrw91 1xZ6QxjOzfWkNgIVxa+gdWbtIm2pVMAQoJyL17rS/WA9+QtlaVUxulZkxJ6qTr0U opRtTw8L+R2kCdF513NwXfSExMdYSjoepoOEM9wQLEN5vIaOFI0GeXuYyyUvHisq L6/HDduTD94XpntXXeZlHA= Received: from R750-427Server16.. (unknown [58.213.8.49]) by zwqz-smtp-mta-g4-1 (Coremail) with SMTP id _____wDHz+E7D3NlEe9fDg--.59065S2; Fri, 08 Dec 2023 20:42:38 +0800 (CST) From: Qian Hao To: dev@dpdk.org Cc: Volodymyr Fialko Subject: [PATCH] examples/packet_ordering: fix segfault in disable_reorder mode Date: Fri, 8 Dec 2023 20:42:31 +0800 Message-Id: <20231208124231.198138-1-qi_an_hao@126.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wDHz+E7D3NlEe9fDg--.59065S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7KF4xZFy8Zr48Cw45try8uFg_yoW8WryfpF nxK34Iyr48ZryrKrZ7Ja47Xr15WFW5XF1xuryfZ3WYkw4UXa4SvrW0qF15uFW8AFykJw17 Zr4YgryqvFyqkF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07Upq2_UUUUU= X-Originating-IP: [58.213.8.49] X-CM-SenderInfo: ptlbt0pbkd0qqrswhudrp/1tbi4wBAGVpEFAbokQAAsP X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org packet_ordering example works in two modes (--disable-reorder): - When reorder is enabled: rx_thread - N*worker_thread - send_thread - When reorder is disabled: rx_thread - N*worker_thread - tx_thread N parallel worker_thread(s) generate out-of-order packets. When reorder is enabled, send_thread uses sequence number generated in rx_thread (Line 459) to enforce packet ordering. Otherwise rx_thread just sends any packet it receives. rx_thread writes sequence number into a dynamic field, which is only registered by calling rte_reorder_create() (Line 741) when reorder is enabled. However, rx_thread marks sequence number onto each packet no matter whether reorder is enabled, overwriting the leading bytes in packet mbufs when reorder is disabled, resulting in segfaults when PMD tries to DMA packets. if (!disable_reorder) {...} is added to fix the bug. --- examples/packet_ordering/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c index d2fd6f77e4..7688f541ba 100644 --- a/examples/packet_ordering/main.c +++ b/examples/packet_ordering/main.c @@ -455,8 +455,11 @@ rx_thread(struct rte_ring *ring_out) app_stats.rx.rx_pkts += nb_rx_pkts; /* mark sequence number */ - for (i = 0; i < nb_rx_pkts; ) - *rte_reorder_seqn(pkts[i++]) = seqn++; + if (!disable_reorder) { + for (i = 0; i < nb_rx_pkts;) { + *rte_reorder_seqn(pkts[i++]) = seqn++; + } + } /* enqueue to rx_to_workers ring */ ret = rte_ring_enqueue_burst(ring_out, -- 2.34.1