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 v3 3/3] samples: bpf: add userspace example for modifying sk_bound_dev_if
Date: Mon, 28 Nov 2016 12:37:54 -0800 [thread overview]
Message-ID: <20161128203752.GC7634@ast-mbp.thefacebook.com> (raw)
In-Reply-To: <1480348130-31354-4-git-send-email-dsa@cumulusnetworks.com>
On Mon, Nov 28, 2016 at 07:48:50AM -0800, David Ahern wrote:
> Add a simple program to demonstrate the ability to attach a bpf program
> to a cgroup that sets sk_bound_dev_if for AF_INET{6} sockets when they
> are created.
>
> Signed-off-by: David Ahern <dsa@cumulusnetworks•com>
...
> +static int prog_load(int idx)
> +{
> + struct bpf_insn prog[] = {
> + BPF_MOV64_REG(BPF_REG_6, BPF_REG_1),
> + BPF_MOV64_IMM(BPF_REG_3, idx),
> + BPF_MOV64_IMM(BPF_REG_2, offsetof(struct bpf_sock, bound_dev_if)),
> + BPF_STX_MEM(BPF_W, BPF_REG_1, BPF_REG_3, offsetof(struct bpf_sock, bound_dev_if)),
> + BPF_MOV64_IMM(BPF_REG_0, 1), /* r0 = verdict */
> + BPF_EXIT_INSN(),
> + };
> +
> + return bpf_prog_load(BPF_PROG_TYPE_CGROUP_SOCK, prog, sizeof(prog),
> + "GPL", 0);
> +}
the program looks trivial enough :)
Could you integrate it into iproute2 as well ?
Then the whole vrf management will be easier.
The user wouldn't even need to be aware that iproute2 sets up
this program. It will know ifindex and can delete
the prog when vrf configs change and so on.
Also please convert this sample into automated test like samples/bpf/*.sh
we're going to move all of them to tools/testing/selftests/ eventually.
next prev parent reply other threads:[~2016-11-28 20:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-28 15:48 [PATCH net-next v3 0/3] net: Add bpf support to set sk_bound_dev_if David Ahern
2016-11-28 15:48 ` [PATCH net-next v3 1/3] bpf: Refactor cgroups code in prep for new type David Ahern
2016-11-28 20:06 ` Alexei Starovoitov
2016-11-28 20:31 ` David Ahern
2016-11-28 15:48 ` [PATCH net-next v3 2/3] bpf: Add new cgroup attach type to enable sock modifications David Ahern
2016-11-28 20:32 ` Alexei Starovoitov
2016-11-28 20:57 ` David Ahern
2016-11-28 15:48 ` [PATCH net-next v3 3/3] samples: bpf: add userspace example for modifying sk_bound_dev_if David Ahern
2016-11-28 20:37 ` Alexei Starovoitov [this message]
2016-11-28 20:47 ` 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=20161128203752.GC7634@ast-mbp.thefacebook.com \
--to=alexei.starovoitov@gmail$(echo .)com \
--cc=ast@fb$(echo .)com \
--cc=daniel@iogearbox$(echo .)net \
--cc=daniel@zonque$(echo .)org \
--cc=dsa@cumulusnetworks$(echo .)com \
--cc=maheshb@google$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=tgraf@suug$(echo .)ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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