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 1740A45AA4; Fri, 4 Oct 2024 00:10:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E5CD840273; Fri, 4 Oct 2024 00:10:56 +0200 (CEST) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mails.dpdk.org (Postfix) with ESMTP id 310FA4021F for ; Fri, 4 Oct 2024 00:10:55 +0200 (CEST) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-20b93887decso12557725ad.3 for ; Thu, 03 Oct 2024 15:10:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727993454; x=1728598254; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eQdKGJ2r+4kxSqeELDNjZGZogaAX9OsPw77UI6EjM7I=; b=xtTrBCrnqhVJaYd/7bG6nCM47rEXXDd9UXCx4PZbr7OH+xiHNOhADRxujvrlD2ZRn7 9GA5pRrluPJwpQac9Z2aO9wK3I4i+hTeJN+Hjq3ucscnjYC31ElP+FtUnSvPHTtDGqh0 bHfPMLaJ/7WySGa+SFOwes/pgvTZ8vykmP89U0n4jzyDZKHLL9X4D37OFWxvVBqD6vc7 kMYOZeF4P7uTavKH5aeEzAMoCRD9A2DogLYwfBxEoCb6/LstjHXxzaPXpf9W64L9XBkj uytP/OqXR0f6o+uPqtZYC3rRuk5Oz4hT729kEH+CHvT3A4ssl7swSgHoxpDp0pgi65EP uadw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727993454; x=1728598254; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eQdKGJ2r+4kxSqeELDNjZGZogaAX9OsPw77UI6EjM7I=; b=Men8+f+p/IvXFDQEBwto9CP0cqc3gCSv26aSGAnCMK9qLjlIXyIwmaXycUTGqceDbt cUw4VctIIP/pkB5stIu1/rBojueEwzhWgYxQ1wRsD/6jmTZg8+WK1AL2dk06nHr19pE0 2/AkxQKCuOL3B3YDxApMM9/ABqmK3dtesJAgsUg5gjnZncIevGDx8YXrlzefKt5mBAbS wKvP5HC32YLoTJoSTvuspSEA21b88MvDzFZ4IUQ0MwNpnEGFmkDxJDPUnd24pYytgh2T 6FyPYzrsLdisGxInW9DJg/hfgJz+d29llY6UOinFj4TotSXSECUTjmylRVFoJPYUvQBw VUuA== X-Gm-Message-State: AOJu0YwKAM2E3PTWfZ07PjE8h8DUC+bw4iaPWOsYAabGohvsuEU76ojk EuKW11L1pJWfORJN6OU6RXjIZVYASdv9c3yySPdSpV9I+1neXfxvSer6bAJMdHDVcADe5jfnHhV j X-Google-Smtp-Source: AGHT+IEY49pgt+GWHYTkAAnwEBsn5hLIzViJDRHHmrOC35FytvUesRf9ochnVLADErH8OQnL+AhknQ== X-Received: by 2002:a17:903:244d:b0:20b:49d6:7c74 with SMTP id d9443c01a7336-20bfe023decmr8706285ad.11.1727993454287; Thu, 03 Oct 2024 15:10:54 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20beead252esm13628705ad.43.2024.10.03.15.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2024 15:10:53 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tianli Lai Subject: [PATCH] app/dumpcap: fix handling of jumbo frames Date: Thu, 3 Oct 2024 15:09:03 -0700 Message-ID: <20241003221051.34924-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240301104129.3725-1-laitianli@tom.com> References: <20240301104129.3725-1-laitianli@tom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 If dumpcap (in legacy pcap mode) tried to handle a large segmented frame it would core dump because rte_pktmbuf_read() would return NULL. Fix by using same logic as in pcap PMD. Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application") Reported-by: Tianli Lai Signed-off-by: Stephen Hemminger --- app/dumpcap/main.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c index 6feb8f5672..fcfaa19951 100644 --- a/app/dumpcap/main.c +++ b/app/dumpcap/main.c @@ -902,7 +902,7 @@ static ssize_t pcap_write_packets(pcap_dumper_t *dumper, struct rte_mbuf *pkts[], uint16_t n) { - uint8_t temp_data[RTE_MBUF_DEFAULT_BUF_SIZE]; + uint8_t temp_data[RTE_ETHER_MAX_JUMBO_FRAME_LEN]; struct pcap_pkthdr header; uint16_t i; size_t total = 0; @@ -911,14 +911,19 @@ pcap_write_packets(pcap_dumper_t *dumper, for (i = 0; i < n; i++) { struct rte_mbuf *m = pkts[i]; + size_t len, caplen; - header.len = rte_pktmbuf_pkt_len(m); - header.caplen = RTE_MIN(header.len, sizeof(temp_data)); + len = caplen = rte_pktmbuf_pkt_len(m); + if (unlikely(!rte_pktmbuf_is_contiguous(m) && len > sizeof(temp_data))) + caplen = sizeof(temp_data); + + header.len = len; + header.caplen = caplen; pcap_dump((u_char *)dumper, &header, - rte_pktmbuf_read(m, 0, header.caplen, temp_data)); + rte_pktmbuf_read(m, 0, caplen, temp_data)); - total += sizeof(header) + header.len; + total += sizeof(header) + caplen; } return total; -- 2.45.2