diff mbox series

[net-next,3/9] net: 8021q: resolve forwarding path for vlan devices

Message ID 20201015011630.2399-4-pablo@netfilter.org
State Superseded
Headers show
Series netfilter: flowtable bridge and vlan enhancements | expand

Commit Message

Pablo Neira Ayuso Oct. 15, 2020, 1:16 a.m. UTC
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 in the IP forwarding going 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 <pablo@netfilter.org>
---
 include/linux/netdevice.h |  7 +++++++
 net/8021q/vlan_dev.c      | 15 +++++++++++++++
 2 files changed, 22 insertions(+)

Comments

kernel test robot Oct. 15, 2020, 7:48 a.m. UTC | #1
Hi Pablo,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Pablo-Neira-Ayuso/netfilter-flowtable-bridge-and-vlan-enhancements/20201015-091818
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 50172733d01c3097b23ac8d45bf1fff72af0ba98
config: riscv-randconfig-s031-20201015 (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.3-rc1-dirty
        # https://github.com/0day-ci/linux/commit/fbe6da32dfe77e080e449951ba7a5d3308938304
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Pablo-Neira-Ayuso/netfilter-flowtable-bridge-and-vlan-enhancements/20201015-091818
        git checkout fbe6da32dfe77e080e449951ba7a5d3308938304
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=riscv 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


"sparse warnings: (new ones prefixed by >>)"
>> net/8021q/vlan_dev.c:776:23: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __be16 [usertype] id @@     got unsigned short [usertype] vlan_id @@
>> net/8021q/vlan_dev.c:776:23: sparse:     expected restricted __be16 [usertype] id
>> net/8021q/vlan_dev.c:776:23: sparse:     got unsigned short [usertype] vlan_id

vim +776 net/8021q/vlan_dev.c

   769	
   770	static int vlan_dev_fill_forward_path(struct net_device_path_ctx *ctx,
   771					      struct net_device_path *path)
   772	{
   773		struct vlan_dev_priv *vlan = vlan_dev_priv(ctx->dev);
   774	
   775		path->type = DEV_PATH_VLAN;
 > 776		path->vlan.id = vlan->vlan_id;
   777		path->vlan.proto = vlan->vlan_proto;
   778		path->dev = ctx->dev;
   779		ctx->dev = vlan->real_dev;
   780	
   781		return 0;
   782	}
   783	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index b77960621c27..6a3370fafe4b 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -835,11 +835,18 @@  typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
 
 enum net_device_path_type {
 	DEV_PATH_ETHERNET = 0,
+	DEV_PATH_VLAN,
 };
 
 struct net_device_path {
 	enum net_device_path_type	type;
 	const struct net_device		*dev;
+	union {
+		struct {
+			__be16		id;
+			__be16		proto;
+		} vlan;
+	};
 };
 
 #define NET_DEVICE_PATH_STACK_MAX	5
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index ec8408d1638f..f06a507557f9 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -767,6 +767,20 @@  static int vlan_dev_get_iflink(const struct net_device *dev)
 	return real_dev->ifindex;
 }
 
+static int vlan_dev_fill_forward_path(struct net_device_path_ctx *ctx,
+				      struct net_device_path *path)
+{
+	struct vlan_dev_priv *vlan = vlan_dev_priv(ctx->dev);
+
+	path->type = DEV_PATH_VLAN;
+	path->vlan.id = vlan->vlan_id;
+	path->vlan.proto = vlan->vlan_proto;
+	path->dev = ctx->dev;
+	ctx->dev = vlan->real_dev;
+
+	return 0;
+}
+
 static const struct ethtool_ops vlan_ethtool_ops = {
 	.get_link_ksettings	= vlan_ethtool_get_link_ksettings,
 	.get_drvinfo	        = vlan_ethtool_get_drvinfo,
@@ -805,6 +819,7 @@  static const struct net_device_ops vlan_netdev_ops = {
 #endif
 	.ndo_fix_features	= vlan_dev_fix_features,
 	.ndo_get_iflink		= vlan_dev_get_iflink,
+	.ndo_fill_forward_path	= vlan_dev_fill_forward_path,
 };
 
 static void vlan_dev_free(struct net_device *dev)