DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/tap: do not send packets larger than MTU
@ 2017-03-15 15:09 Pascal Mazon
  2017-03-15 21:48 ` Wiles, Keith
  0 siblings, 1 reply; 3+ messages in thread
From: Pascal Mazon @ 2017-03-15 15:09 UTC (permalink / raw)
  To: keith.wiles; +Cc: dev, Pascal Mazon

Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
---
 drivers/net/tap/rte_eth_tap.c | 6 ++++++
 drivers/net/tap/rte_eth_tap.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 69fa282ca176..17496501e6ba 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -340,14 +340,19 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	struct tx_queue *txq = queue;
 	uint16_t num_tx = 0;
 	unsigned long num_tx_bytes = 0;
+	uint32_t max_size;
 	int i, n;
 
 	if (unlikely(nb_pkts == 0))
 		return 0;
 
+	max_size = *txq->mtu + (ETHER_HDR_LEN + ETHER_CRC_LEN + 4);
 	for (i = 0; i < nb_pkts; i++) {
 		/* copy the tx frame data */
 		mbuf = bufs[num_tx];
+		/* stats.errs will be incremented */
+		if (rte_pktmbuf_pkt_len(mbuf) > max_size)
+			break;
 		n = write(txq->fd,
 			  rte_pktmbuf_mtod(mbuf, void *),
 			  rte_pktmbuf_pkt_len(mbuf));
@@ -707,6 +712,7 @@ tap_setup_queue(struct rte_eth_dev *dev,
 
 	rx->fd = fd;
 	tx->fd = fd;
+	tx->mtu = &dev->data->mtu;
 
 	return fd;
 }
diff --git a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h
index 1ad6ad88796a..9546411bd790 100644
--- a/drivers/net/tap/rte_eth_tap.h
+++ b/drivers/net/tap/rte_eth_tap.h
@@ -60,6 +60,7 @@ struct rx_queue {
 
 struct tx_queue {
 	int fd;
+	uint16_t *mtu;                  /* Pointer to MTU from dev_data */
 	struct pkt_stats stats;         /* Stats for this TX queue */
 };
 
-- 
2.8.0.rc0

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

* Re: [dpdk-dev] [PATCH] net/tap: do not send packets larger than MTU
  2017-03-15 15:09 [dpdk-dev] [PATCH] net/tap: do not send packets larger than MTU Pascal Mazon
@ 2017-03-15 21:48 ` Wiles, Keith
  2017-03-24 15:29   ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Wiles, Keith @ 2017-03-15 21:48 UTC (permalink / raw)
  To: Pascal Mazon; +Cc: dev


> On Mar 15, 2017, at 11:09 PM, Pascal Mazon <pascal.mazon@6wind.com> wrote:
> 
> Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>

Acked-by: Keith Wiles <keith.wiles#intel.com>
> ---
> drivers/net/tap/rte_eth_tap.c | 6 ++++++
> drivers/net/tap/rte_eth_tap.h | 1 +
> 2 files changed, 7 insertions(+)

Regards,
Keith

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

* Re: [dpdk-dev] [PATCH] net/tap: do not send packets larger than MTU
  2017-03-15 21:48 ` Wiles, Keith
@ 2017-03-24 15:29   ` Ferruh Yigit
  0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2017-03-24 15:29 UTC (permalink / raw)
  To: Wiles, Keith, Pascal Mazon; +Cc: dev

On 3/15/2017 9:48 PM, Wiles, Keith wrote:
> 
>> On Mar 15, 2017, at 11:09 PM, Pascal Mazon <pascal.mazon@6wind.com> wrote:
>>
>> Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
> 
> Acked-by: Keith Wiles <keith.wiles#intel.com>

Applied to dpdk-next-net/master, thanks.

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

end of thread, other threads:[~2017-03-24 15:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-15 15:09 [dpdk-dev] [PATCH] net/tap: do not send packets larger than MTU Pascal Mazon
2017-03-15 21:48 ` Wiles, Keith
2017-03-24 15:29   ` Ferruh Yigit

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).