linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Coco Li <lixiaoyan@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	David Ahern <dsahern@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Michael Chan <michael.chan@broadcom.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/2] IPv6/GRO: generic helper to remove temporary HBH/jumbo header in driver
Date: Tue, 29 Nov 2022 10:33:59 +0100	[thread overview]
Message-ID: <9480856d183c88a205fd79d9dbc156a7fd3ea0d3.camel@redhat.com> (raw)
In-Reply-To: <20221123191627.3442831-1-lixiaoyan@google.com>

Hello,

Only a couple of minor things below, reporting them as this is still a
RFC, right ? ;)

On Wed, 2022-11-23 at 11:16 -0800, Coco Li wrote:
> IPv6/TCP and GRO stacks can build big TCP packets with an added
> temporary Hop By Hop header.
> 
> Is GSO is not involved, then the temporary header needs to be removed in
> the driver. This patch provides a generic helper for drivers that need
> to modify their headers in place.
> 
> Signed-off-by: Coco Li <lixiaoyan@google.com>
> ---
>  include/net/ipv6.h     | 36 ++++++++++++++++++++++++++++++++++++
>  net/ipv6/ip6_offload.c | 26 ++++----------------------
>  2 files changed, 40 insertions(+), 22 deletions(-)
> 
> diff --git a/include/net/ipv6.h b/include/net/ipv6.h
> index d383c895592a..c5a1daaf5056 100644
> --- a/include/net/ipv6.h
> +++ b/include/net/ipv6.h
> @@ -500,6 +500,42 @@ static inline int ipv6_has_hopopt_jumbo(const struct sk_buff *skb)
>  	return jhdr->nexthdr;
>  }
>  
> +/* Return 0 if HBH header is successfully removed
> + * Or if HBH removal is unnecessary (packet is not big TCP)
> + * Return error to indicate dropping the packet
> + */
> +static inline int ipv6_hopopt_jumbo_remove(struct sk_buff *skb)
> +{
> +	const int hophdr_len = sizeof(struct hop_jumbo_hdr);
> +	int nexthdr = ipv6_has_hopopt_jumbo(skb);
> +	struct ipv6hdr *h6;
> +	int err = 0;
> +
> +	if (!nexthdr)
> +		return err;

You can help a bit the compiler avoiding err initialization:

	int err;

	if (!nexthdr)
		return 0;

> +
> +	err = skb_cow_head(skb, 0);
> +	if (err)
> +		return err;
> +
> +	/* Remove the HBH header.
> +	 * Layout: [Ethernet header][IPv6 header][HBH][L4 Header]
> +	 */
> +	memmove(skb_mac_header(skb) + hophdr_len, skb_mac_header(skb),
> +		skb_network_header(skb) - skb_mac_header(skb) +

The have could be:

		skb_mac_header_len(skb)

which is IMHO a little more clear.

Thanks!

Paolo


  parent reply	other threads:[~2022-11-29  9:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 19:16 [PATCH net-next v2 1/2] IPv6/GRO: generic helper to remove temporary HBH/jumbo header in driver Coco Li
2022-11-23 19:16 ` [RFC net-next v2 2/2] bnxt: Use generic HBH removal helper in tx path Coco Li
2022-11-23 19:42   ` Michael Chan
2022-11-23 20:42     ` Michael Chan
2022-11-29  8:58     ` Michael Chan
2022-11-29 17:29       ` Coco Li
2022-11-29 17:50         ` Michael Chan
2022-11-29  9:33 ` Paolo Abeni [this message]
2022-11-29 13:41   ` [PATCH net-next v2 1/2] IPv6/GRO: generic helper to remove temporary HBH/jumbo header in driver Alexander Lobakin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9480856d183c88a205fd79d9dbc156a7fd3ea0d3.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lixiaoyan@google.com \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).