From: Pascal Mazon Date: Wed, 15 Mar 2017 15:09:08 +0000 (+0100) Subject: net/tap: do not send packets larger than MTU X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5025409c0482e9445da42b50826a84af5274814b;p=dpdk.git net/tap: do not send packets larger than MTU Signed-off-by: Pascal Mazon Acked-by: Keith Wiles --- diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index c711b36c32..3345c1a2e2 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -305,14 +305,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)); @@ -646,6 +651,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 741ec53508..deb594c8f6 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 */ };