Re: [PATCH net-next v4 3/4] net: ipv6: seg6_iptunnel: mitigate 2-realloc issue

From: Paolo Abeni
Date: Tue Nov 19 2024 - 05:48:29 EST


On 11/18/24 14:15, Justin Iurman wrote:
[...]
> /* encapsulate an IPv6 packet within an outer IPv6 header with reduced SRH */
> static int seg6_do_srh_encap_red(struct sk_buff *skb,
> - struct ipv6_sr_hdr *osrh, int proto)
> + struct ipv6_sr_hdr *osrh, int proto,
> + struct dst_entry *dst)
> {
> __u8 first_seg = osrh->first_segment;
> - struct dst_entry *dst = skb_dst(skb);
> - struct net *net = dev_net(dst->dev);
> + struct net *net = dev_net(skb_dst(skb)->dev);
> struct ipv6hdr *hdr, *inner_hdr;
> int hdrlen = ipv6_optlen(osrh);
> int red_tlv_offset, tlv_offset;


Minor nit: please respect the reverse x-mas tree order above.
Also the code would probably be more readable with:

struct dst_entry *old_dst = skb_dst(skb);

and using 'old_dst' instead of 'skb_dst(skb)'

Cheers,

Paolo