# Re: \[PATCH bpf-next v2 4/8\] xsk: register XDP sockets at bind(), and add new AF\_XDP BPF helper

- From: Alexei Starovoitov \<hidden\>
- Date: 2021-01-20 23:42:48 
- List: netdev
- Page: https://ratatoskr.run/netdev/2021/01/7757919
- Thread: https://ratatoskr.run/netdev/2021/01/7757843/t.md

```text
On Wed, Jan 20, 2021 at 12:26 PM Toke Høiland-Jørgensen [ref] wrote:
>
> This argument, however, I buy: bpf_redirect() is the single-purpose
> helper for redirecting to an ifindex, bpf_redirect_xsk() is the
> single-purpose helper for redirecting to an XSK, and bpf_redirect_map()
> is the generic one that does both of those and more. Fair enough,
> consider me convinced :)
>
> > A lot of back-and-forth for *one* if-statement, but it's kind of a
> > design thing for me. ;-)
>
> Surely you don't mean to imply that you have *better* things to do with
> your time than have a 10-emails-long argument over a single if
> statement? ;)

After reading this thread I think I have to pour cold water on the design.

The performance blip comes from hard coded assumptions:
+ queue_id = xdp->rxq->queue_index;
+ xs = READ_ONCE(dev->_rx[queue_id].xsk);

bpf can have specialized helpers, but imo this is beyond what's reasonable.
Please move such things into the program and try to make
bpf_redirect_map faster.

Making af_xdp non-root is orthogonal. If there is actual need for that
it has to be designed thoroughly and not presented as "this helper may
help to do that".
I don't think "may" will materialize unless people actually work
toward the goal of non-root.
```
