Commit bcaf109f authored by Carolina Jubran's avatar Carolina Jubran Committed by Saeed Mahameed

net/mlx5e: XDP, Drop fragmented packets larger than MTU size

XDP transmits fragmented packets that are larger than MTU size instead of
dropping those packets. The drop check that checks whether a packet is larger
than MTU is comparing MTU size against the linear part length only.

Adjust the drop check to compare MTU size against both linear and non-linear
part lengths to avoid transmitting fragmented packets larger than MTU size.

Fixes: 39a1665d ("net/mlx5e: Implement sending multi buffer XDP frames")
Signed-off-by: default avatarCarolina Jubran <cjubran@nvidia.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent be86106f
...@@ -493,6 +493,7 @@ mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xmit_data *xdptxd, ...@@ -493,6 +493,7 @@ mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xmit_data *xdptxd,
dma_addr_t dma_addr = xdptxd->dma_addr; dma_addr_t dma_addr = xdptxd->dma_addr;
u32 dma_len = xdptxd->len; u32 dma_len = xdptxd->len;
u16 ds_cnt, inline_hdr_sz; u16 ds_cnt, inline_hdr_sz;
unsigned int frags_size;
u8 num_wqebbs = 1; u8 num_wqebbs = 1;
int num_frags = 0; int num_frags = 0;
bool inline_ok; bool inline_ok;
...@@ -503,8 +504,9 @@ mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xmit_data *xdptxd, ...@@ -503,8 +504,9 @@ mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xmit_data *xdptxd,
inline_ok = sq->min_inline_mode == MLX5_INLINE_MODE_NONE || inline_ok = sq->min_inline_mode == MLX5_INLINE_MODE_NONE ||
dma_len >= MLX5E_XDP_MIN_INLINE; dma_len >= MLX5E_XDP_MIN_INLINE;
frags_size = xdptxd->has_frags ? xdptxdf->sinfo->xdp_frags_size : 0;
if (unlikely(!inline_ok || sq->hw_mtu < dma_len)) { if (unlikely(!inline_ok || sq->hw_mtu < dma_len + frags_size)) {
stats->err++; stats->err++;
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment