From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: David Ahern <dsa@cumulusnetworks.com>
Cc: netdev@vger.kernel.org, daniel@zonque.org, ast@fb.com,
daniel@iogearbox.net, maheshb@google.com, tgraf@suug.ch
Subject: Re: [PATCH net-next v6 4/6] bpf: Add support for reading socket family, type, protocol
Date: Wed, 30 Nov 2016 21:53:17 -0800 [thread overview]
Message-ID: <20161201055314.GA42375@ast-mbp.thefacebook.com> (raw)
In-Reply-To: <1480529810-25850-5-git-send-email-dsa@cumulusnetworks.com>
On Wed, Nov 30, 2016 at 10:16:48AM -0800, David Ahern wrote:
> Add socket family, type and protocol to bpf_sock allowing bpf programs
> read-only access.
>
> Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
...
> +static u32 convert_sock_access(int sock_field, int dst_reg, int src_reg,
> + struct bpf_insn *insn_buf)
> +{
> + struct bpf_insn *insn = insn_buf;
> +
> + switch (sock_field) {
> + case SOCKF_AD_TYPE:
> + *insn++ = BPF_LDX_MEM(BPF_W, dst_reg, src_reg,
> + offsetof(struct sock, __sk_flags_offset));
> + *insn++ = BPF_ALU32_IMM(BPF_AND, dst_reg, SK_FL_TYPE_MASK);
> + *insn++ = BPF_ALU32_IMM(BPF_RSH, dst_reg, SK_FL_TYPE_SHIFT);
> + break;
Wasn't that complex after all? ;)
This part looks good.
> + case offsetof(struct bpf_sock, type):
> + return convert_sock_access(SOCKF_AD_TYPE, dst_reg, src_reg,
> + insn_buf);
my only request-for-change is to place the above 3 lines of *insn++ here
instead of adding new helper function for it.
In case of skb it was a helper, because it was called from different places.
Here this is the only place where it ever be needed, so extra helper
only confuses the reader.
The rest of the patches look good to me.
I'm not Ack-ing them yet, since you didn't carry over my Ack
from the first patch and I had to re-review it again this time.
Thanks.
next prev parent reply other threads:[~2016-12-01 6:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-30 18:16 [PATCH net-next v6 0/6] net: Add bpf support for sockets David Ahern
2016-11-30 18:16 ` [PATCH net-next v6 1/6] bpf: Refactor cgroups code in prep for new type David Ahern
2016-11-30 18:16 ` [PATCH net-next v6 2/6] bpf: Add new cgroup attach type to enable sock modifications David Ahern
2016-11-30 18:16 ` [PATCH net-next v6 3/6] samples: bpf: add userspace example for modifying sk_bound_dev_if David Ahern
2016-11-30 18:16 ` [PATCH net-next v6 4/6] bpf: Add support for reading socket family, type, protocol David Ahern
2016-12-01 5:53 ` Alexei Starovoitov [this message]
2016-11-30 18:16 ` [PATCH net-next v6 5/6] samples/bpf: Update bpf loader for cgroup section names David Ahern
2016-11-30 18:16 ` [PATCH net-next v6 6/6] samples/bpf: add userspace example for prohibiting sockets David Ahern
2016-12-01 5:59 ` Alexei Starovoitov
2016-12-01 15:13 ` David Ahern
2016-12-05 10:51 ` David Laight
2016-12-05 14:31 ` David Ahern
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=20161201055314.GA42375@ast-mbp.thefacebook.com \
--to=alexei.starovoitov@gmail.com \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=daniel@zonque.org \
--cc=dsa@cumulusnetworks.com \
--cc=maheshb@google.com \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
/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