From: Daniel Borkmann <daniel@iogearbox.net>
To: Alexei Starovoitov <ast@fb.com>,
"David S . Miller" <davem@davemloft.net>
Cc: David Ahern <dsa@cumulusnetworks.com>, Tejun Heo <tj@kernel.org>,
Andy Lutomirski <luto@amacapital.net>,
"Eric W . Biederman" <ebiederm@xmission.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH v3 net] bpf: add bpf_sk_netns_id() helper
Date: Tue, 07 Feb 2017 00:39:03 +0100 [thread overview]
Message-ID: <58990917.8000406@iogearbox.net> (raw)
In-Reply-To: <1486179240-3574802-1-git-send-email-ast@fb.com>
On 02/04/2017 04:34 AM, Alexei Starovoitov wrote:
[...]
> +BPF_CALL_1(bpf_skb_netns_id, struct sk_buff *, skb)
> +{
> + struct net_device *dev = skb->dev;
> +
> + if (!dev)
> + return 0;
> + return proc_get_ns_devid_inum(&dev_net(dev)->ns);
> +}
> +
> +static const struct bpf_func_proto bpf_skb_netns_id_proto = {
> + .func = bpf_skb_netns_id,
> + .gpl_only = false,
> + .ret_type = RET_INTEGER,
> + .arg1_type = ARG_PTR_TO_CTX,
> +};
> +
> static const struct bpf_func_proto *
> sk_filter_func_proto(enum bpf_func_id func_id)
> {
> @@ -2620,6 +2649,8 @@ sk_filter_func_proto(enum bpf_func_id func_id)
> case BPF_FUNC_trace_printk:
> if (capable(CAP_SYS_ADMIN))
> return bpf_get_trace_printk_proto();
> + case BPF_FUNC_sk_netns_id:
> + return &bpf_skb_netns_id_proto;
> default:
> return NULL;
> }
Btw, I think here's an oversight that would still need to be
fixed. Above would mean that trace printk from unprivileged would
fall through and use &bpf_skb_netns_id_proto as proto now instead
of NULL. So BPF_FUNC_sk_netns_id needs to be placed above the
BPF_FUNC_trace_printk case, not in its fall-through path. Looks
like Chenbo in his get_socket_cookie missed this, too. Other than
that BPF bits seem good to me.
> @@ -2700,6 +2731,17 @@ xdp_func_proto(enum bpf_func_id func_id)
> }
next prev parent reply other threads:[~2017-02-06 23:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-04 3:34 [PATCH v3 net] bpf: add bpf_sk_netns_id() helper Alexei Starovoitov
2017-02-05 19:24 ` David Ahern
2017-02-05 20:19 ` Andy Lutomirski
2017-02-06 23:39 ` Daniel Borkmann [this message]
2017-02-07 0:02 ` Alexei Starovoitov
2017-02-07 0:09 ` Daniel Borkmann
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=58990917.8000406@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=ast@fb.com \
--cc=davem@davemloft.net \
--cc=dsa@cumulusnetworks.com \
--cc=ebiederm@xmission.com \
--cc=luto@amacapital.net \
--cc=netdev@vger.kernel.org \
--cc=tj@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.