[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240701195507.256374-2-tom@herbertland.com>
Date: Mon, 1 Jul 2024 12:55:01 -0700
From: Tom Herbert <tom@...bertland.com>
To: davem@...emloft.net,
kuba@...nel.org,
jesse.brandeburg@...el.com,
anthony.l.nguyen@...el.com,
cai.huoqing@...ux.dev,
netdev@...r.kernel.org,
felipe@...anda.io,
justin.iurman@...ege.be
Cc: Tom Herbert <tom@...bertland.com>
Subject: [PATCH net-next v2 1/7] ipv6: Add ipv6_skip_exthdr_no_rthdr
ipv6_skip_exthdr_no_rthdr will be called by drivers that support
protocol specific transmit checksum offload with extension headers.
Protocol specific checksum offload doesn't work with routing headers
since the destination address in the IPv6 header is not the one used
in the pseduo checksum for TCP or UDP. This is not a problem with
protocol agnostic checksum offload.
If a routing header is present then ipv6_skip_exthdr_no_rthdr returns
a value less than zero, this is an indication that the driver should
call skb_checksum_help instead of offloading the checksum which would
be doomed to cause a packet drop at the receiver due to a bad checksum.
Signed-off-by: Tom Herbert <tom@...bertland.com>
---
include/net/ipv6.h | 17 +++++++++++++++--
net/ipv6/exthdrs_core.c | 25 ++++++++++++++++++-------
2 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 88a8e554f7a1..6581fabd1e1e 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -1157,8 +1157,21 @@ void ipv6_push_nfrag_opts(struct sk_buff *skb, struct ipv6_txoptions *opt,
void ipv6_push_frag_opts(struct sk_buff *skb, struct ipv6_txoptions *opt,
u8 *proto);
-int ipv6_skip_exthdr(const struct sk_buff *, int start, u8 *nexthdrp,
- __be16 *frag_offp);
+int __ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
+ __be16 *frag_offp, bool no_rthdr);
+
+static inline int ipv6_skip_exthdr(const struct sk_buff *skb, int start,
+ u8 *nexthdrp, __be16 *frag_offp)
+{
+ return __ipv6_skip_exthdr(skb, start, nexthdrp, frag_offp, false);
+}
+
+static inline int ipv6_skip_exthdr_no_rthdr(const struct sk_buff *skb,
+ int start, u8 *nexthdrp,
+ __be16 *frag_offp)
+{
+ return __ipv6_skip_exthdr(skb, start, nexthdrp, frag_offp, true);
+}
bool ipv6_ext_hdr(u8 nexthdr);
diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c
index 49e31e4ae7b7..25501777ae05 100644
--- a/net/ipv6/exthdrs_core.c
+++ b/net/ipv6/exthdrs_core.c
@@ -69,8 +69,8 @@ EXPORT_SYMBOL(ipv6_ext_hdr);
* --ANK (980726)
*/
-int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
- __be16 *frag_offp)
+int __ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
+ __be16 *frag_offp, bool no_rthdr)
{
u8 nexthdr = *nexthdrp;
@@ -85,7 +85,8 @@ int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr);
if (!hp)
return -1;
- if (nexthdr == NEXTHDR_FRAGMENT) {
+ switch (nexthdr) {
+ case NEXTHDR_FRAGMENT: {
__be16 _frag_off, *fp;
fp = skb_header_pointer(skb,
start+offsetof(struct frag_hdr,
@@ -97,21 +98,31 @@ int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
*frag_offp = *fp;
if (ntohs(*frag_offp) & ~0x7)
- break;
+ goto out;
hdrlen = 8;
- } else if (nexthdr == NEXTHDR_AUTH)
+ break;
+ }
+ case NEXTHDR_AUTH:
hdrlen = ipv6_authlen(hp);
- else
+ break;
+ case NEXTHDR_ROUTING:
+ if (no_rthdr)
+ return -1;
+ fallthrough;
+ default:
hdrlen = ipv6_optlen(hp);
+ break;
+ }
nexthdr = hp->nexthdr;
start += hdrlen;
}
+out:
*nexthdrp = nexthdr;
return start;
}
-EXPORT_SYMBOL(ipv6_skip_exthdr);
+EXPORT_SYMBOL(__ipv6_skip_exthdr);
int ipv6_find_tlv(const struct sk_buff *skb, int offset, int type)
{
--
2.34.1
Powered by blists - more mailing lists