Re: [PATCH net-next v2 1/2] IPv6/GRO: generic helper to remove temporary HBH/jumbo header in driver

From: Alexander Lobakin
Date: Tue Nov 29 2022 - 08:42:46 EST


From: Paolo Abeni <pabeni@xxxxxxxxxx>
Date: Tue, 29 Nov 2022 10:33:59 +0100

> 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:

[...]

> > +static inline int ipv6_hopopt_jumbo_remove(struct sk_buff *skb)

I thinks it's relatively small and inlineable enough to not make it
an external function, right? I'd keep it inline just how the author
does it, the compiler then will decide.

> > +{
> > + 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;

Same with the end of the function, @err is unused after
skb_cow_head() and always equal 0, so the end return could be just
`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

Thanks,
Olek