On Thu, Jul 30, 2020 at 9:45 PM Yoshiki Komachi <komachi.yoshiki@xxxxxxxxx> wrote: > > This patch adds a simple example of XDP-based bridge with the new > bpf_fdb_lookup helper. This program simply forwards packets based > on the destination port given by FDB in the kernel. Note that both > vlan filtering and learning features are currently unsupported in > this example. > > There is another plan to recreate a userspace application > (xdp_bridge_user.c) as a daemon process, which helps to automate > not only detection of status changes in bridge port but also > handling vlan protocol updates. > > Note: David Ahern suggested a new bpf helper [1] to get master > vlan/bonding devices in XDP programs attached to their slaves > when the master vlan/bonding devices are bridge ports. If this > idea is accepted and the helper is introduced in the future, we > can handle interfaces slaved to vlan/bonding devices in this > sample by calling the suggested bpf helper (I guess it can get > vlan/bonding ifindex from their slave ifindex). Notice that we > don't need to change bpf_fdb_lookup() API to use such a feature, > but we just need to modify bpf programs like this sample. > > [1]: http://vger.kernel.org/lpc-networking2018.html#session-1 > > Signed-off-by: Yoshiki Komachi <komachi.yoshiki@xxxxxxxxx> > --- Have you tried using a BPF skeleton for this? It could have saved a bunch of mechanical code for your example. Also libbpf supports map pinning out of the box now, I wonder if it would just work in your case. Also it would be nice if you tried using BPF link-based approach for this example, to show how it can be used. Thanks! > samples/bpf/Makefile | 3 + > samples/bpf/xdp_bridge_kern.c | 129 ++++++++++++++++++ > samples/bpf/xdp_bridge_user.c | 239 ++++++++++++++++++++++++++++++++++ > 3 files changed, 371 insertions(+) > create mode 100644 samples/bpf/xdp_bridge_kern.c > create mode 100644 samples/bpf/xdp_bridge_user.c > [...]