Skip to contentSkip to conversation

mlx5: fix get_ip_proto()

PATCH Applied Cong Wang 4 participants 4 messages Nov 29, 2018 – Dec 1, 2018

Subsystems (4)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 mlx5: fix get_ip_proto()

IP header is not necessarily located right after struct ethhdr, there could be multiple 802.1Q headers in between, this is why we call __vlan_get_protocol().

Fixes fe1dc069990c ("net/mlx5e: don't set CHECKSUM_COMPLETE on SCTP packets")
Cc Alaa Hleihel <[email protected]>
Cc Or Gerlitz <[email protected]>
Cc Saeed Mahameed <[email protected]>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +3 -3
index 9b6bd2b51556..f7c5dbb0ffcd 100644
@@ -724,9 +724,9 @@ static u32 mlx5e_get_fcs(const struct sk_buff *skb)
 	return __get_unaligned_cpu32(fcs_bytes);
 }
 
-static u8 get_ip_proto(struct sk_buff *skb, __be16 proto)
+static u8 get_ip_proto(struct sk_buff *skb, int network_depth, __be16 proto)
 {
-	void *ip_p = skb->data + sizeof(struct ethhdr);
+	void *ip_p = skb->data + network_depth;
 
 	return (proto == htons(ETH_P_IP)) ? ((struct iphdr *)ip_p)->protocol :
 					    ((struct ipv6hdr *)ip_p)->nexthdr;
@@ -786,7 +786,7 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
 		goto csum_unnecessary;
 
 	if (likely(is_last_ethertype_ip(skb, &network_depth, &proto))) {
-		if (unlikely(get_ip_proto(skb, proto) == IPPROTO_SCTP))
+		if (unlikely(get_ip_proto(skb, network_depth, proto) == IPPROTO_SCTP))
 			goto csum_unnecessary;
 
 		skb->ip_summed = CHECKSUM_COMPLETE;
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 31 lines · Cong Wang

IP header is not necessarily located right after struct ethhdr, there could be multiple 802.1Q headers in between, this is why we call __vlan_get_protocol().

Fixes fe1dc069990c ("net/mlx5e: don't set CHECKSUM_COMPLETE on SCTP packets")
Cc Alaa Hleihel <[email protected]>
Cc Or Gerlitz <[email protected]>
Cc Saeed Mahameed <[email protected]>
---
  drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +2 -2
index 9b6bd2b51556..f7c5dbb0ffcd 100644
@@ -724,9 +724,9 @@ static u32 mlx5e_get_fcs(const struct sk_buff *skb)
  	return __get_unaligned_cpu32(fcs_bytes);
  }
 
-static u8 get_ip_proto(struct sk_buff *skb, __be16 proto)
+static u8 get_ip_proto(struct sk_buff *skb, int network_depth, __be16 proto)
  {
-	void *ip_p = skb->data + sizeof(struct ethhdr);
+	void *ip_p = skb->data + network_depth;
 
  	return (proto == htons(ETH_P_IP)) ? ((struct iphdr *)ip_p)->protocol :
  					    ((struct ipv6hdr *)ip_p)->nexthdr;

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c static inline void mlx5e_handle_csum(struct net_device *netdev, · line 792

Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -1
@@ -786,7 +786,7 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
  		goto csum_unnecessary;
 
  	if (likely(is_last_ethertype_ip(skb, &network_depth, &proto))) {
-		if (unlikely(get_ip_proto(skb, proto) == IPPROTO_SCTP))
+		if (unlikely(get_ip_proto(skb, network_depth, proto) == IPPROTO_SCTP))
  			goto csum_unnecessary;
 
  		skb->ip_summed = CHECKSUM_COMPLETE;

LGTM. Thanks for you patch, Cong.

#2 lore raw
Quoted 8 lines · Tariq Toukan
Quoted 4 lines · Cong Wang

IP header is not necessarily located right after struct ethhdr, there could be multiple 802.1Q headers in between, this is why we call __vlan_get_protocol().

Quoted 5 lines
Quoted 5 lines
Fixes fe1dc069990c ("net/mlx5e: don't set CHECKSUM_COMPLETE on SCTP packets")
Cc Alaa Hleihel <[email protected]>
Cc Or Gerlitz <[email protected]>
Cc Saeed Mahameed <[email protected]>
maintainer Applied
#3 lore raw
In reply to Cong Wang

From: Cong Wang <[email protected]>
Date: Wed, 28 Nov 2018 15:04:05 -0800

Quoted 9 lines

IP header is not necessarily located right after struct ethhdr, there could be multiple 802.1Q headers in between, this is why we call __vlan_get_protocol().

Fixes fe1dc069990c ("net/mlx5e: don't set CHECKSUM_COMPLETE on SCTP packets")
Cc Alaa Hleihel <[email protected]>
Cc Or Gerlitz <[email protected]>
Cc Saeed Mahameed <[email protected]>

Applied.