From: David Ahern <dsahern@gmail.com>
To: Joe Stringer <joe@wand.net.nz>
Cc: nicolas.dichtel@6wind.com, netdev <netdev@vger.kernel.org>,
daniel@iogearbox.net
Subject: Re: netns_id in bpf_sk_lookup_{tcp,udp}
Date: Mon, 19 Nov 2018 16:46:23 -0700 [thread overview]
Message-ID: <077323f3-3026-06b5-fb4b-54383e5387f6@gmail.com> (raw)
In-Reply-To: <CAOftzPgviq+J6kCCXEiWjtpR25ZPhZYFaWpNOFJ3i9pOoDg6cg@mail.gmail.com>
On 11/19/18 2:59 PM, Joe Stringer wrote:
> @@ -2221,12 +2222,13 @@ union bpf_attr {
> * **sizeof**\ (*tuple*\ **->ipv6**)
> * Look for an IPv6 socket.
> *
> - * If the *netns* is zero, then the socket lookup table in the
> - * netns associated with the *ctx* will be used. For the TC hooks,
> - * this in the netns of the device in the skb. For socket hooks,
> - * this in the netns of the socket. If *netns* is non-zero, then
> - * it specifies the ID of the netns relative to the netns
> - * associated with the *ctx*.
> + * If the *netns* is **BPF_F_SK_CURRENT_NS** or greater, then the
> + * socket lookup table in the netns associated with the *ctx* will
> + * will be used. For the TC hooks, this is the netns of the device
> + * in the skb. For socket hooks, this is the netns of the socket.
> + * If *netns* is less than **BPF_F_SK_CURRENT_NS**, then it
> + * specifies the ID of the netns relative to the netns associated
> + * with the *ctx*.
> *
> * All values for *flags* are reserved for future usage, and must
> * be left at zero.
> @@ -2409,6 +2411,9 @@ enum bpf_func_id {
> /* BPF_FUNC_perf_event_output for sk_buff input context. */
> #define BPF_F_CTXLEN_MASK (0xfffffULL << 32)
>
> +/* BPF_FUNC_sk_lookup_tcp and BPF_FUNC_sk_lookup_udp flags. */
> +#define BPF_F_SK_CURRENT_NS 0x80000000 /* For netns argument */
> +
> /* Mode for BPF_FUNC_skb_adjust_room helper. */
> enum bpf_adj_room_mode {
> BPF_ADJ_ROOM_NET,
>
> Plus adjusting all of the internal types and the helper headers to use
> u32. With the highest bit used to specify that the netns should be the
> current netns, all other netns IDs should be available.
>
That seems reasonable if the nsid limit is s32.
That revelation shows another hole:
$ ip netns add foo
$ ip netns set foo 0xffffffff
$ ip netns list
foo (id: 0)
Seems like alloc_netid() should error out if reqid < -1 (-1 being the
NETNSA_NSID_NOT_ASSIGNED flag) as opposed to blindly ignoring it.
next prev parent reply other threads:[~2018-11-20 10:12 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
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 [this message]
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=077323f3-3026-06b5-fb4b-54383e5387f6@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).