* [dpdk-dev] [PATCH] app/testpmd: fix eth packet dump for small buffers
@ 2019-07-24 10:58 David Marchand
2019-07-24 15:00 ` Iremonger, Bernard
0 siblings, 1 reply; 3+ messages in thread
From: David Marchand @ 2019-07-24 10:58 UTC (permalink / raw)
To: dev; +Cc: olivier.matz, stable, Wenzhuo Lu, Jingjing Wu, Bernard Iremonger
In the rather unlikely case where the first segment is too small to
contain an ethernet header, we can't go and directly dereference the
mbuf data buffer.
Using rte_pktmbuf_read is a little more expensive but this is still
acceptable for a debugging feature.
Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
app/test-pmd/util.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index a1164b7..18dfdca 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -14,7 +14,7 @@
#include "testpmd.h"
static inline void
-print_ether_addr(const char *what, struct rte_ether_addr *eth_addr)
+print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr)
{
char buf[RTE_ETHER_ADDR_FMT_SIZE];
rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, eth_addr);
@@ -26,7 +26,8 @@
uint16_t nb_pkts, int is_rx)
{
struct rte_mbuf *mb;
- struct rte_ether_hdr *eth_hdr;
+ const struct rte_ether_hdr *eth_hdr;
+ struct rte_ether_hdr _eth_hdr;
uint16_t eth_type;
uint64_t ol_flags;
uint16_t i, packet_type;
@@ -46,7 +47,7 @@
(unsigned int) nb_pkts);
for (i = 0; i < nb_pkts; i++) {
mb = pkts[i];
- eth_hdr = rte_pktmbuf_mtod(mb, struct rte_ether_hdr *);
+ eth_hdr = rte_pktmbuf_read(mb, 0, sizeof(_eth_hdr), &_eth_hdr);
eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
ol_flags = mb->ol_flags;
packet_type = mb->packet_type;
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] app/testpmd: fix eth packet dump for small buffers
2019-07-24 10:58 [dpdk-dev] [PATCH] app/testpmd: fix eth packet dump for small buffers David Marchand
@ 2019-07-24 15:00 ` Iremonger, Bernard
2019-07-29 21:37 ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Iremonger, Bernard @ 2019-07-24 15:00 UTC (permalink / raw)
To: David Marchand, dev; +Cc: olivier.matz, stable, Lu, Wenzhuo, Wu, Jingjing
> -----Original Message-----
> From: David Marchand [mailto:david.marchand@redhat.com]
> Sent: Wednesday, July 24, 2019 11:59 AM
> To: dev@dpdk.org
> Cc: olivier.matz@6wind.com; stable@dpdk.org; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Iremonger,
> Bernard <bernard.iremonger@intel.com>
> Subject: [PATCH] app/testpmd: fix eth packet dump for small buffers
>
> In the rather unlikely case where the first segment is too small to contain an
> ethernet header, we can't go and directly dereference the mbuf data buffer.
>
> Using rte_pktmbuf_read is a little more expensive but this is still acceptable
> for a debugging feature.
>
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH] app/testpmd: fix eth packet dump for small buffers
2019-07-24 15:00 ` Iremonger, Bernard
@ 2019-07-29 21:37 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2019-07-29 21:37 UTC (permalink / raw)
To: David Marchand
Cc: stable, Iremonger, Bernard, dev, olivier.matz, Lu, Wenzhuo, Wu, Jingjing
> > In the rather unlikely case where the first segment is too small to contain an
> > ethernet header, we can't go and directly dereference the mbuf data buffer.
> >
> > Using rte_pktmbuf_read is a little more expensive but this is still acceptable
> > for a debugging feature.
> >
> > Fixes: af75078fece3 ("first public release")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
>
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-29 21:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-24 10:58 [dpdk-dev] [PATCH] app/testpmd: fix eth packet dump for small buffers David Marchand
2019-07-24 15:00 ` Iremonger, Bernard
2019-07-29 21:37 ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
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).