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: <20240709120919.GH346094@kernel.org>
Date: Tue, 9 Jul 2024 13:09:19 +0100
From: Simon Horman <horms@...nel.org>
To: Richard Gobert <richardbgobert@...il.com>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
	pabeni@...hat.com, idosch@...dia.com, amcohen@...dia.com,
	petrm@...dia.com, gnault@...hat.com, jbenc@...hat.com,
	b.galvani@...il.com, martin.lau@...nel.org, daniel@...earbox.net,
	aahila@...gle.com, liuhangbin@...il.com, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v2 1/2] net: vxlan: enable local address bind
 for vxlan sockets

On Mon, Jul 08, 2024 at 01:11:02PM +0200, Richard Gobert wrote:
> This patch adds support for binding to a local address in vxlan sockets.
> It achieves this by using vxlan_addr union to represent a local address
> to bind to, and copying it to udp_port_cfg in vxlan_create_sock.
> 
> Also change vxlan_find_sock to search the socket based on the listening address.
> 
> Signed-off-by: Richard Gobert <richardbgobert@...il.com>
> ---
>  drivers/net/vxlan/vxlan_core.c | 53 ++++++++++++++++++++++++----------
>  1 file changed, 38 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
> index ba59e92ab941..9a797147beb7 100644
> --- a/drivers/net/vxlan/vxlan_core.c
> +++ b/drivers/net/vxlan/vxlan_core.c
> @@ -72,22 +72,34 @@ static inline bool vxlan_collect_metadata(struct vxlan_sock *vs)
>  }
>  
>  /* Find VXLAN socket based on network namespace, address family, UDP port,
> - * enabled unshareable flags and socket device binding (see l3mdev with
> - * non-default VRF).
> + * bounded address, enabled unshareable flags and socket device binding
> + * (see l3mdev with non-default VRF).
>   */
>  static struct vxlan_sock *vxlan_find_sock(struct net *net, sa_family_t family,
> -					  __be16 port, u32 flags, int ifindex)
> +					  __be16 port, u32 flags, int ifindex, union vxlan_addr *saddr)

nit: Where it can trivially be achieved, please limit lines to 80 columns
     wide as is still preferred in Networking code.

     Flagged by ./scripts/checkpatch.pl --max-line-length=80

>  {
>  	struct vxlan_sock *vs;
>  
>  	flags &= VXLAN_F_RCV_FLAGS;
>  
>  	hlist_for_each_entry_rcu(vs, vs_head(net, port), hlist) {
> -		if (inet_sk(vs->sock->sk)->inet_sport == port &&
> +		struct sock *sk = vs->sock->sk;
> +		struct inet_sock *inet = inet_sk(sk);
> +
> +		if (inet->inet_sport == port &&
>  		    vxlan_get_sk_family(vs) == family &&
>  		    vs->flags == flags &&
> -		    vs->sock->sk->sk_bound_dev_if == ifindex)
> -			return vs;
> +		    vs->sock->sk->sk_bound_dev_if == ifindex) {
> +			if (family == AF_INET && inet->inet_rcv_saddr == saddr->sin.sin_addr.s_addr) {
> +				return vs;
> +			}
> +#if IS_ENABLED(CONFIG_IPV6)
> +			else if (ipv6_addr_cmp(&sk->sk_v6_rcv_saddr, &saddr->sin6.sin6_addr) == 0)

1. There is a '{' missing form the line above, so this doesn't compile
   (if IPV6 is configured).
2. Probably the '{}' can be dropped from this if / else if conditional.

> +				return vs;
> +			}
> +#endif
> +		}
> +
>  	}
>  	return NULL;
>  }

-- 
pw-bot: changes-requested

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ