Skip to content

Commit 83fea49

Browse files
gal-pressmandavem330
authored andcommitted
net/mlx5e: Fix UDP GSO for encapsulated packets
When the skb is encapsulated, adjust the inner UDP header instead of the outer one, and account for UDP header (instead of TCP) in the inline header size calculation. Fixes: 689adf0 ("net/mlx5e: Add UDP GSO support") Reported-by: Jason Baron <[email protected]> Closes: https://lore.kernel.org/netdev/[email protected]/ Signed-off-by: Gal Pressman <[email protected]> Reviewed-by: Dragos Tatulea <[email protected]> Reviewed-by: Boris Pismenny <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5c74195 commit 83fea49

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,14 @@ static inline void
102102
mlx5e_udp_gso_handle_tx_skb(struct sk_buff *skb)
103103
{
104104
int payload_len = skb_shinfo(skb)->gso_size + sizeof(struct udphdr);
105+
struct udphdr *udphdr;
105106

106-
udp_hdr(skb)->len = htons(payload_len);
107+
if (skb->encapsulation)
108+
udphdr = (struct udphdr *)skb_inner_transport_header(skb);
109+
else
110+
udphdr = udp_hdr(skb);
111+
112+
udphdr->len = htons(payload_len);
107113
}
108114

109115
struct mlx5e_accel_tx_state {

drivers/net/ethernet/mellanox/mlx5/core/en_tx.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ mlx5e_tx_get_gso_ihs(struct mlx5e_txqsq *sq, struct sk_buff *skb, int *hopbyhop)
153153

154154
*hopbyhop = 0;
155155
if (skb->encapsulation) {
156-
ihs = skb_inner_tcp_all_headers(skb);
156+
if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
157+
ihs = skb_inner_transport_offset(skb) +
158+
sizeof(struct udphdr);
159+
else
160+
ihs = skb_inner_tcp_all_headers(skb);
157161
stats->tso_inner_packets++;
158162
stats->tso_inner_bytes += skb->len - ihs;
159163
} else {

0 commit comments

Comments
 (0)