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: Sat, 19 Aug 2017 13:52:16 -0700 [thread overview]
Message-ID: <5998A500.8090407@gmail.com> (raw)
In-Reply-To: <5e3248bf-1951-5859-8cfb-4fdb641dcc41@fb.com>
On 08/18/2017 09:50 PM, Alexei Starovoitov wrote:
> On 8/18/17 8:30 PM, John Fastabend wrote:
>> So this is really close to what I proposed above. For a TX_SOCKMAP
>> simply do not attach any programs,
>>
>> bpf_create_map(BPF_MAP_TYPE_SOCKMAP, .... )
>> [...]
>>
>> For an RX_SOCKMAP,
>>
>> bpf_create_map(BPF_MAP_TYPE_SOCKMAP, .... )
>> bpf_prog_attach(verdict_prog, map_fd, BPF_SMAP_STREAM_VERDICT, 0);
>> bpf_prog_attach(parse_prog, map_fd, BPF_SMAP_STREAM_PARSER, 0);
>>
>> With the new attach type (compared to the fd2 thing before) we can easily
>> extend maps to contain other program types as needed. So in the future
>> we might have TX_SOCKMAP, RX_SOCKMAP, FOO_SOCKMAP, ...
>
> agree. that sounds as good generalization.
>
>> I don't see the need to have the API enforce the map type via update
>> specifiers bpf_{rx|tx}_sock_map_update. The programmer should "know"
>> the type by virtue of the programs attached. This is more flexible
>> as well because it allows a map to be TX only, RX only or TX/RX.
>
> makes sense. good point.
>
>> With this proposal we can relax the restriction where a sock can only
>> be in a single map and even allow a sock to be in the same map multiple
>> times. The limitation we do have to enforce is allowing a sock in the
>> a map with different BPF_SMAP_STREAM_* programs. But I think this
>> should be clear to the programmer (with good tracing functions and
>> error codes).
>>
>> Slight aside: but by creating map size of 1 we have an object that
>> contains programs and later we can attach a sock to it, looks like
>> the following,
>>
>> create_map(BPF_MAP_TYPE_SOCKMAP,...)
>> bpf_prog_attach(...)
>> [...]
>> bpf_update_map_elem(fd, map, key, flags)
>>
>> I think this is very close to your first approach where you suggested
>> a program container object.
>
> yep.
>
>>> Or you have cases when two RX sockets need to redirect into each
>>> other and in both cases strparser+verdict need to run?
>> If we don't do rx, tx restrictions and use my suggestion here we
>> don't have this limitation. OR because we allow socks in multiple
>> maps now the user can simply put the sockets in different maps.
>
> agree. good point as well.
>
>>> In such case we need to allow bpf_sk_redirect_map() to use on
>>> RX_SOCKMAP map as well,
>>> but looking at current implementation you only allow one psock per map,
>>> so two sockets forwarding to each other cannot work due to only one queue.
>>> Am I missing anything from what you want to achieve?
>> I don't think so. But lets get rid of the one psock per map, I took a shot
>> at relaxing that today and was able to get it with a refcount on the psock
>> which seems to work OK.
>
> +1
>
>> Also reorganizing the psock structure into clear sections tx_psock, rx_psock,
>> general_psock will probably help readers.
>
> nice. thanks!
>
>>> Thoughts?
>>>
>> What do you think of my counter proposal I started coding it up and it
>> actually (other than pushing code snippets around) seems to work out
>> nicely with the existing code base. I think it is really a nice improvement.
>
> ok. I think we're mostly on the same page and patches will
> either bring us to the full agreement or show where we disagree :)
I'll work up the patches Monday/Tuesday and we should have plenty of time to
work out any kinks. The bit I did Friday makes me think the changes to support
this should be straight forward.
Thanks,
John
next prev parent reply other threads:[~2017-08-19 20:52 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
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 [this message]
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=5998A500.8090407@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).