d6bbc77abee631369b1ec2a30ed5eb52072d4037
[openwrt/staging/981213.git] /
1 From: Pablo Neira Ayuso <pablo@netfilter.org>
2 Date: Wed, 24 Mar 2021 02:30:34 +0100
3 Subject: [PATCH] net: bridge: resolve forwarding path for bridge devices
4
5 Add .ndo_fill_forward_path for bridge devices.
6
7 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
8 ---
9
10 --- a/include/linux/netdevice.h
11 +++ b/include/linux/netdevice.h
12 @@ -851,6 +851,7 @@ typedef u16 (*select_queue_fallback_t)(s
13 enum net_device_path_type {
14 DEV_PATH_ETHERNET = 0,
15 DEV_PATH_VLAN,
16 + DEV_PATH_BRIDGE,
17 };
18
19 struct net_device_path {
20 --- a/net/bridge/br_device.c
21 +++ b/net/bridge/br_device.c
22 @@ -398,6 +398,32 @@ static int br_del_slave(struct net_devic
23 return br_del_if(br, slave_dev);
24 }
25
26 +static int br_fill_forward_path(struct net_device_path_ctx *ctx,
27 + struct net_device_path *path)
28 +{
29 + struct net_bridge_fdb_entry *f;
30 + struct net_bridge_port *dst;
31 + struct net_bridge *br;
32 +
33 + if (netif_is_bridge_port(ctx->dev))
34 + return -1;
35 +
36 + br = netdev_priv(ctx->dev);
37 + f = br_fdb_find_rcu(br, ctx->daddr, 0);
38 + if (!f || !f->dst)
39 + return -1;
40 +
41 + dst = READ_ONCE(f->dst);
42 + if (!dst)
43 + return -1;
44 +
45 + path->type = DEV_PATH_BRIDGE;
46 + path->dev = dst->br->dev;
47 + ctx->dev = dst->dev;
48 +
49 + return 0;
50 +}
51 +
52 static const struct ethtool_ops br_ethtool_ops = {
53 .get_drvinfo = br_getinfo,
54 .get_link = ethtool_op_get_link,
55 @@ -432,6 +458,7 @@ static const struct net_device_ops br_ne
56 .ndo_bridge_setlink = br_setlink,
57 .ndo_bridge_dellink = br_dellink,
58 .ndo_features_check = passthru_features_check,
59 + .ndo_fill_forward_path = br_fill_forward_path,
60 };
61
62 static struct device_type br_type = {