1 From: Pablo Neira Ayuso <pablo@netfilter.org>
2 Date: Wed, 24 Mar 2021 02:30:33 +0100
3 Subject: [PATCH] net: 8021q: resolve forwarding path for vlan devices
5 Add .ndo_fill_forward_path for vlan devices.
7 For instance, assuming the following topology:
20 For packets going through IP forwarding to eth0.100 whose destination
21 MAC address is ab:cd:ef:ab:cd:ef, dev_fill_forward_path() provides the
26 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
29 --- a/include/linux/netdevice.h
30 +++ b/include/linux/netdevice.h
31 @@ -843,11 +843,18 @@ typedef u16 (*select_queue_fallback_t)(s
33 enum net_device_path_type {
34 DEV_PATH_ETHERNET = 0,
38 struct net_device_path {
39 enum net_device_path_type type;
40 const struct net_device *dev;
49 #define NET_DEVICE_PATH_STACK_MAX 5
50 --- a/net/8021q/vlan_dev.c
51 +++ b/net/8021q/vlan_dev.c
52 @@ -770,6 +770,20 @@ static int vlan_dev_get_iflink(const str
53 return real_dev->ifindex;
56 +static int vlan_dev_fill_forward_path(struct net_device_path_ctx *ctx,
57 + struct net_device_path *path)
59 + struct vlan_dev_priv *vlan = vlan_dev_priv(ctx->dev);
61 + path->type = DEV_PATH_VLAN;
62 + path->encap.id = vlan->vlan_id;
63 + path->encap.proto = vlan->vlan_proto;
64 + path->dev = ctx->dev;
65 + ctx->dev = vlan->real_dev;
70 static const struct ethtool_ops vlan_ethtool_ops = {
71 .get_link_ksettings = vlan_ethtool_get_link_ksettings,
72 .get_drvinfo = vlan_ethtool_get_drvinfo,
73 @@ -808,6 +822,7 @@ static const struct net_device_ops vlan_
75 .ndo_fix_features = vlan_dev_fix_features,
76 .ndo_get_iflink = vlan_dev_get_iflink,
77 + .ndo_fill_forward_path = vlan_dev_fill_forward_path,
80 static void vlan_dev_free(struct net_device *dev)