DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [memnic PATCH 2/5] pmd: check frame length from host
@ 2014-03-11  5:38 Hiroshi Shimamoto
  2014-03-21 18:00 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Hiroshi Shimamoto @ 2014-03-11  5:38 UTC (permalink / raw)
  To: dev; +Cc: Hayato Momma

From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>

Drop packets which have invalid length.

Normally this must not happen while vSwitch works fine, however
it's better to put a sentinel to prevent memory corruption.

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Reviewed-by: Hayato Momma <h-momma@ce.jp.nec.com>
---
 pmd/pmd_memnic.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/pmd/pmd_memnic.c b/pmd/pmd_memnic.c
index 805f0b2..bf5fc2e 100644
--- a/pmd/pmd_memnic.c
+++ b/pmd/pmd_memnic.c
@@ -226,6 +226,8 @@ static uint16_t memnic_recv_pkts(void *rx_queue,
 		p = &data->packets[idx];
 		if (p->status != MEMNIC_PKT_ST_FILLED)
 			break;
+		if (p->len > MEMNIC_MAX_FRAME_LEN)
+			goto drop;
 		mb = rte_pktmbuf_alloc(adapter->mp);
 		if (!mb)
 			break;
@@ -238,6 +240,7 @@ static uint16_t memnic_recv_pkts(void *rx_queue,
 		mb->pkt.data_len = p->len;
 		rx_pkts[nr] = mb;
 
+drop:
 		rte_mb();
 		p->status = MEMNIC_PKT_ST_FREE;
 
-- 
1.8.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [memnic PATCH 2/5] pmd: check frame length from host
  2014-03-11  5:38 [dpdk-dev] [memnic PATCH 2/5] pmd: check frame length from host Hiroshi Shimamoto
@ 2014-03-21 18:00 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2014-03-21 18:00 UTC (permalink / raw)
  To: Hiroshi Shimamoto; +Cc: dev, Hayato Momma

11/03/2014 05:38, Hiroshi Shimamoto:
> Drop packets which have invalid length.
> 
> Normally this must not happen while vSwitch works fine, however
> it's better to put a sentinel to prevent memory corruption.
> 
> Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
> Reviewed-by: Hayato Momma <h-momma@ce.jp.nec.com>

Acked and applied with title
	"pmd: check received frame length"

Thank you
-- 
Thomas

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-21 18:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-11  5:38 [dpdk-dev] [memnic PATCH 2/5] pmd: check frame length from host Hiroshi Shimamoto
2014-03-21 18:00 ` 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).