netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: BPF for hash calculation
       [not found] <D6D87E0C-3F64-4552-888B-D1152F062C48@mellanox.com>
@ 2020-05-20  2:35 ` Ariel Levkovich
  0 siblings, 0 replies; only message in thread
From: Ariel Levkovich @ 2020-05-20  2:35 UTC (permalink / raw)
  To: ast, daniel, Jiri Pirko
  Cc: Roni Bar Yanai, Majd Dibbiny, Saeed Mahameed, netdev, bpf

On May 19, 2020, at 22:13, Ariel Levkovich <lariel@mellanox.com> wrote:
> 
> Hi Daniel, Aleksei
> 
> I’m working on a feature to add support for datapath hash actions and matching via TC API.
> 
> One of the options we want to offer users there is to provide their own hash calculation function, in the form of a BPF program.
> The program should accept struct __sk_buff and return a hash value.
> 
> After a little research and testing I noticed that some key parameters in struct __sk_buff are sertricted to BPF_PROG_TYPE_SK_SKB program types while I was planning to re-use the existing  BPF_PROG_TYPE_SCHED_ACT program type for the act_hash purpose.
> The key parameters I’m referring to are fields like remote_ip4, local_ip4, src/dst_port (flow key fields) that are most likely going to be relevant for hash calculation on a packet.
> 
> So my question to you is basically what is the best option here? The way I see it the options are:
> 1. Remove restrictions on these fields for SCHED_ACT program type in kernel/bpf/verifier.c
> 2. Add new program type SCHED_ACT_HASH with permission to access these fields.
> 3. More of a question - is there another way to access the flow keys via struct __sk_buff?
> 
> Appreciate your advice and thanks in advance.
> 
> Best Regards,
> 
> Ariel Levkovich
> Staff engineer, Mellanox SW

Forgot to CC relevant mailing list.
After further digging it seems there’s a pointer to a flow keys struct that is not restricted to SK_SKB prog types and should be our best option. The question remains whether we can reuse SCHED_ACT type or a new type for hash calculation should be added?



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-20  2:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <D6D87E0C-3F64-4552-888B-D1152F062C48@mellanox.com>
2020-05-20  2:35 ` BPF for hash calculation Ariel Levkovich

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).