net/hinic: fix Tx mbuf length problem

Message ID tencent_DA7A37CEC963C36D31B0E4B959B8DE535306@qq.com (mailing list archive)
State Rejected, archived
Delegated to: Thomas Monjalon
Headers
Series net/hinic: fix Tx mbuf length problem |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Junjie Lin March 7, 2022, 2:12 p.m. UTC
  From: Junjie Lin <linjunjie6@huawei.com>

The Tx mbuf needs to be ignored if the pkt_len member is zero.

Fixes: 54faba2295bd ("net/hinic:adds Tx queue xstats members")
Cc: stable@dpdk.org

Signed-off-by: Junjie Lin <linjunjie6@huawei.com>
---
 drivers/net/hinic/hinic_pmd_tx.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Stephen Hemminger March 7, 2022, 4:06 p.m. UTC | #1
On Mon,  7 Mar 2022 22:12:20 +0800
Junjie Lin <277600718@qq.com> wrote:

> From: Junjie Lin <linjunjie6@huawei.com>
> 
> The Tx mbuf needs to be ignored if the pkt_len member is zero.
> 
> Fixes: 54faba2295bd ("net/hinic:adds Tx queue xstats members")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Junjie Lin <linjunjie6@huawei.com>

Not all drivers do this. It looks like you have a buggy application
if it tries to send 0 length packets.
  
Ferruh Yigit March 8, 2022, 11:16 a.m. UTC | #2
On 3/7/2022 4:06 PM, Stephen Hemminger wrote:
> On Mon,  7 Mar 2022 22:12:20 +0800
> Junjie Lin <277600718@qq.com> wrote:
> 
>> From: Junjie Lin <linjunjie6@huawei.com>
>>
>> The Tx mbuf needs to be ignored if the pkt_len member is zero.
>>
>> Fixes: 54faba2295bd ("net/hinic:adds Tx queue xstats members")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Junjie Lin <linjunjie6@huawei.com>
> 
> Not all drivers do this. It looks like you have a buggy application
> if it tries to send 0 length packets.

Agree, not sure if invalid packet check should be done in driver level.

Junjie, in which use case you are observing this problem?
Or in the past, I remember some PMD FW was crashing for similar
case, and check was added to protect device, do you have similar
problem?
  

Patch

diff --git a/drivers/net/hinic/hinic_pmd_tx.c b/drivers/net/hinic/hinic_pmd_tx.c
index f09b1a6..99a5e3a 100644
--- a/drivers/net/hinic/hinic_pmd_tx.c
+++ b/drivers/net/hinic/hinic_pmd_tx.c
@@ -1144,6 +1144,12 @@  u16 hinic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts)
 		mbuf_pkt = *tx_pkts++;
 		queue_info = 0;
 
+		if (unlikely(mbuf_pkt->pkt_len == 0)) {
+			rte_pktmbuf_free(mbuf_pkt);
+			txq->txq_stats.off_errs++;
+			continue;
+		}
+
 		/* 1. parse sge and tx offload info from mbuf */
 		if (unlikely(!hinic_get_sge_txoff_info(mbuf_pkt,
 						       &sqe_info, &off_info))) {