Skip to content

Commit e4417d6

Browse files
ummakynesdavem330
authored andcommitted
net: 8021q: resolve forwarding path for vlan devices
Add .ndo_fill_forward_path for vlan devices. For instance, assuming the following topology: IP forwarding / \ eth0.100 eth0 | eth0 . . . ethX ab:cd:ef:ab:cd:ef For packets going through IP forwarding to eth0.100 whose destination MAC address is ab:cd:ef:ab:cd:ef, dev_fill_forward_path() provides the following path: eth0.100 -> eth0 Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ddb94ea commit e4417d6

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

include/linux/netdevice.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,11 +850,18 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
850850

851851
enum net_device_path_type {
852852
DEV_PATH_ETHERNET = 0,
853+
DEV_PATH_VLAN,
853854
};
854855

855856
struct net_device_path {
856857
enum net_device_path_type type;
857858
const struct net_device *dev;
859+
union {
860+
struct {
861+
u16 id;
862+
__be16 proto;
863+
} encap;
864+
};
858865
};
859866

860867
#define NET_DEVICE_PATH_STACK_MAX 5

net/8021q/vlan_dev.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,20 @@ static int vlan_dev_get_iflink(const struct net_device *dev)
776776
return real_dev->ifindex;
777777
}
778778

779+
static int vlan_dev_fill_forward_path(struct net_device_path_ctx *ctx,
780+
struct net_device_path *path)
781+
{
782+
struct vlan_dev_priv *vlan = vlan_dev_priv(ctx->dev);
783+
784+
path->type = DEV_PATH_VLAN;
785+
path->encap.id = vlan->vlan_id;
786+
path->encap.proto = vlan->vlan_proto;
787+
path->dev = ctx->dev;
788+
ctx->dev = vlan->real_dev;
789+
790+
return 0;
791+
}
792+
779793
static const struct ethtool_ops vlan_ethtool_ops = {
780794
.get_link_ksettings = vlan_ethtool_get_link_ksettings,
781795
.get_drvinfo = vlan_ethtool_get_drvinfo,
@@ -814,6 +828,7 @@ static const struct net_device_ops vlan_netdev_ops = {
814828
#endif
815829
.ndo_fix_features = vlan_dev_fix_features,
816830
.ndo_get_iflink = vlan_dev_get_iflink,
831+
.ndo_fill_forward_path = vlan_dev_fill_forward_path,
817832
};
818833

819834
static void vlan_dev_free(struct net_device *dev)

0 commit comments

Comments
 (0)