From cd1442c0ff214561b71fec501031b0c992ab8ef2 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Mon, 6 Apr 2020 09:50:20 +0000 Subject: [PATCH] Don't drop packets having too many TCP option headers in mlx5en(4). When using SACK it can happen there are multiple option headers. Don't drop these packets, but instead limit the amount of inlining to the maximum supported. MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/dev/mlx5/mlx5_en/mlx5_en_tx.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c index f3086576d0c..1b83103977d 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c @@ -613,18 +613,18 @@ top: if (likely(args.ihs == 0)) { /* nothing to inline */ - } else if (unlikely(args.ihs > sq->max_inline)) { - /* inline header size is too big */ - err = EINVAL; - goto tx_drop; } else if ((mb->m_flags & M_VLANTAG) != 0) { struct ether_vlan_header *eh = (struct ether_vlan_header *) wqe->eth.inline_hdr_start; /* Range checks */ - if (unlikely(args.ihs > (MLX5E_MAX_TX_INLINE - ETHER_VLAN_ENCAP_LEN))) - args.ihs = (MLX5E_MAX_TX_INLINE - ETHER_VLAN_ENCAP_LEN); - else if (unlikely(args.ihs < ETHER_HDR_LEN)) { + if (unlikely(args.ihs > (sq->max_inline - ETHER_VLAN_ENCAP_LEN))) { + if (mb->m_pkthdr.csum_flags & CSUM_TSO) { + err = EINVAL; + goto tx_drop; + } + args.ihs = (sq->max_inline - ETHER_VLAN_ENCAP_LEN); + } else if (unlikely(args.ihs < ETHER_HDR_LEN)) { err = EINVAL; goto tx_drop; } @@ -641,6 +641,14 @@ top: args.ihs += ETHER_VLAN_ENCAP_LEN; wqe->eth.inline_hdr_sz = cpu_to_be16(args.ihs); } else { + /* check if inline header size is too big */ + if (unlikely(args.ihs > sq->max_inline)) { + if (unlikely(mb->m_pkthdr.csum_flags & CSUM_TSO)) { + err = EINVAL; + goto tx_drop; + } + args.ihs = sq->max_inline; + } m_copydata(mb, 0, args.ihs, wqe->eth.inline_hdr_start); m_adj(mb, args.ihs); wqe->eth.inline_hdr_sz = cpu_to_be16(args.ihs);