Skip to contentSkip to conversation

Bare UDP L3 Encapsulation Module

PATCH Superseded Martin Varghese 3 participants 10 messages Jan 21, 2020 – Jan 24, 2020

Subsystems (4)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v4 cover Bare UDP L3 Encapsulation Module

From: Martin Varghese <[email protected]>

There are various L3 encapsulation standards using UDP being discussed to leverage the UDP based load balancing capability of different networks. MPLSoUDP (__ https://tools.ietf.org/html/rfc7510) is one among them.

The Bareudp tunnel module provides a generic L3 encapsulation tunnelling support for tunnelling different L3 protocols like MPLS, IP, NSH etc. inside a UDP tunnel.

Special Handling
----------------
The bareudp device supports special handling for MPLS & IP as they can have multiple ethertypes.
MPLS procotcol can have ethertypes ETH_P_MPLS_UC (unicast) & ETH_P_MPLS_MC (multicast). IP protocol can have ethertypes ETH_P_IP (v4) & ETH_P_IPV6 (v6).
This special handling can be enabled only for ethertypes ETH_P_IP & ETH_P_MPLS_UC with a flag called multiproto mode.

Usage
------

1) Device creation & deletion

a) ip link add dev bareudp0 type bareudp dstport 6635 ethertype 0x8847.

This creates a bareudp tunnel device which tunnels L3 traffic with ethertype 0x8847 (MPLS traffic). The destination port of the UDP header will be set to 6635.The device will listen on UDP port 6635 to receive traffic.

b) ip link delete bareudp0

2) Device creation with multiple proto mode enabled

There are two ways to create a bareudp device for MPLS & IP with multiproto mode enabled.

a) ip link add dev bareudp0 type bareudp dstport 6635 ethertype 0x8847 multiproto

b) ip link add dev bareudp0 type bareudp dstport 6635 ethertype mpls

3) Device Usage

The bareudp device could be used along with OVS or flower filter in TC. The OVS or TC flower layer must set the tunnel information in SKB dst field before sending packet buffer to the bareudp device for transmission. On reception the bareudp device extracts and stores the tunnel information in SKB dst field before passing the packet buffer to the network stack.

Why not FOU ?
------------
FOU by design does l4 encapsulation.It maps udp port to ipproto (IP protocol number for l4 protocol).

Bareudp acheives a generic l3 encapsulation.It maps udp port to l3 ethertype

Martin Varghese (2):
net: UDP tunnel encapsulation module for tunnelling different
protocols like MPLS,IP,NSH etc.
net: Special handling for IP & MPLS.

 Documentation/networking/bareudp.rst |  53 +++
 Documentation/networking/index.rst   |   1 +
 drivers/net/Kconfig                  |  13 +
 drivers/net/Makefile                 |   1 +
 drivers/net/bareudp.c                | 801 +++++++++++++++++++++++++++++++++++
 include/net/bareudp.h                |  20 +
 include/net/ip6_tunnel.h             |  50 +++
 include/net/ip_tunnels.h             |  47 ++
 include/uapi/linux/if_link.h         |  12 +
 9 files changed, 998 insertions(+)
 create mode 100644 Documentation/networking/bareudp.rst
 create mode 100644 drivers/net/bareudp.c
 create mode 100644 include/net/bareudp.h
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v4 1/2 net: UDP tunnel encapsulation module for

From: Martin Varghese <[email protected]>

The Bareudp tunnel module provides a generic L3 encapsulation tunnelling module for tunnelling different protocols like MPLS, IP,NSH etc inside a UDP tunnel.

---
Changes in v2:
- Fixed documentation errors.
- Converted documentation to rst format.
- Moved ip tunnel rt lookup code to a common location.
- Removed seperate v4 and v6 socket.
- Added call to skb_ensure_writable before updating ethernet header.
- Simplified bareudp_destroy_tunnels as deleting devices under a namespace is taken care be the default pernet exit code.
- Fixed bareudp_change_mtu.

Changes in v3:
- Re-sending the patch again.

Changes in v4:
- Converted bareudp device to l3 device.
- Removed redundant fields in bareudp device.

 Documentation/networking/bareudp.rst |  35 ++
 Documentation/networking/index.rst   |   1 +
 drivers/net/Kconfig                  |  13 +
 drivers/net/Makefile                 |   1 +
 drivers/net/bareudp.c                | 741 +++++++++++++++++++++++++++++++++++
 include/net/bareudp.h                |  19 +
 include/net/ip6_tunnel.h             |  50 +++
 include/net/ip_tunnels.h             |  47 +++
 include/uapi/linux/if_link.h         |  11 +
 9 files changed, 918 insertions(+)
 create mode 100644 Documentation/networking/bareudp.rst
 create mode 100644 drivers/net/bareudp.c
 create mode 100644 include/net/bareudp.h
Documentation/networking/bareudp.rst new file +35 -0
new file mode 100644
index 0000000..4087a1b
@@ -0,0 +1,35 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+========================================
+Bare UDP Tunnelling Module Documentation
+========================================
+
+There are various L3 encapsulation standards using UDP being discussed to
+leverage the UDP based load balancing capability of different networks.
+MPLSoUDP (__ https://tools.ietf.org/html/rfc7510) is one among them.
+
+The Bareudp tunnel module provides a generic L3 encapsulation tunnelling
+support for tunnelling different L3 protocols like MPLS, IP, NSH etc. inside
+a UDP tunnel.
+
+Usage
+------
+
+1) Device creation & deletion
+
+    a) ip link add dev bareudp0 type bareudp dstport 6635 ethertype 0x8847.
+
+       This creates a bareudp tunnel device which tunnels L3 traffic with ethertype
+       0x8847 (MPLS traffic). The destination port of the UDP header will be set to
+       6635.The device will listen on UDP port 6635 to receive traffic.
+
+    b) ip link delete bareudp0
+
+2) Device Usage
+
+The bareudp device could be used along with OVS or flower filter in TC.
+The OVS or TC flower layer must set the tunnel information in SKB dst field before
+sending packet buffer to the bareudp device for transmission. On reception the
+bareudp device extracts and stores the tunnel information in SKB dst field before
+passing the packet buffer to the network stack.
+
Documentation/networking/index.rst +1 -0
index d07d985..ea3d604 100644
@@ -33,6 +33,7 @@ Contents:
    tls
    tls-offload
    nfc
+   bareudp
 
 .. only::  subproject and html
 
drivers/net/Kconfig +13 -0
index dee7958..9726447 100644
@@ -258,6 +258,19 @@ config GENEVE
 	  To compile this driver as a module, choose M here: the module
 	  will be called geneve.
 
+config BAREUDP
+       tristate "Bare UDP Encapsulation"
+       depends on INET && NET_UDP_TUNNEL
+       depends on IPV6 || !IPV6
+       select NET_IP_TUNNEL
+       select GRO_CELLS
+       help
+          This adds a bare UDP tunnel module for tunnelling different
+          kinds of traffic like MPLS, IP, etc. inside a UDP tunnel.
+
+          To compile this driver as a module, choose M here: the module
+          will be called bareudp.
+
 config GTP
 	tristate "GPRS Tunneling Protocol datapath (GTP-U)"
 	depends on INET
drivers/net/Makefile +1 -0
index 953b7c1..567b1aa49 100644
@@ -29,6 +29,7 @@ obj-$(CONFIG_VETH) += veth.o
 obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
 obj-$(CONFIG_VXLAN) += vxlan.o
 obj-$(CONFIG_GENEVE) += geneve.o
+obj-$(CONFIG_BAREUDP) += bareudp.o
 obj-$(CONFIG_GTP) += gtp.o
 obj-$(CONFIG_NLMON) += nlmon.o
 obj-$(CONFIG_NET_VRF) += vrf.o
drivers/net/bareudp.c new file +741 -0

741 lines not on this page · raw message

include/net/bareudp.h new file +19 -0
new file mode 100644
index 0000000..513fae6
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __NET_BAREUDP_H
+#define __NET_BAREUDP_H
+
+#include <linux/types.h>
+#include <linux/skbuff.h>
+
+struct bareudp_conf {
+	__be16 ethertype;
+	__be16 port;
+	u16 sport_min;
+};
+
+struct net_device *bareudp_dev_create(struct net *net, const char *name,
+				      u8 name_assign_type,
+				      struct bareudp_conf *info);
+
+#endif
include/net/ip6_tunnel.h +50 -0

55 lines not on this page · raw message

include/net/ip_tunnels.h +47 -0

53 lines not on this page · raw message

include/uapi/linux/if_link.h +11 -0
index 024af2d..fb4b33a 100644
@@ -590,6 +590,17 @@ enum ifla_geneve_df {
 	GENEVE_DF_MAX = __GENEVE_DF_END - 1,
 };
 
+/* Bareudp section  */
+enum {
+	IFLA_BAREUDP_UNSPEC,
+	IFLA_BAREUDP_PORT,
+	IFLA_BAREUDP_ETHERTYPE,
+	IFLA_BAREUDP_SRCPORT_MIN,
+	__IFLA_BAREUDP_MAX
+};
+
+#define IFLA_BAREUDP_MAX (__IFLA_BAREUDP_MAX - 1)
+
 /* PPP section */
 enum {
 	IFLA_PPP_UNSPEC,
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [PATCH net-next v4 1/2] net: UDP tunnel encapsulation module for

Quoted 8 lines · Martin Varghese

From: Martin Varghese <[email protected]>

The Bareudp tunnel module provides a generic L3 encapsulation tunnelling module for tunnelling different protocols like MPLS, IP,NSH etc inside a UDP tunnel.

This addresses the main points I raised. A few small points below, nothing serious. It could use more eye balls, but beyond those Acked from me.

Quoted 11 lines

---
Changes in v2:
- Fixed documentation errors.
- Converted documentation to rst format.
- Moved ip tunnel rt lookup code to a common location.
- Removed seperate v4 and v6 socket.
- Added call to skb_ensure_writable before updating ethernet header.
- Simplified bareudp_destroy_tunnels as deleting devices under a namespace is taken care be the default pernet exit code.
- Fixed bareudp_change_mtu.

Quoted 5 lines

Changes in v3:
- Re-sending the patch again.

Changes in v4:
- Converted bareudp device to l3 device.

I didn't quite get this statement, but it encompasses the change to ARPHRD_NONE and introduction of gro_cells, I guess?

Documentation/networking/index.rst Contents: · line 36

Quoted 11 lines

- Removed redundant fields in bareudp device.

Documentation/networking/index.rst +1 -0
index d07d985..ea3d604 100644
@@ -33,6 +33,7 @@ Contents:
    tls
    tls-offload
    nfc
+   bareudp

if respinning: this list is mostly alphabetically ordened, perhaps insert before batman-adv

Quoted 5 lines
drivers/net/Kconfig +0 -0
index dee7958..9726447 100644

drivers/net/Kconfig config GENEVE · line 266

Quoted 9 lines
drivers/net/Kconfig +6 -0
@@ -258,6 +258,19 @@ config GENEVE
          To compile this driver as a module, choose M here: the module
          will be called geneve.
 
+config BAREUDP
+       tristate "Bare UDP Encapsulation"
+       depends on INET && NET_UDP_TUNNEL
+       depends on IPV6 || !IPV6
+       select NET_IP_TUNNEL
+       select GRO_CELLS

Depends on NET_UDP_TUNNEL plus selects NET_IP_TUNNEL seems odd.

NET_UDP_TUNNEL itself selects NET_IP_TUNNEL, so perhaps just select NET_UDP_TUNNEL.

I had to make that change to be able to get it in a .config after make defconfig.

drivers/net/Kconfig config GENEVE · line 271

Quoted 5 lines
drivers/net/Kconfig +5 -0
+static int bareudp_change_mtu(struct net_device *dev, int new_mtu)
+{
+       dev->mtu = new_mtu;
+       return 0;
+}

If your ndo_change_mtu does nothing special, it can just rely on the assignment in __dev_set_mtu

Quoted 4 lines
drivers/net/Kconfig +4 -0
+/* Initialize the device structure. */
+static void bareudp_setup(struct net_device *dev)
+{
+       dev->netdev_ops = &bareudp_netdev_ops;

drivers/net/Kconfig config GENEVE

Quoted 10 lines
drivers/net/Kconfig +10 -0
+       dev->needs_free_netdev = true;
+       SET_NETDEV_DEVTYPE(dev, &bareudp_type);
+       dev->features    |= NETIF_F_SG | NETIF_F_HW_CSUM;
+       dev->features    |= NETIF_F_RXCSUM;
+       dev->features    |= NETIF_F_GSO_SOFTWARE;
+       dev->hw_features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
+       dev->hw_features |= NETIF_F_GSO_SOFTWARE;
+       dev->hard_header_len = 0;
+       dev->addr_len = 0;
+       dev->mtu = 1500;

ETH_DATA_LEN?

#3 lore raw

Re: [PATCH net-next v4 1/2] net: UDP tunnel encapsulation module for

Quoted 26 lines · Willem de Bruijn
Quoted 8 lines · Martin Varghese

From: Martin Varghese <[email protected]>

The Bareudp tunnel module provides a generic L3 encapsulation tunnelling module for tunnelling different protocols like MPLS, IP,NSH etc inside a UDP tunnel.

This addresses the main points I raised. A few small points below, nothing serious. It could use more eye balls, but beyond those Acked from me.

Quoted 11 lines

---
Changes in v2:
- Fixed documentation errors.
- Converted documentation to rst format.
- Moved ip tunnel rt lookup code to a common location.
- Removed seperate v4 and v6 socket.
- Added call to skb_ensure_writable before updating ethernet header.
- Simplified bareudp_destroy_tunnels as deleting devices under a namespace is taken care be the default pernet exit code.
- Fixed bareudp_change_mtu.

Quoted 9 lines
Quoted 5 lines

Changes in v3:
- Re-sending the patch again.

Changes in v4:
- Converted bareudp device to l3 device.

I didn't quite get this statement, but it encompasses the change to ARPHRD_NONE and introduction of gro_cells, I guess?

The term l3 device is from OVS may be.What i meant is we no longer needed the dummy ethernet header and the device works with l3 packet.

Quoted 32 lines

Documentation/networking/index.rst Contents: · line 36

Quoted 11 lines

- Removed redundant fields in bareudp device.

Documentation/networking/index.rst +1 -0
index d07d985..ea3d604 100644
@@ -33,6 +33,7 @@ Contents:
    tls
    tls-offload
    nfc
+   bareudp

if respinning: this list is mostly alphabetically ordened, perhaps insert before batman-adv

Quoted 5 lines
drivers/net/Kconfig +0 -0
index dee7958..9726447 100644

drivers/net/Kconfig config GENEVE · line 266

Quoted 9 lines
drivers/net/Kconfig +6 -0
@@ -258,6 +258,19 @@ config GENEVE
          To compile this driver as a module, choose M here: the module
          will be called geneve.
 
+config BAREUDP
+       tristate "Bare UDP Encapsulation"
+       depends on INET && NET_UDP_TUNNEL
+       depends on IPV6 || !IPV6
+       select NET_IP_TUNNEL
+       select GRO_CELLS

Depends on NET_UDP_TUNNEL plus selects NET_IP_TUNNEL seems odd.

Quoted 7 lines

NET_UDP_TUNNEL itself selects NET_IP_TUNNEL, so perhaps just select NET_UDP_TUNNEL.

I had to make that change to be able to get it in a .config after make defconfig.

Noted

Quoted 9 lines

drivers/net/Kconfig config GENEVE · line 271

Quoted 5 lines
drivers/net/Kconfig +5 -0
+static int bareudp_change_mtu(struct net_device *dev, int new_mtu)
+{
+       dev->mtu = new_mtu;
+       return 0;
+}

If your ndo_change_mtu does nothing special, it can just rely on the assignment in __dev_set_mtu

Yes we could remove the ndo_change_mtu implementation as it is redundant But i would like to retain bareudp_change_mtu and also to add a validation code in the function as no validation is done in the rtnetlink layer during newlink create

Quoted 8 lines
Quoted 8 lines
drivers/net/Kconfig +8 -0
+/* Initialize the device structure. */
+static void bareudp_setup(struct net_device *dev)
+{
+       dev->netdev_ops = &bareudp_netdev_ops;
+       dev->needs_free_netdev = true;
+       SET_NETDEV_DEVTYPE(dev, &bareudp_type);
+       dev->features    |= NETIF_F_SG | NETIF_F_HW_CSUM;
+       dev->features    |= NETIF_F_RXCSUM;
Quoted 8 lines

drivers/net/Kconfig

Quoted 6 lines
drivers/net/Kconfig +6 -0
+       dev->features    |= NETIF_F_GSO_SOFTWARE;
+       dev->hw_features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
+       dev->hw_features |= NETIF_F_GSO_SOFTWARE;
+       dev->hard_header_len = 0;
+       dev->addr_len = 0;
+       dev->mtu = 1500;

ETH_DATA_LEN?

Noted

Thanks for your time.The code look really better from the v1 version.

#4 lore raw

Re: [PATCH net-next v4 1/2] net: UDP tunnel encapsulation module for

In reply to Willem de Bruijn
Quoted 74 lines · Willem de Bruijn
Quoted 8 lines · Martin Varghese

From: Martin Varghese <[email protected]>

The Bareudp tunnel module provides a generic L3 encapsulation tunnelling module for tunnelling different protocols like MPLS, IP,NSH etc inside a UDP tunnel.

This addresses the main points I raised. A few small points below, nothing serious. It could use more eye balls, but beyond those Acked from me.

Quoted 11 lines

---
Changes in v2:
- Fixed documentation errors.
- Converted documentation to rst format.
- Moved ip tunnel rt lookup code to a common location.
- Removed seperate v4 and v6 socket.
- Added call to skb_ensure_writable before updating ethernet header.
- Simplified bareudp_destroy_tunnels as deleting devices under a namespace is taken care be the default pernet exit code.
- Fixed bareudp_change_mtu.

Quoted 5 lines

Changes in v3:
- Re-sending the patch again.

Changes in v4:
- Converted bareudp device to l3 device.

I didn't quite get this statement, but it encompasses the change to ARPHRD_NONE and introduction of gro_cells, I guess?

Documentation/networking/index.rst Contents: · line 36

Quoted 11 lines

- Removed redundant fields in bareudp device.

Documentation/networking/index.rst +1 -0
index d07d985..ea3d604 100644
@@ -33,6 +33,7 @@ Contents:
    tls
    tls-offload
    nfc
+   bareudp

if respinning: this list is mostly alphabetically ordened, perhaps insert before batman-adv

Quoted 5 lines
drivers/net/Kconfig +0 -0
index dee7958..9726447 100644

drivers/net/Kconfig config GENEVE · line 266

Quoted 9 lines
drivers/net/Kconfig +6 -0
@@ -258,6 +258,19 @@ config GENEVE
          To compile this driver as a module, choose M here: the module
          will be called geneve.
 
+config BAREUDP
+       tristate "Bare UDP Encapsulation"
+       depends on INET && NET_UDP_TUNNEL
+       depends on IPV6 || !IPV6
+       select NET_IP_TUNNEL
+       select GRO_CELLS

Depends on NET_UDP_TUNNEL plus selects NET_IP_TUNNEL seems odd.

NET_UDP_TUNNEL itself selects NET_IP_TUNNEL, so perhaps just select NET_UDP_TUNNEL.

I had to make that change to be able to get it in a .config after make defconfig.

Quoted 9 lines

drivers/net/Kconfig config GENEVE · line 271

Quoted 5 lines
drivers/net/Kconfig +5 -0
+static int bareudp_change_mtu(struct net_device *dev, int new_mtu)
+{
+       dev->mtu = new_mtu;
+       return 0;
+}

If your ndo_change_mtu does nothing special, it can just rely on the assignment in __dev_set_mtu

yes.
we could set dev_set_mtu in all the cases.ignore my previous reply

Quoted 16 lines
Quoted 4 lines
drivers/net/Kconfig +4 -0
+/* Initialize the device structure. */
+static void bareudp_setup(struct net_device *dev)
+{
+       dev->netdev_ops = &bareudp_netdev_ops;

drivers/net/Kconfig config GENEVE

Quoted 10 lines
drivers/net/Kconfig +10 -0
+       dev->needs_free_netdev = true;
+       SET_NETDEV_DEVTYPE(dev, &bareudp_type);
+       dev->features    |= NETIF_F_SG | NETIF_F_HW_CSUM;
+       dev->features    |= NETIF_F_RXCSUM;
+       dev->features    |= NETIF_F_GSO_SOFTWARE;
+       dev->hw_features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
+       dev->hw_features |= NETIF_F_GSO_SOFTWARE;
+       dev->hard_header_len = 0;
+       dev->addr_len = 0;
+       dev->mtu = 1500;

ETH_DATA_LEN?

#5 lore raw

Re: [PATCH net-next v4 1/2] net: UDP tunnel encapsulation module for

In reply to Martin Varghese
Thank you for the patch! Perhaps something to improve:

Hi Martin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on net/master linus/master v5.5-rc7 next-20200123] [cannot apply to ipvs/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Martin-Varghese/Bare-UDP-L3-Encapsulation-Module/20200124-103044
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 9bbc8be29d66cc34b650510f2c67b5c55235fe5d
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.5.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=sh

If you fix the issue, kindly add following tag

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

drivers//net/bareudp.c: In function 'bareudp_fill_metadata_dst':

>> drivers//net/bareudp.c:455:9: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return ret;
            ^~~

vim +/ret +455 drivers//net/bareudp.c

413
414 static int bareudp_fill_metadata_dst(struct net_device *dev,
415 struct sk_buff *skb)
416 {
417 struct ip_tunnel_info *info = skb_tunnel_info(skb);
418 struct bareudp_dev *bareudp = netdev_priv(dev);
419 bool use_cache = ip_tunnel_dst_cache_usable(skb, info);
420 int ret;
421
422 if (ip_tunnel_info_af(info) == AF_INET) {
423 struct rtable *rt;
424 struct flowi4 fl4;
425
426 rt = iptunnel_get_rt(skb, dev, bareudp->net, &fl4, info,
427 use_cache);
428 if (IS_ERR(rt))
429 return PTR_ERR(rt);
430
431 ip_rt_put(rt);
432 info->key.u.ipv4.src = fl4.saddr;
433 #if IS_ENABLED(CONFIG_IPV6)
434 } else if (ip_tunnel_info_af(info) == AF_INET6) {
435 struct dst_entry *dst;
436 struct flowi6 fl6;
437 struct socket *sock = rcu_dereference(bareudp->sock);
438
439 dst = ip6tunnel_get_dst(skb, dev, bareudp->net, sock, &fl6,
440 info, use_cache);
441 if (IS_ERR(dst))
442 return PTR_ERR(dst);
443
444 dst_release(dst);
445 info->key.u.ipv6.src = fl6.saddr;
446 #endif
447 } else {
448 return -EINVAL;
449 }
450
451 info->key.tp_src = udp_flow_src_port(bareudp->net, skb,
452 bareudp->sport_min,
453 USHRT_MAX, true);
454 info->key.tp_dst = bareudp->port;

 > 455		return ret;

456 }
457

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation

#6 lore raw

Re: [PATCH net-next v4 1/2] net: UDP tunnel encapsulation module for

In reply to Martin Varghese
Thank you for the patch! Perhaps something to improve:

Hi Martin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on net/master linus/master v5.5-rc7 next-20200122] [cannot apply to ipvs/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Martin-Varghese/Bare-UDP-L3-Encapsulation-Module/20200124-103044
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 9bbc8be29d66cc34b650510f2c67b5c55235fe5d
config: openrisc-randconfig-a001-20200124 (attached as .config)
compiler: or1k-linux-gcc (GCC) 9.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=openrisc

If you fix the issue, kindly add following tag

All warnings (new ones prefixed by >>):

In file included from net/ipv4/ip_tunnel_core.c:27:
include/net/ip6_tunnel.h: In function 'ip6tunnel_get_dst':
include/net/ip6_tunnel.h:195:9: error: implicit declaration of function 'dst_cache_get_ip6'; did you mean 'dst_cache_get_ip4'? [-Werror=implicit-function-declaration]

     195 |   dst = dst_cache_get_ip6(dst_cache, &fl6->saddr);
         |         ^~~~~~~~~~~~~~~~~
         |         dst_cache_get_ip4
>> include/net/ip6_tunnel.h:195:7: warning: assignment to 'struct dst_entry *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     195 |   dst = dst_cache_get_ip6(dst_cache, &fl6->saddr);
         |       ^
   include/net/ip6_tunnel.h:213:3: error: implicit declaration of function 'dst_cache_set_ip6'; did you mean 'dst_cache_set_ip4'? [-Werror=implicit-function-declaration]
     213 |   dst_cache_set_ip6(dst_cache, dst, &fl6->saddr);
         |   ^~~~~~~~~~~~~~~~~
         |   dst_cache_set_ip4

cc1: some warnings being treated as errors

vim +195 include/net/ip6_tunnel.h

168
169 static inline struct dst_entry *ip6tunnel_get_dst(struct sk_buff *skb,

   170							  struct net_device *dev,
   171							  struct net *net,
   172							  struct socket *sock,
   173							  struct flowi6 *fl6,
   174							  const struct ip_tunnel_info *info,
   175							  bool use_cache)
   176	{
   177		struct dst_entry *dst = NULL;
   178	#ifdef CONFIG_DST_CACHE
   179		struct dst_cache *dst_cache;
   180	#endif
   181		__u8 prio;
   182	
   183		memset(fl6, 0, sizeof(*fl6));
   184		fl6->flowi6_mark = skb->mark;
   185		fl6->flowi6_proto = IPPROTO_UDP;
   186		fl6->daddr = info->key.u.ipv6.dst;
   187		fl6->saddr = info->key.u.ipv6.src;
   188		prio = info->key.tos;
   189	
   190		fl6->flowlabel = ip6_make_flowinfo(RT_TOS(prio),
   191						   info->key.label);
   192	#ifdef CONFIG_DST_CACHE
   193		dst_cache = (struct dst_cache *)&info->dst_cache;
   194		if (use_cache) {
 > 195			dst = dst_cache_get_ip6(dst_cache, &fl6->saddr);

196 if (dst)
197 return dst;
198 }
199 #endif
200 dst = ipv6_stub->ipv6_dst_lookup_flow(net, sock->sk, fl6,
201 NULL);
202 if (IS_ERR(dst)) {
203 netdev_dbg(dev, "no route to %pI6\n", &fl6->daddr);
204 return ERR_PTR(-ENETUNREACH);
205 }
206 if (dst->dev == dev) { /* is this necessary? */
207 netdev_dbg(dev, "circular route to %pI6\n", &fl6->daddr);
208 dst_release(dst);
209 return ERR_PTR(-ELOOP);
210 }
211 #ifdef CONFIG_DST_CACHE
212 if (use_cache)
213 dst_cache_set_ip6(dst_cache, dst, &fl6->saddr);
214 #endif
215 return dst;
216 }
217

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation

#7 lore raw

PATCH v4 2/2 net: Special handling for IP & MPLS.

In reply to Martin Varghese

From: Martin Varghese <[email protected]>

Special handling is needed in bareudp module for IP & MPLS as they support more than one ethertypes.

MPLS has 2 ethertypes. 0x8847 for MPLS unicast and 0x8848 for MPLS multicast. While decapsulating MPLS packet from UDP packet the tunnel destination IP address is checked to determine the ethertype. The ethertype of the packet will be set to 0x8848 if the tunnel destination IP address is a multicast IP address. The ethertype of the packet will be set to 0x8847 if the tunnel destination IP address is a unicast IP address.

IP has 2 ethertypes.0x0800 for IPV4 and 0x86dd for IPv6. The version field of the IP header tunnelled will be checked to determine the ethertype.

This special handling to tunnel additional ethertypes will be disabled by default and can be enabled using a flag called ext mode. This flag can be used only with ethertypes 0x8847 and 0x0800.

---
Changes in v2:
- Fixed documentation errors.
- Changed commit message.

Changes in v3:
- Re-sending the patch.

Changes in v4:
- Renamed extmode flag to multiproto
- Fixed typo in description.

 Documentation/networking/bareudp.rst | 20 ++++++++++-
 drivers/net/bareudp.c                | 68 +++++++++++++++++++++++++++++++++---
 include/net/bareudp.h                |  1 +
 include/uapi/linux/if_link.h         |  1 +
 4 files changed, 85 insertions(+), 5 deletions(-)
Documentation/networking/bareudp.rst +19 -1
index 4087a1b..9794dd8 100644
@@ -12,6 +12,15 @@ The Bareudp tunnel module provides a generic L3 encapsulation tunnelling
 support for tunnelling different L3 protocols like MPLS, IP, NSH etc. inside
 a UDP tunnel.
 
+Special Handling
+----------------
+The bareudp device supports special handling for MPLS & IP as they can have
+multiple ethertypes.
+MPLS procotcol can have ethertypes ETH_P_MPLS_UC  (unicast) & ETH_P_MPLS_MC (multicast).
+IP protocol can have ethertypes ETH_P_IP (v4) & ETH_P_IPV6 (v6).
+This special handling can be enabled only for ethertypes ETH_P_IP & ETH_P_MPLS_UC
+with a flag called multiproto mode.
+
 Usage
 ------
 
@@ -25,7 +34,16 @@ Usage
 
     b) ip link delete bareudp0
 
-2) Device Usage
+2) Device creation with multiple proto mode enabled
+
+There are two ways to create a bareudp device for MPLS & IP with multiproto mode
+enabled.
+
+    a) ip link add dev  bareudp0 type bareudp dstport 6635 ethertype 0x8847 multiproto
+
+    b) ip link add dev  bareudp0 type bareudp dstport 6635 ethertype mpls
+
+3) Device Usage
 
 The bareudp device could be used along with OVS or flower filter in TC.
 The OVS or TC flower layer must set the tunnel information in SKB dst field before
drivers/net/bareudp.c +64 -4

114 lines not on this page · raw message

include/net/bareudp.h +1 -0
index 513fae6..cb03f6f 100644
@@ -10,6 +10,7 @@ struct bareudp_conf {
 	__be16 ethertype;
 	__be16 port;
 	u16 sport_min;
+	bool multi_proto_mode;
 };
 
 struct net_device *bareudp_dev_create(struct net *net, const char *name,
include/uapi/linux/if_link.h +1 -0
index fb4b33a..61e0801 100644
@@ -596,6 +596,7 @@ enum {
 	IFLA_BAREUDP_PORT,
 	IFLA_BAREUDP_ETHERTYPE,
 	IFLA_BAREUDP_SRCPORT_MIN,
+	IFLA_BAREUDP_MULTIPROTO_MODE,
 	__IFLA_BAREUDP_MAX
 };
 
Signature · 1 line
1.8.3.1
Acked-by on v4 2/2
#8 lore raw

Re: [PATCH net-next v4 2/2] net: Special handling for IP & MPLS.

Quoted 13 lines · Martin Varghese

From: Martin Varghese <[email protected]>

Special handling is needed in bareudp module for IP & MPLS as they support more than one ethertypes.

MPLS has 2 ethertypes. 0x8847 for MPLS unicast and 0x8848 for MPLS multicast. While decapsulating MPLS packet from UDP packet the tunnel destination IP address is checked to determine the ethertype. The ethertype of the packet will be set to 0x8848 if the tunnel destination IP address is a multicast IP address. The ethertype of the packet will be set to 0x8847 if the tunnel destination IP address is a unicast IP address.

Quoted 8 lines

IP has 2 ethertypes.0x0800 for IPV4 and 0x86dd for IPv6. The version field of the IP header tunnelled will be checked to determine the ethertype.

This special handling to tunnel additional ethertypes will be disabled by default and can be enabled using a flag called ext mode. This flag can be used only with ethertypes 0x8847 and 0x0800.

#9 lore raw

Re: [PATCH net-next v4 2/2] net: Special handling for IP & MPLS.

Quoted 18 lines · Willem de Bruijn
Quoted 16 lines · Martin Varghese

From: Martin Varghese <[email protected]>

Special handling is needed in bareudp module for IP & MPLS as they support more than one ethertypes.

MPLS has 2 ethertypes. 0x8847 for MPLS unicast and 0x8848 for MPLS multicast. While decapsulating MPLS packet from UDP packet the tunnel destination IP address is checked to determine the ethertype. The ethertype of the packet will be set to 0x8848 if the tunnel destination IP address is a multicast IP address. The ethertype of the packet will be set to 0x8847 if the tunnel destination IP address is a unicast IP address.

IP has 2 ethertypes.0x0800 for IPV4 and 0x86dd for IPv6. The version field of the IP header tunnelled will be checked to determine the ethertype.

Quoted 7 lines
Quoted 5 lines

This special handling to tunnel additional ethertypes will be disabled by default and can be enabled using a flag called ext mode. This flag can be used only with ethertypes 0x8847 and 0x0800.

Thanks for your time.