netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Joe Stringer <joe@wand.net.nz>
Cc: netdev <netdev@vger.kernel.org>,
	daniel@iogearbox.net, Nicolas Dichtel <nicolas.dichtel@6wind.com>
Subject: Re: netns_id in bpf_sk_lookup_{tcp,udp}
Date: Mon, 19 Nov 2018 12:54:55 -0700	[thread overview]
Message-ID: <c9400c6a-67a7-dd89-cf64-4f1b8ece89a2@gmail.com> (raw)
In-Reply-To: <CAOftzPjkOp=7V1n1Vpz2VV3A=xy5qKhkpZvhyttjF21BzivNzQ@mail.gmail.com>

On 11/19/18 12:47 PM, Joe Stringer wrote:
> On Mon, 19 Nov 2018 at 10:39, David Ahern <dsahern@gmail.com> wrote:
>>
>> On 11/19/18 11:36 AM, Joe Stringer wrote:
>>> Hi David, thanks for pointing this out.
>>>
>>> This is more of an oversight through iterations, the runtime lookup
>>> will fail to find a socket if the netns value is greater than the
>>> range of a uint32 so I think it would actually make more sense to drop
>>> the parameter size to u32 rather than u64 so that this would be
>>> validated at load time rather than silently returning NULL because of
>>> a bad parameter.
>>
>> ok. I was wondering if it was a u64 to handle nsid of 0 which as I
>> understand it is a legal nsid. If you drop to u32, how do you know when
>> nsid has been set?
> 
> I was operating under the assumption that 0 represents the root netns
> id, and cannot be assigned to another non-root netns.
> 
> Looking at __peernet2id_alloc(), it seems to me like it attempts to
> find a netns and if it cannot find one, returns 0, which then leads to
> a scroll over the idr starting from 0 to INT_MAX to find a legitimate
> id for the netns, so I think this is a fair assumption?
> 

Maybe Nicolas can give a definitive answer; as I recall he added the
NSID option. I have not had time to walk the code. But I do recall
seeing an id of 0. e.g, on my dev box:
$ ip netns
vms (id: 0)

And include/uapi/linux/net_namespace.h shows -1 as not assigned.

  reply	other threads:[~2018-11-20  6:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-19  3:26 netns_id in bpf_sk_lookup_{tcp,udp} David Ahern
2018-11-19 18:36 ` Joe Stringer
2018-11-19 18:39   ` David Ahern
2018-11-19 19:47     ` Joe Stringer
2018-11-19 19:54       ` David Ahern [this message]
2018-11-19 20:28         ` Nicolas Dichtel
2018-11-19 20:54           ` Joe Stringer
2018-11-19 21:59             ` Joe Stringer
2018-11-19 23:46               ` David Ahern
2018-11-20  9:05                 ` Nicolas Dichtel
2018-11-20 15:46                   ` David Ahern
2018-11-20 16:03                     ` Nicolas Dichtel
2018-11-21  5:12                   ` David Ahern
2018-11-21  9:44                     ` [PATCH iproute2] ipnetns: parse nsid as a signed integer Nicolas Dichtel
2018-11-21 17:37                       ` Stephen Hemminger

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=c9400c6a-67a7-dd89-cf64-4f1b8ece89a2@gmail.com \
    --to=dsahern@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=joe@wand.net.nz \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.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).