Skip to content

Commit bcaf109

Browse files
cjubranSaeed Mahameed
authored andcommitted
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: 39a1665 ("net/mlx5e: Implement sending multi buffer XDP frames") Signed-off-by: Carolina Jubran <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent be86106 commit bcaf109

File tree

1 file changed

+3
-1
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en

1 file changed

+3
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xmit_data *xdptxd,
493493
dma_addr_t dma_addr = xdptxd->dma_addr;
494494
u32 dma_len = xdptxd->len;
495495
u16 ds_cnt, inline_hdr_sz;
496+
unsigned int frags_size;
496497
u8 num_wqebbs = 1;
497498
int num_frags = 0;
498499
bool inline_ok;
@@ -503,8 +504,9 @@ mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xmit_data *xdptxd,
503504

504505
inline_ok = sq->min_inline_mode == MLX5_INLINE_MODE_NONE ||
505506
dma_len >= MLX5E_XDP_MIN_INLINE;
507+
frags_size = xdptxd->has_frags ? xdptxdf->sinfo->xdp_frags_size : 0;
506508

507-
if (unlikely(!inline_ok || sq->hw_mtu < dma_len)) {
509+
if (unlikely(!inline_ok || sq->hw_mtu < dma_len + frags_size)) {
508510
stats->err++;
509511
return false;
510512
}

0 commit comments

Comments
 (0)