lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9480856d183c88a205fd79d9dbc156a7fd3ea0d3.camel@redhat.com>
Date:   Tue, 29 Nov 2022 10:33:59 +0100
From:   Paolo Abeni <pabeni@...hat.com>
To:     Coco Li <lixiaoyan@...gle.com>,
        "David S. Miller" <davem@...emloft.net>,
        Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
        David Ahern <dsahern@...nel.org>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Michael Chan <michael.chan@...adcom.com>
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v2 1/2] IPv6/GRO: generic helper to remove
 temporary HBH/jumbo header in driver

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@...gle.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ