Skip to content

Commit ec9d16b

Browse files
ummakynesdavem330
authored andcommitted
net: bridge: resolve forwarding path for bridge devices
Add .ndo_fill_forward_path for bridge devices. Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e4417d6 commit ec9d16b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

include/linux/netdevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
851851
enum net_device_path_type {
852852
DEV_PATH_ETHERNET = 0,
853853
DEV_PATH_VLAN,
854+
DEV_PATH_BRIDGE,
854855
};
855856

856857
struct net_device_path {

net/bridge/br_device.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,32 @@ static int br_del_slave(struct net_device *dev, struct net_device *slave_dev)
385385
return br_del_if(br, slave_dev);
386386
}
387387

388+
static int br_fill_forward_path(struct net_device_path_ctx *ctx,
389+
struct net_device_path *path)
390+
{
391+
struct net_bridge_fdb_entry *f;
392+
struct net_bridge_port *dst;
393+
struct net_bridge *br;
394+
395+
if (netif_is_bridge_port(ctx->dev))
396+
return -1;
397+
398+
br = netdev_priv(ctx->dev);
399+
f = br_fdb_find_rcu(br, ctx->daddr, 0);
400+
if (!f || !f->dst)
401+
return -1;
402+
403+
dst = READ_ONCE(f->dst);
404+
if (!dst)
405+
return -1;
406+
407+
path->type = DEV_PATH_BRIDGE;
408+
path->dev = dst->br->dev;
409+
ctx->dev = dst->dev;
410+
411+
return 0;
412+
}
413+
388414
static const struct ethtool_ops br_ethtool_ops = {
389415
.get_drvinfo = br_getinfo,
390416
.get_link = ethtool_op_get_link,
@@ -419,6 +445,7 @@ static const struct net_device_ops br_netdev_ops = {
419445
.ndo_bridge_setlink = br_setlink,
420446
.ndo_bridge_dellink = br_dellink,
421447
.ndo_features_check = passthru_features_check,
448+
.ndo_fill_forward_path = br_fill_forward_path,
422449
};
423450

424451
static struct device_type br_type = {

0 commit comments

Comments
 (0)