All of lore.kernel.org
 help / color / mirror / Atom feed
* Calculating a hash from a eBPF program?
@ 2017-06-27 20:45 Dan Siemon
  2017-06-27 21:56 ` Daniel Borkmann
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Siemon @ 2017-06-27 20:45 UTC (permalink / raw)
  To: xdp-newbies

[This isn't strictly an XDP question, I'm using cls_bpf but I don't
know of a better place to ask]

Is there a way to calculate a hash of a struct or other data from
within an eBPF program? I need to build a classifier that can hash a
flow encapsulated in protocols like PPPoE or GTP-U. Basically like
cls_flow's use of jhash2 but at a different offset. I looked at the
helpers in bpf.h but don't see anything helpful there.

Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Calculating a hash from a eBPF program?
  2017-06-27 20:45 Calculating a hash from a eBPF program? Dan Siemon
@ 2017-06-27 21:56 ` Daniel Borkmann
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2017-06-27 21:56 UTC (permalink / raw)
  To: Dan Siemon; +Cc: xdp-newbies

On 06/27/2017 10:45 PM, Dan Siemon wrote:
> [This isn't strictly an XDP question, I'm using cls_bpf but I don't
> know of a better place to ask]
>
> Is there a way to calculate a hash of a struct or other data from
> within an eBPF program? I need to build a classifier that can hash a
> flow encapsulated in protocols like PPPoE or GTP-U. Basically like
> cls_flow's use of jhash2 but at a different offset. I looked at the
> helpers in bpf.h but don't see anything helpful there.

Why no implement it inside the BPF prog like it's done here [1]
(the example is XDP but cls_bpf should work just as well)?

There's also a bpf_set_hash(struct __sk_buff *skb, u32 hash)
helper (net-next) for cls_bpf, where you can then use the jhash
result and set it as skb->hash.

   [1] http://lingrok.org/xref/linux-net-next/tools/testing/selftests/bpf/test_l4lb.c#26

> Thanks.
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-27 21:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27 20:45 Calculating a hash from a eBPF program? Dan Siemon
2017-06-27 21:56 ` Daniel Borkmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.