From: John Fastabend <john.fastabend@gmail.com>
To: Alexei Starovoitov <ast@fb.com>,
davem@davemloft.net, daniel@iogearbox.net
Cc: tgraf@suug.ch, netdev@vger.kernel.org, tom@herbertland.com
Subject: Re: [net-next PATCH 06/10] bpf: sockmap with sk redirect support
Date: Thu, 17 Aug 2017 11:58:00 -0700 [thread overview]
Message-ID: <5995E738.9090803@gmail.com> (raw)
In-Reply-To: <fbc6e111-f610-2ef9-bb2a-6503d747124f@fb.com>
[...]
>> +
>> +static void smap_tx_work(struct work_struct *w)
>> +{
>> + struct smap_psock *psock;
>> + struct sk_buff *skb;
>> + int rem, off, n;
>> +
>> + psock = container_of(w, struct smap_psock, tx_work);
>> +
>> + /* lock sock to avoid losing sk_socket at some point during loop */
>> + lock_sock(psock->sock);
>> + if (psock->save_skb) {
>> + skb = psock->save_skb;
>> + rem = psock->save_rem;
>> + off = psock->save_off;
>> + psock->save_skb = NULL;
>> + goto start;
>> + }
>> +
>> + while ((skb = skb_dequeue(&psock->rxqueue))) {
>> + rem = skb->len;
>> + off = 0;
>> +start:
>> + do {
>> + if (likely(psock->sock->sk_socket))
>> + n = skb_send_sock_locked(psock->sock,
>> + skb, off, rem);
>
> so this will be hot loop ?
> Do you have perf report by any chance? Curious how it looks.
I had some old ones but lets generate some fresh ones and we can go over
them. I'll post later today/tomorrow.
>
>> + /* reserve BPF programs early so can abort easily on failures */
>> + if (map_flags & BPF_SOCKMAP_STRPARSER) {
>
> why have two 'flags' arguments and new helper just for this?
> can normal update() be used and extra bits of flag there?
>
The new helper is needed regardless to handle consuming the skops ctx
pointer from programs attached to cgroups. This way we can attach sockets
in cgroups when they enter specified TCP states.
The map_flags arg was because I expect we may end up with a few more flags
in sockmap and thought it was reasonable to keep separate namespaces for
the two flag types, BPF_ and BPF_SOCKMAP_*. It does however have the one
issue that when doing the update via syscall the flags are not available.
If there is no objection to consuming some bits of the normal flags a small
patch could do that. I think we will need at least two more bits going forward
for additional features. I guess though the map flags is not pressed for
bit space yet though.
>> -#define BPF_PROG_ATTACH_LAST_FIELD attach_flags
>> +#define BPF_PROG_ATTACH_LAST_FIELD attach_bpf_fd2
>
>> + prog1 = bpf_prog_get_type(attr->attach_bpf_fd, ptype);
>> + if (IS_ERR(prog1)) {
>> + fdput(f);
>> + return PTR_ERR(prog1);
>> + }
>> +
>> + prog2 = bpf_prog_get_type(attr->attach_bpf_fd2, ptype);
>
> could you add a comment to uapi on possible uses of this field
> otherwise the name is not readable.
Yep no problem. I have a couple patches queued up for selftests and
automatically pulling in STREAM_PARSER, along with couple minor other
things so I'll push this update with those.
Thanks,
John
next prev parent reply other threads:[~2017-08-17 18:58 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-16 5:30 [net-next PATCH 00/10] BPF: sockmap and sk redirect support John Fastabend
2017-08-16 5:30 ` [net-next PATCH 01/10] net: early init support for strparser John Fastabend
2017-08-16 5:31 ` [net-next PATCH 02/10] net: add sendmsg_locked and sendpage_locked to af_inet6 John Fastabend
2017-08-16 5:31 ` [net-next PATCH 03/10] net: fixes for skb_send_sock John Fastabend
2017-08-16 5:31 ` [net-next PATCH 04/10] bpf: introduce new program type for skbs on sockets John Fastabend
2017-08-16 5:32 ` [net-next PATCH 05/10] bpf: export bpf_prog_inc_not_zero John Fastabend
2017-08-16 5:32 ` [net-next PATCH 06/10] bpf: sockmap with sk redirect support John Fastabend
2017-08-17 5:40 ` Alexei Starovoitov
2017-08-17 18:58 ` John Fastabend [this message]
2017-08-17 22:28 ` Alexei Starovoitov
2017-08-18 7:35 ` John Fastabend
2017-08-18 18:32 ` Alexei Starovoitov
2017-08-19 3:30 ` John Fastabend
2017-08-19 4:50 ` Alexei Starovoitov
2017-08-19 20:52 ` John Fastabend
2017-08-16 5:33 ` [net-next PATCH 07/10] bpf: add access to sock fields and pkt data from sk_skb programs John Fastabend
2017-08-17 5:42 ` Alexei Starovoitov
2017-08-17 12:40 ` Daniel Borkmann
2017-08-16 5:33 ` [net-next PATCH 08/10] bpf: sockmap sample program John Fastabend
2017-08-16 5:33 ` [net-next PATCH 09/10] bpf: selftests: add tests for new __sk_buff members John Fastabend
2017-08-16 5:34 ` [net-next PATCH 10/10] bpf: selftests add sockmap tests John Fastabend
2017-08-16 15:25 ` [net-next PATCH 00/10] BPF: sockmap and sk redirect support Daniel Borkmann
2017-08-16 18:28 ` David Miller
2017-08-16 18:35 ` David Miller
2017-08-16 19:06 ` John Fastabend
2017-08-16 19:13 ` David Miller
2017-08-16 19:17 ` Eric Dumazet
2017-08-16 19:34 ` John Fastabend
2017-08-16 21:22 ` David Miller
2017-08-16 21:35 ` David Ahern
2017-08-16 21:37 ` John Fastabend
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=5995E738.9090803@gmail.com \
--to=john.fastabend@gmail.com \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
--cc=tom@herbertland.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).