From: Simon Horman <horms@kernel.org>
To: Richard Gobert <richardbgobert@gmail.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, idosch@nvidia.com, amcohen@nvidia.com,
petrm@nvidia.com, gnault@redhat.com, jbenc@redhat.com,
b.galvani@gmail.com, martin.lau@kernel.org, daniel@iogearbox.net,
aahila@google.com, liuhangbin@gmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/2] net: vxlan: enable local address bind for vxlan sockets
Date: Tue, 9 Jul 2024 13:09:19 +0100 [thread overview]
Message-ID: <20240709120919.GH346094@kernel.org> (raw)
In-Reply-To: <20240708111103.9742-2-richardbgobert@gmail.com>
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@gmail.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
next prev parent reply other threads:[~2024-07-09 12:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-08 11:11 [PATCH net-next v2 0/2] net: add local address bind support to vxlan and geneve Richard Gobert
2024-07-08 11:11 ` [PATCH net-next v2 1/2] net: vxlan: enable local address bind for vxlan sockets Richard Gobert
2024-07-09 12:09 ` Simon Horman [this message]
2024-07-08 11:11 ` [PATCH net-next v2 2/2] net: geneve: enable local address bind for geneve sockets 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=20240709120919.GH346094@kernel.org \
--to=horms@kernel.org \
--cc=aahila@google.com \
--cc=amcohen@nvidia.com \
--cc=b.galvani@gmail.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gnault@redhat.com \
--cc=idosch@nvidia.com \
--cc=jbenc@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuhangbin@gmail.com \
--cc=martin.lau@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=richardbgobert@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).