All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Gobert <richardbgobert@gmail.com>
To: Ido Schimmel <idosch@nvidia.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	donald.hunter@gmail.com, andrew+netdev@lunn.ch,
	dsahern@kernel.org, shuah@kernel.org, daniel@iogearbox.net,
	jacob.e.keller@intel.com, razor@blackwall.org, petrm@nvidia.com,
	menglong8.dong@gmail.com, martin.lau@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v5 3/5] net: vxlan: bind vxlan sockets to their local address if configured
Date: Wed, 13 Aug 2025 17:18:57 +0200	[thread overview]
Message-ID: <9727fba9-a238-4d0c-aa12-cb6c4cbcdea3@gmail.com> (raw)
In-Reply-To: <aJxaYt7aPxuU9iN6@shredder>



On 8/13/25 11:26, Ido Schimmel wrote:
> On Tue, Aug 12, 2025 at 02:51:53PM +0200, Richard Gobert wrote:
>> Bind VXLAN sockets to the local addresses if the IFLA_VXLAN_LOCALBIND
>> option is set. This is the new default.
> 
> Drop the last sentence?
> 
>>
>> Change vxlan_find_sock to search for the socket using the listening
>> address.
>>
>> This is implemented by copying the VXLAN local address to the udp_port_cfg
>> passed to udp_sock_create. The freebind option is set because VXLAN
>> interfaces may be UP before their outgoing interface is.
>>
>> This fixes multiple VXLAN selftests that fail because of that race.
> 
> This sentence is no longer relevant as well.
> 
>>
>> Signed-off-by: Richard Gobert <richardbgobert@gmail.com>
>> ---
>>  drivers/net/vxlan/vxlan_core.c | 59 ++++++++++++++++++++++++++--------
>>  1 file changed, 46 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
>> index 15fe9d83c724..12da9595436e 100644
>> --- a/drivers/net/vxlan/vxlan_core.c
>> +++ b/drivers/net/vxlan/vxlan_core.c
>> @@ -78,18 +78,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).
>> + * bound 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)
>>  {
>>  	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);
> 
> https://docs.kernel.org/process/maintainer-netdev.html#local-variable-ordering-reverse-xmas-tree-rcs
> 
>> +
>> +		if (flags & VXLAN_F_LOCALBIND) {
>> +			if (family == AF_INET &&
>> +			    inet->inet_rcv_saddr != saddr->sin.sin_addr.s_addr)
>> +				continue;
>> +#if IS_ENABLED(CONFIG_IPV6)
>> +			else if (family == AF_INET6 &&
>> +				 ipv6_addr_cmp(&sk->sk_v6_rcv_saddr,
>> +					       &saddr->sin6.sin6_addr) != 0)
>> +				continue;
>> +#endif
>> +		}
>> +
>> +		if (inet->inet_sport == port &&
>>  		    vxlan_get_sk_family(vs) == family &&
>>  		    vs->flags == flags &&
>>  		    vs->sock->sk->sk_bound_dev_if == ifindex)

My bad, will fix.

  reply	other threads:[~2025-08-13 15:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-12 12:51 [PATCH net-next v5 0/5] net: add local address bind support to vxlan and geneve Richard Gobert
2025-08-12 12:51 ` [PATCH net-next v5 1/5] net: udp: add freebind option to udp_sock_create Richard Gobert
2025-08-13  9:25   ` Ido Schimmel
2025-08-13 15:10     ` Richard Gobert
2025-08-12 12:51 ` [PATCH net-next v5 2/5] net: vxlan: add netlink option to bind vxlan sockets to local addresses Richard Gobert
2025-08-13  6:28   ` Kuniyuki Iwashima
2025-08-13 15:46     ` Richard Gobert
2025-08-13 16:04       ` Ido Schimmel
2025-08-13 17:55         ` Kuniyuki Iwashima
2025-08-13  9:26   ` Ido Schimmel
2025-08-12 12:51 ` [PATCH net-next v5 3/5] net: vxlan: bind vxlan sockets to their local address if configured Richard Gobert
2025-08-13  7:07   ` Kuniyuki Iwashima
2025-08-13 15:41     ` Richard Gobert
2025-08-13  9:26   ` Ido Schimmel
2025-08-13 15:18     ` Richard Gobert [this message]
2025-08-12 12:51 ` [PATCH net-next v5 4/5] net: geneve: enable binding geneve sockets to local addresses Richard Gobert
2025-08-12 12:51 ` [PATCH net-next v5 5/5] selftests/net: add vxlan localbind selftest Richard Gobert
2025-08-13 11:44   ` Ido Schimmel
2025-08-13 15:49     ` Richard Gobert
2025-08-13 14:34   ` Jakub Kicinski
2025-08-13 15:52     ` Richard Gobert
2025-08-13  9:25 ` [PATCH net-next v5 0/5] net: add local address bind support to vxlan and geneve Ido Schimmel
2025-08-13 15:29   ` Richard Gobert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9727fba9-a238-4d0c-aa12-cb6c4cbcdea3@gmail.com \
    --to=richardbgobert@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=menglong8.dong@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=razor@blackwall.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.