From 6fe9e470bbc5fd1e2b93e2734b19c9d137a617ea Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 11 Jun 2020 09:41:54 +0000 Subject: [PATCH] Make sure packets generated by raw IP code is let through by mlx5en(4). Allow the TCP header to reside in the mbuf following the IP header. Else such packets will get dropped. Backtrace: mlx5e_sq_xmit() mlx5e_xmit() ether_output_frame() ether_output() ip_output_send() ip_output() rip_output() sosend_generic() sosend() kern_sendit() sendit() sys_sendto() amd64_syscall() fast_syscall_common() MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/dev/mlx5/mlx5_en/mlx5_en_tx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c index 2663e42bbc02..c1a0ea512c65 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c @@ -307,9 +307,15 @@ mlx5e_get_full_header_size(const struct mbuf *mb, const struct tcphdr **ppth) goto failure; } tcp_packet: - if (unlikely(mb->m_len < eth_hdr_len + sizeof(*th))) - goto failure; - th = (const struct tcphdr *)(mb->m_data + eth_hdr_len); + if (unlikely(mb->m_len < eth_hdr_len + sizeof(*th))) { + const struct mbuf *m_th = mb->m_next; + if (unlikely(mb->m_len != eth_hdr_len || + m_th == NULL || m_th->m_len < sizeof(*th))) + goto failure; + th = (const struct tcphdr *)(m_th->m_data); + } else { + th = (const struct tcphdr *)(mb->m_data + eth_hdr_len); + } tcp_hlen = th->th_off << 2; eth_hdr_len += tcp_hlen; udp_packet: