From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, stable@dpdk.org
Subject: [dpdk-dev] [PATCH v2 1/3] net/pcap: fix Rx with small buffers
Date: Thu, 25 Jul 2019 14:04:18 +0200 [thread overview]
Message-ID: <1564056260-18125-2-git-send-email-david.marchand@redhat.com> (raw)
In-Reply-To: <1564056260-18125-1-git-send-email-david.marchand@redhat.com>
If the pkt pool contains only buffers smaller than the default headroom,
then the driver will compute an invalid buffer size (negative value cast
to an uint16_t).
Rely on the mbuf api to check how much space is available in the mbuf.
Fixes: 6eb0ae218a98 ("pcap: fix mbuf allocation")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
drivers/net/pcap/rte_eth_pcap.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 322c18f..470867d 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -242,7 +242,6 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
struct rte_mbuf *mbuf;
struct pcap_rx_queue *pcap_q = queue;
uint16_t num_rx = 0;
- uint16_t buf_size;
uint32_t rx_bytes = 0;
pcap_t *pcap;
@@ -265,11 +264,7 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
if (unlikely(mbuf == NULL))
break;
- /* Now get the space available for data in the mbuf */
- buf_size = rte_pktmbuf_data_room_size(pcap_q->mb_pool) -
- RTE_PKTMBUF_HEADROOM;
-
- if (header.caplen <= buf_size) {
+ if (header.caplen <= rte_pktmbuf_tailroom(mbuf)) {
/* pcap packet will fit in the mbuf, can copy it */
rte_memcpy(rte_pktmbuf_mtod(mbuf, void *), packet,
header.caplen);
--
1.8.3.1
next prev parent reply other threads:[~2019-07-25 12:04 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-24 11:54 [dpdk-dev] [PATCH 0/3] Multiseg fixes for pcap pmd David Marchand
2019-07-24 11:54 ` [dpdk-dev] [PATCH 1/3] net/pcap: fix Rx with small buffers David Marchand
2019-07-24 18:28 ` Ferruh Yigit
2019-07-24 11:54 ` [dpdk-dev] [PATCH 2/3] net/pcap: fix transmit return count in error conditions David Marchand
2019-07-24 18:36 ` Ferruh Yigit
2019-07-25 7:40 ` David Marchand
2019-07-25 11:01 ` Ferruh Yigit
2019-07-24 11:54 ` [dpdk-dev] [PATCH 3/3] net/pcap: fix concurrent multiseg packet transmits David Marchand
2019-07-24 18:43 ` Ferruh Yigit
2019-07-25 8:18 ` [dpdk-dev] [dpdk-stable] " David Marchand
2019-07-25 11:07 ` Ferruh Yigit
2019-07-25 12:04 ` [dpdk-dev] [PATCH v2 0/3] Multiseg fixes for pcap pmd David Marchand
2019-07-25 12:04 ` David Marchand [this message]
2019-07-25 12:04 ` [dpdk-dev] [PATCH v2 2/3] net/pcap: fix transmit return count in error conditions David Marchand
2019-07-25 14:43 ` Ferruh Yigit
2019-07-25 12:04 ` [dpdk-dev] [PATCH v2 3/3] net/pcap: fix concurrent multiseg packet transmits David Marchand
2019-07-25 12:05 ` [dpdk-dev] [dpdk-stable] " David Marchand
2019-07-25 14:47 ` [dpdk-dev] " Ferruh Yigit
2019-07-25 19:24 ` [dpdk-dev] [PATCH v3 0/3] Multiseg fixes for pcap pmd David Marchand
2019-07-25 19:24 ` [dpdk-dev] [PATCH v3 1/3] net/pcap: fix Rx with small buffers David Marchand
2019-07-25 19:24 ` [dpdk-dev] [PATCH v3 2/3] net/pcap: fix transmit return count in error conditions David Marchand
2019-07-25 19:24 ` [dpdk-dev] [PATCH v3 3/3] net/pcap: fix concurrent multiseg packet transmits David Marchand
2019-07-25 22:36 ` [dpdk-dev] [PATCH v3 0/3] Multiseg fixes for pcap pmd Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1564056260-18125-2-git-send-email-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).