diff mbox series

[net-next,1/3] net: gso: add HBH extension header offload support

Message ID e8b01e54-b623-44ec-84d5-406ea3b0c80b@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: gro: reduce extension header parsing overhead | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1117 this patch: 1117
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang fail Errors and warnings before: 12 this patch: 12
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1144 this patch: 1144
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 65 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Richard Gobert Dec. 21, 2023, 6:55 p.m. UTC
This commit adds net_offload to IPv6 Hop-by-Hop extension headers (as it
is done for routing and dstopts) since it is supported in GSO and GRO.
This allows to remove specific HBH conditionals in GSO and GRO when
pulling and parsing an incoming packet.

Signed-off-by: Richard Gobert <richardbgobert@gmail.com>
---
 net/ipv6/exthdrs_offload.c | 11 +++++++++++
 net/ipv6/ip6_offload.c     | 25 +++++++++++--------------
 2 files changed, 22 insertions(+), 14 deletions(-)

Comments

Willem de Bruijn Dec. 26, 2023, 8:24 p.m. UTC | #1
Richard Gobert wrote:
> This commit adds net_offload to IPv6 Hop-by-Hop extension headers (as it
> is done for routing and dstopts) since it is supported in GSO and GRO.
> This allows to remove specific HBH conditionals in GSO and GRO when
> pulling and parsing an incoming packet.
> 
> Signed-off-by: Richard Gobert <richardbgobert@gmail.com>

Reviewed-by: Willem de Bruijn <willemb@google.com>

> ---
>  net/ipv6/exthdrs_offload.c | 11 +++++++++++
>  net/ipv6/ip6_offload.c     | 25 +++++++++++--------------
>  2 files changed, 22 insertions(+), 14 deletions(-)
> 
> diff --git a/net/ipv6/exthdrs_offload.c b/net/ipv6/exthdrs_offload.c
> index 06750d65d480..4c00398f4dca 100644
> --- a/net/ipv6/exthdrs_offload.c
> +++ b/net/ipv6/exthdrs_offload.c
> @@ -16,6 +16,10 @@ static const struct net_offload dstopt_offload = {
>  	.flags		=	INET6_PROTO_GSO_EXTHDR,
>  };
>  
> +static const struct net_offload hbh_offload = {
> +	.flags		=	INET6_PROTO_GSO_EXTHDR,
> +};
> +
>  int __init ipv6_exthdrs_offload_init(void)
>  {
>  	int ret;
> @@ -28,9 +32,16 @@ int __init ipv6_exthdrs_offload_init(void)
>  	if (ret)
>  		goto out_rt;
>  
> +	ret = inet6_add_offload(&hbh_offload, IPPROTO_HOPOPTS);
> +	if (ret)
> +		goto out_dstopts;
> +
>  out:
>  	return ret;
>  
> +out_dstopts:
> +	inet6_del_offload(&dstopt_offload, IPPROTO_DSTOPTS);
> +
>  out_rt:
>  	inet6_del_offload(&rthdr_offload, IPPROTO_ROUTING);
>  	goto out;
> diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
> index d6314287338d..0e0b5fed0995 100644
> --- a/net/ipv6/ip6_offload.c
> +++ b/net/ipv6/ip6_offload.c
> @@ -45,15 +45,13 @@ static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto)
>  		struct ipv6_opt_hdr *opth;
>  		int len;
>  
> -		if (proto != NEXTHDR_HOP) {
> -			ops = rcu_dereference(inet6_offloads[proto]);
> +		ops = rcu_dereference(inet6_offloads[proto]);
>  
> -			if (unlikely(!ops))
> -				break;
> +		if (unlikely(!ops))
> +			break;
>  
> -			if (!(ops->flags & INET6_PROTO_GSO_EXTHDR))
> -				break;
> -		}
> +		if (!(ops->flags & INET6_PROTO_GSO_EXTHDR))
> +			break;
>  
>  		if (unlikely(!pskb_may_pull(skb, 8)))
>  			break;
> @@ -171,13 +169,12 @@ static int ipv6_exthdrs_len(struct ipv6hdr *iph,
>  
>  	proto = iph->nexthdr;
>  	for (;;) {
> -		if (proto != NEXTHDR_HOP) {
> -			*opps = rcu_dereference(inet6_offloads[proto]);
> -			if (unlikely(!(*opps)))
> -				break;
> -			if (!((*opps)->flags & INET6_PROTO_GSO_EXTHDR))
> -				break;
> -		}
> +		*opps = rcu_dereference(inet6_offloads[proto]);
> +		if (unlikely(!(*opps)))
> +			break;
> +		if (!((*opps)->flags & INET6_PROTO_GSO_EXTHDR))
> +			break;
> +
>  		opth = (void *)opth + optlen;
>  		optlen = ipv6_optlen(opth);
>  		len += optlen;
> -- 
> 2.36.1
>
diff mbox series

Patch

diff --git a/net/ipv6/exthdrs_offload.c b/net/ipv6/exthdrs_offload.c
index 06750d65d480..4c00398f4dca 100644
--- a/net/ipv6/exthdrs_offload.c
+++ b/net/ipv6/exthdrs_offload.c
@@ -16,6 +16,10 @@  static const struct net_offload dstopt_offload = {
 	.flags		=	INET6_PROTO_GSO_EXTHDR,
 };
 
+static const struct net_offload hbh_offload = {
+	.flags		=	INET6_PROTO_GSO_EXTHDR,
+};
+
 int __init ipv6_exthdrs_offload_init(void)
 {
 	int ret;
@@ -28,9 +32,16 @@  int __init ipv6_exthdrs_offload_init(void)
 	if (ret)
 		goto out_rt;
 
+	ret = inet6_add_offload(&hbh_offload, IPPROTO_HOPOPTS);
+	if (ret)
+		goto out_dstopts;
+
 out:
 	return ret;
 
+out_dstopts:
+	inet6_del_offload(&dstopt_offload, IPPROTO_DSTOPTS);
+
 out_rt:
 	inet6_del_offload(&rthdr_offload, IPPROTO_ROUTING);
 	goto out;
diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
index d6314287338d..0e0b5fed0995 100644
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -45,15 +45,13 @@  static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto)
 		struct ipv6_opt_hdr *opth;
 		int len;
 
-		if (proto != NEXTHDR_HOP) {
-			ops = rcu_dereference(inet6_offloads[proto]);
+		ops = rcu_dereference(inet6_offloads[proto]);
 
-			if (unlikely(!ops))
-				break;
+		if (unlikely(!ops))
+			break;
 
-			if (!(ops->flags & INET6_PROTO_GSO_EXTHDR))
-				break;
-		}
+		if (!(ops->flags & INET6_PROTO_GSO_EXTHDR))
+			break;
 
 		if (unlikely(!pskb_may_pull(skb, 8)))
 			break;
@@ -171,13 +169,12 @@  static int ipv6_exthdrs_len(struct ipv6hdr *iph,
 
 	proto = iph->nexthdr;
 	for (;;) {
-		if (proto != NEXTHDR_HOP) {
-			*opps = rcu_dereference(inet6_offloads[proto]);
-			if (unlikely(!(*opps)))
-				break;
-			if (!((*opps)->flags & INET6_PROTO_GSO_EXTHDR))
-				break;
-		}
+		*opps = rcu_dereference(inet6_offloads[proto]);
+		if (unlikely(!(*opps)))
+			break;
+		if (!((*opps)->flags & INET6_PROTO_GSO_EXTHDR))
+			break;
+
 		opth = (void *)opth + optlen;
 		optlen = ipv6_optlen(opth);
 		len += optlen;