Denis Kirjanov b64f75
From fab2bdc84727620e644e637bed88c512b9c05266 Mon Sep 17 00:00:00 2001
Denis Kirjanov b64f75
From: Slawomir Laba <slawomirx.laba@intel.com>
Denis Kirjanov b64f75
Date: Thu, 10 Sep 2020 07:57:04 +0000
Denis Kirjanov b64f75
Subject: [PATCH 06/19] i40e: Fix flow for IPv6 next header (extension header)
Denis Kirjanov b64f75
Git-commit: 92c6058024e87087cf1b99b0389d67c0a886360e
Denis Kirjanov b64f75
Patch-mainline: v5.12-rc1
Denis Kirjanov b64f75
References: git-fixes
Denis Kirjanov b64f75
Denis Kirjanov b64f75
When a packet contains an IPv6 header with next header which is
Denis Kirjanov b64f75
an extension header and not a protocol one, the kernel function
Denis Kirjanov b64f75
skb_transport_header called with such sk_buff will return a
Denis Kirjanov b64f75
pointer to the extension header and not to the TCP one.
Denis Kirjanov b64f75
Denis Kirjanov b64f75
The above explained call caused a problem with packet processing
Denis Kirjanov b64f75
for skb with encapsulation for tunnel with I40E_TX_CTX_EXT_IP_IPV6.
Denis Kirjanov b64f75
The extension header was not skipped at all.
Denis Kirjanov b64f75
Denis Kirjanov b64f75
The ipv6_skip_exthdr function does check if next header of the IPV6
Denis Kirjanov b64f75
header is an extension header and doesn't modify the l4_proto pointer
Denis Kirjanov b64f75
if it points to a protocol header value so its safe to omit the
Denis Kirjanov b64f75
comparison of exthdr and l4.hdr pointers. The ipv6_skip_exthdr can
Denis Kirjanov b64f75
return value -1. This means that the skipping process failed
Denis Kirjanov b64f75
and there is something wrong with the packet so it will be dropped.
Denis Kirjanov b64f75
Denis Kirjanov b64f75
Fixes: a3fd9d8876a5 ("i40e/i40evf: Handle IPv6 extension headers in checksum offload")
Denis Kirjanov b64f75
Signed-off-by: Slawomir Laba <slawomirx.laba@intel.com>
Denis Kirjanov b64f75
Signed-off-by: Przemyslaw Patynowski <przemyslawx.patynowski@intel.com>
Denis Kirjanov b64f75
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Denis Kirjanov b64f75
Tested-by: Tony Brelinski <tonyx.brelinski@intel.com>
Denis Kirjanov b64f75
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Denis Kirjanov b64f75
Signed-off-by: Denis Kirjanov <denis.kirjanov@suse.com>
Denis Kirjanov b64f75
---
Denis Kirjanov b64f75
 drivers/net/ethernet/intel/i40e/i40e_txrx.c | 9 ++++++---
Denis Kirjanov b64f75
 1 file changed, 6 insertions(+), 3 deletions(-)
Denis Kirjanov b64f75
Denis Kirjanov b64f75
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
Denis Kirjanov b64f75
index 734d95943967..4cb16178adb9 100644
Denis Kirjanov b64f75
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
Denis Kirjanov b64f75
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
Denis Kirjanov b64f75
@@ -3109,13 +3109,16 @@ static int i40e_tx_enable_csum(struct sk_buff *skb, u32 *tx_flags,
Denis Kirjanov b64f75
 
Denis Kirjanov b64f75
 			l4_proto = ip.v4->protocol;
Denis Kirjanov b64f75
 		} else if (*tx_flags & I40E_TX_FLAGS_IPV6) {
Denis Kirjanov b64f75
+			int ret;
Denis Kirjanov b64f75
+
Denis Kirjanov b64f75
 			tunnel |= I40E_TX_CTX_EXT_IP_IPV6;
Denis Kirjanov b64f75
 
Denis Kirjanov b64f75
 			exthdr = ip.hdr + sizeof(*ip.v6);
Denis Kirjanov b64f75
 			l4_proto = ip.v6->nexthdr;
Denis Kirjanov b64f75
-			if (l4.hdr != exthdr)
Denis Kirjanov b64f75
-				ipv6_skip_exthdr(skb, exthdr - skb->data,
Denis Kirjanov b64f75
-						 &l4_proto, &frag_off);
Denis Kirjanov b64f75
+			ret = ipv6_skip_exthdr(skb, exthdr - skb->data,
Denis Kirjanov b64f75
+					       &l4_proto, &frag_off);
Denis Kirjanov b64f75
+			if (ret < 0)
Denis Kirjanov b64f75
+				return -1;
Denis Kirjanov b64f75
 		}
Denis Kirjanov b64f75
 
Denis Kirjanov b64f75
 		/* define outer transport */
Denis Kirjanov b64f75
-- 
Denis Kirjanov b64f75
2.16.4
Denis Kirjanov b64f75