Yoshiki Komachi
2020-Aug-04 11:27 UTC
[Bridge] [RFC PATCH bpf-next 2/3] bpf: Add helper to do forwarding lookups in kernel FDB table
> 2020/08/01 2:15?David Ahern <dsahern at gmail.com>????: > > On 7/30/20 10:44 PM, Yoshiki Komachi wrote: >> diff --git a/net/core/filter.c b/net/core/filter.c >> index 654c346b7d91..68800d1b8cd5 100644 >> --- a/net/core/filter.c >> +++ b/net/core/filter.c >> @@ -5084,6 +5085,46 @@ static const struct bpf_func_proto bpf_skb_fib_lookup_proto = { >> .arg4_type = ARG_ANYTHING, >> }; >> >> +#if IS_ENABLED(CONFIG_BRIDGE) >> +BPF_CALL_4(bpf_xdp_fdb_lookup, struct xdp_buff *, ctx, >> + struct bpf_fdb_lookup *, params, int, plen, u32, flags) >> +{ >> + struct net_device *src, *dst; >> + struct net *net; >> + >> + if (plen < sizeof(*params)) >> + return -EINVAL; > > I need to look at the details more closely, but on first reading 2 > things caught me eye: > 1. you need to make sure flags is 0 since there are no supported flags > at the moment, andThanks for your initial comments! I will make sure whether this flag is required or not.>> + >> + net = dev_net(ctx->rxq->dev); >> + >> + if (is_multicast_ether_addr(params->addr) || >> + is_broadcast_ether_addr(params->addr)) >> + return BPF_FDB_LKUP_RET_NOENT; >> + >> + src = dev_get_by_index_rcu(net, params->ifindex); >> + if (unlikely(!src)) >> + return -ENODEV; >> + >> + dst = br_fdb_find_port_xdp(src, params->addr, params->vlan_id); > > 2. this needs to be done via netdev ops to avoid referencing bridge code > which can be compiled as a module. I suspect the build robots will id > this part soon.I guess that no build errors will occur because the API is allowed when CONFIG_BRIDGE is enabled. I successfully build my kernel applying this patch, and I don?t receive any messages from build robots for now. Thanks & Best regards, ? Yoshiki Komachi komachi.yoshiki at gmail.com
David Ahern
2020-Aug-05 16:38 UTC
[Bridge] [RFC PATCH bpf-next 2/3] bpf: Add helper to do forwarding lookups in kernel FDB table
On 8/4/20 5:27 AM, Yoshiki Komachi wrote:> > I guess that no build errors will occur because the API is allowed when > CONFIG_BRIDGE is enabled. > > I successfully build my kernel applying this patch, and I don?t receive any > messages from build robots for now.If CONFIG_BRIDGE is a module, build should fail: filter.c is built-in trying to access a symbol from module.