net/ixgbe: check for illegal Tx packets
authorXiao Zhang <xiao.zhang@intel.com>
Mon, 17 Feb 2020 14:51:15 +0000 (22:51 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 19 Feb 2020 12:51:06 +0000 (13:51 +0100)
For ixgbe, there is restriction that data buffers of any transmitted
packet must include at least 12 bytes of the src/dst Ethernet MAC
addresses as well as 2 bytes of the Type/Len field, otherwise, tx hang
would happen.

This patch adds check for those illegal packets and protects TX from
hanging.

Fixes: 7829b8d52be0 ("net/ixgbe: add Tx preparation")
Cc: stable@dpdk.org
Signed-off-by: Xiao Zhang <xiao.zhang@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>
drivers/net/ixgbe/ixgbe_rxtx.c
drivers/net/ixgbe/ixgbe_rxtx.h

index 7b398f1..f839bca 100644 (file)
@@ -986,6 +986,12 @@ ixgbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
                        return i;
                }
 
+               /* check the size of packet */
+               if (m->pkt_len < IXGBE_TX_MIN_PKT_LEN) {
+                       rte_errno = EINVAL;
+                       return i;
+               }
+
 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
                ret = rte_validate_tx_offload(m);
                if (ret != 0) {
index 000c5b1..20a8b29 100644 (file)
@@ -53,6 +53,8 @@
 
 #define IXGBE_TX_MAX_SEG                    40
 
+#define IXGBE_TX_MIN_PKT_LEN                14
+
 #define IXGBE_PACKET_TYPE_MASK_82599        0X7F
 #define IXGBE_PACKET_TYPE_MASK_X550         0X10FF
 #define IXGBE_PACKET_TYPE_MASK_TUNNEL       0XFF