Commit 6aace17e authored by Moshe Shemesh's avatar Moshe Shemesh Committed by Saeed Mahameed

net/mlx5e: Fix inline header size for small packets

Fix inline header size, make sure it is not greater than skb len.
This bug effects small packets, for example L2 packets with size < 18.

Fixes: ae76715d ("net/mlx5e: Check the minimum inline header mode before xmit")
Signed-off-by: default avatarMoshe Shemesh <moshe@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 19122039
...@@ -128,10 +128,10 @@ static inline int mlx5e_skb_l3_header_offset(struct sk_buff *skb) ...@@ -128,10 +128,10 @@ static inline int mlx5e_skb_l3_header_offset(struct sk_buff *skb)
return mlx5e_skb_l2_header_offset(skb); return mlx5e_skb_l2_header_offset(skb);
} }
static inline unsigned int mlx5e_calc_min_inline(enum mlx5_inline_modes mode, static inline u16 mlx5e_calc_min_inline(enum mlx5_inline_modes mode,
struct sk_buff *skb) struct sk_buff *skb)
{ {
int hlen; u16 hlen;
switch (mode) { switch (mode) {
case MLX5_INLINE_MODE_NONE: case MLX5_INLINE_MODE_NONE:
...@@ -140,19 +140,22 @@ static inline unsigned int mlx5e_calc_min_inline(enum mlx5_inline_modes mode, ...@@ -140,19 +140,22 @@ static inline unsigned int mlx5e_calc_min_inline(enum mlx5_inline_modes mode,
hlen = eth_get_headlen(skb->data, skb_headlen(skb)); hlen = eth_get_headlen(skb->data, skb_headlen(skb));
if (hlen == ETH_HLEN && !skb_vlan_tag_present(skb)) if (hlen == ETH_HLEN && !skb_vlan_tag_present(skb))
hlen += VLAN_HLEN; hlen += VLAN_HLEN;
return hlen; break;
case MLX5_INLINE_MODE_IP: case MLX5_INLINE_MODE_IP:
/* When transport header is set to zero, it means no transport /* When transport header is set to zero, it means no transport
* header. When transport header is set to 0xff's, it means * header. When transport header is set to 0xff's, it means
* transport header wasn't set. * transport header wasn't set.
*/ */
if (skb_transport_offset(skb)) if (skb_transport_offset(skb)) {
return mlx5e_skb_l3_header_offset(skb); hlen = mlx5e_skb_l3_header_offset(skb);
break;
}
/* fall through */ /* fall through */
case MLX5_INLINE_MODE_L2: case MLX5_INLINE_MODE_L2:
default: default:
return mlx5e_skb_l2_header_offset(skb); hlen = mlx5e_skb_l2_header_offset(skb);
} }
return min_t(u16, hlen, skb->len);
} }
static inline void mlx5e_tx_skb_pull_inline(unsigned char **skb_data, static inline void mlx5e_tx_skb_pull_inline(unsigned char **skb_data,
......
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