mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Richard Gobert <richardbgobert@gmail.com>
To: Eyal Birger <eyal.birger@gmail.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, idosch@nvidia.com, razor@blackwall.org,
	amcohen@nvidia.com, petrm@nvidia.com, jbenc@redhat.com,
	b.galvani@gmail.com, bpoirier@nvidia.com, gavinl@nvidia.com,
	martin.lau@kernel.org, daniel@iogearbox.net,
	herbert@gondor.apana.org.au, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 2/2] net: geneve: enable local address bind for geneve sockets
Date: Tue, 27 Feb 2024 10:02:51 +0100	[thread overview]
Message-ID: <aa5f1c11-4528-4d53-91f3-5ce8c02363ac@gmail.com> (raw)
In-Reply-To: <CAHsH6GvX7zYSoA7JVemRtunWWSaew1S11Y996WAGt6B9d8=cOA@mail.gmail.com>

Eyal Birger wrote:
> Hi,
> 
> On Thu, Feb 22, 2024 at 12:54 PM Richard Gobert
> <richardbgobert@gmail.com> wrote:
>>
>> This patch adds support for binding to a local address in geneve sockets.
> 
> Thanks for adding this.
> 
>> It achieves this by adding a geneve_addr union to represent local address
>> to bind to, and copying it to udp_port_cfg in geneve_create_sock.
> 
> AFICT in geneve_sock_add(), geneve_socket_create() is only called if there's
> no existing open socket with the GENEVE destination port. As such, wouldn't
> this bind work only for the first socket in the namespace?
> 
> If that is the case, then perhaps binding the socket isn't the right
> approach, and instead geneve_lookup() should search for the tunnel based on
> both the source and destination IPs.
> 
> Am I missing something?
> 
> Eyal

You are right, I missed it.
Binding the socket is the main reason for the patch, to prevent exposing
the geneve port on all interfaces.
I think it should be searched in geneve{6}_lookup and in geneve_find_sock:

static struct geneve_sock *geneve_find_sock(struct geneve_net *gn,
					    sa_family_t family,
					    union geneve_addr *saddr)
 {
 	struct geneve_sock *gs;

 	list_for_each_entry(gs, &gn->sock_list, list) {
		struct inet_sock *inet = inet_sk(gs->sock->sk);

		if (inet->inet_sport == dst_port && geneve_get_sk_family(gs) == family) {
			if (family == AF_INET && inet->inet_rcv_saddr == saddr->sin.sin_addr.s_addr)
				return gs;
        ...

This is also true for VXLAN
What do you think?
Thanks


  reply	other threads:[~2024-02-27  9:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 20:48 [PATCH net-next 0/2] net: add local address bind support to vxlan and geneve Richard Gobert
2024-02-22 20:51 ` [PATCH net-next 1/2] net: vxlan: enable local address bind for vxlan sockets Richard Gobert
2024-02-23 17:49   ` kernel test robot
2024-02-24  5:58   ` kernel test robot
2024-02-22 20:53 ` [PATCH net-next 2/2] net: geneve: enable local address bind for geneve sockets Richard Gobert
2024-02-22 22:31   ` Eyal Birger
2024-02-27  9:02     ` Richard Gobert [this message]
2024-02-28 17:51       ` Eyal Birger
2024-02-24  9:01   ` kernel test robot
2024-02-24 10:06   ` Jiri Benc
2024-02-23 14:11 ` [PATCH net-next 0/2] net: add local address bind support to vxlan and geneve Jakub Kicinski

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=aa5f1c11-4528-4d53-91f3-5ce8c02363ac@gmail.com \
    --to=richardbgobert@gmail.com \
    --cc=amcohen@nvidia.com \
    --cc=b.galvani@gmail.com \
    --cc=bpoirier@nvidia.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eyal.birger@gmail.com \
    --cc=gavinl@nvidia.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=idosch@nvidia.com \
    --cc=jbenc@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=razor@blackwall.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®