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] [day] [month] [year] [list]
Message-ID: <ec71f1cd-89b9-4a18-bcc6-0bac6f6660d0@intel.com>
Date: Wed, 27 Aug 2025 16:45:22 +0200
From: Alexander Lobakin <aleksander.lobakin@...el.com>
To: Yue Haibing <yuehaibing@...wei.com>
CC: <davem@...emloft.net>, <dsahern@...nel.org>, <edumazet@...gle.com>,
	<kuba@...nel.org>, <pabeni@...hat.com>, <horms@...nel.org>,
	<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next] ipv6: sit: Add ipip6_tunnel_dst_find() for
 cleanup

From: Yue Haibing <yuehaibing@...wei.com>
Date: Wed, 27 Aug 2025 12:00:27 +0800

> Extract the dst lookup logic from ipip6_tunnel_xmit() into new helper
> ipip6_tunnel_dst_find() to reduce code duplication and enhance readability.
> 
> No functional change intended.

...but bloat-o-meter stats would be nice to see here. I'm curious
whether the object code got any changes or the compilers still just
inline this function to both call sites.

> 
> Signed-off-by: Yue Haibing <yuehaibing@...wei.com>
> ---
>  net/ipv6/sit.c | 93 +++++++++++++++++++++++---------------------------
>  1 file changed, 43 insertions(+), 50 deletions(-)
> 
> diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
> index 12496ba1b7d4..bcd261ff985b 100644
> --- a/net/ipv6/sit.c
> +++ b/net/ipv6/sit.c
> @@ -848,6 +848,47 @@ static inline __be32 try_6rd(struct ip_tunnel *tunnel,
>  	return dst;
>  }
>  
> +static bool ipip6_tunnel_dst_find(struct sk_buff *skb, __be32 *dst,
> +				  bool is_isatap)
> +{
> +	const struct ipv6hdr *iph6 = ipv6_hdr(skb);
> +	struct neighbour *neigh = NULL;
> +	const struct in6_addr *addr6;
> +	bool found = false;
> +	int addr_type;
> +
> +	if (skb_dst(skb))
> +		neigh = dst_neigh_lookup(skb_dst(skb), &iph6->daddr);
> +
> +	if (!neigh) {
> +		net_dbg_ratelimited("nexthop == NULL\n");
> +		return found;

Return false here right away.

> +	}
> +
> +	addr6 = (const struct in6_addr *)&neigh->primary_key;
> +	addr_type = ipv6_addr_type(addr6);
> +
> +	if (is_isatap) {
> +		if ((addr_type & IPV6_ADDR_UNICAST) &&
> +		    ipv6_addr_is_isatap(addr6)) {
> +			*dst = addr6->s6_addr32[3];
> +			found = true;
> +		}
> +	} else {
> +		if (addr_type == IPV6_ADDR_ANY) {
> +			addr6 = &ipv6_hdr(skb)->daddr;
> +			addr_type = ipv6_addr_type(addr6);
> +		}
> +
> +		if ((addr_type & IPV6_ADDR_COMPATv4) != 0) {
> +			*dst = addr6->s6_addr32[3];
> +			found = true;
> +		}
> +	}
> +	neigh_release(neigh);
> +	return found;

I'd put 2 additional newlines here:

	}

	neigh_release(neigh);

	return found;
}

for readability purposes and also a NL before the final `return` is
usually mandatory.

Thanks,
Olek

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ