Bareudp Tunnel Module
Subsystems (3)
cover Bareudp Tunnel Module
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 0x8847 (unicast) & 0x8847 (multicast). IP proctocol can have ethertypes 0x0800 (v4) & 0x866 (v6).
This special handling can be enabled only for ethertype 0x0800 & 0x88847 with a flag called extended 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 extended mode enabled
There are two ways to create a bareudp device for MPLS & IP with extended mode enabled
a. ip link add dev bareudp0 type bareudp dstport 6635 ethertype 0x8847 extmode 1
b. ip link add dev bareudp0 type bareudp dstport 6635 ethertype mpls
Note - iproute2 & Selftests are implemented in seperate patches.
Martin (2):
UDP tunnel encapsulation module for tunnelling different protocols
like MPLS,IP,NSH etc.
Special handling for IP & MPLS.
Documentation/networking/bareudp.txt | 41 ++ drivers/net/Kconfig | 13 + drivers/net/Makefile | 1 + drivers/net/bareudp.c | 998 +++++++++++++++++++++++++++++++++++ include/net/bareudp.h | 20 + include/uapi/linux/if_link.h | 13 + 6 files changed, 1086 insertions(+) create mode 100644 Documentation/networking/bareudp.txt create mode 100644 drivers/net/bareudp.c create mode 100644 include/net/bareudp.h
Signature · 1 line
1.8.3.1
PATCH 1/2 UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
From: Martin <[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.
--- Documentation/networking/bareudp.txt | 23 + drivers/net/Kconfig | 13 + drivers/net/Makefile | 1 + drivers/net/bareudp.c | 930 +++++++++++++++++++++++++++++++++++ include/net/bareudp.h | 19 + include/uapi/linux/if_link.h | 12 + 6 files changed, 998 insertions(+) create mode 100644 Documentation/networking/bareudp.txt create mode 100644 drivers/net/bareudp.c create mode 100644 include/net/bareudp.h
Documentation/networking/bareudp.txt new file +23 -0
@@ -0,0 +1,23 @@ +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
drivers/net/Kconfig +13 -0
@@ -215,6 +215,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 + kind 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
@@ -28,6 +28,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 +930 -0
930 lines not on this page · raw message
include/net/bareudp.h new file +19 -0
@@ -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/uapi/linux/if_link.h +12 -0
@@ -580,6 +580,18 @@ 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
Jonathan Corbet
maintainerRe: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 19 lines · On Tue, 8 Oct 2019 15:18:53 +0530 Martin Varghese…
Documentation/networking/bareudp.txt new file +13
-0@@ -0,0 +1,23 @@ +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 +------
Documentation/networking/bareudp.txt line 23
Quoted 10 lines
Documentation/networking/bareudp.txt new file +10
-0+ +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
Please add new documentation in the RST format if at all possible. This document is 95% RST already; doing the last bit of work will save somebody else the effort of converting it in the future.
Thanks,
jon
Randy Dunlap
reviewerRe: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
In reply to Martin VargheseQuoted 25 lines · Martin Varghese
From: Martin <[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.
Signed-off-by Martin Varghese <[email protected]>--- Documentation/networking/bareudp.txt | 23 + drivers/net/Kconfig | 13 + drivers/net/Makefile | 1 + drivers/net/bareudp.c | 930 +++++++++++++++++++++++++++++++++++ include/net/bareudp.h | 19 + include/uapi/linux/if_link.h | 12 + 6 files changed, 998 insertions(+) create mode 100644 Documentation/networking/bareudp.txt create mode 100644 drivers/net/bareudp.c create mode 100644 include/net/bareudp.hDocumentation/networking/bareudp.txt new file +0
-0
Documentation/networking/bareudp.txt line 6
Quoted 6 lines
Documentation/networking/bareudp.txt new file +6
-0@@ -0,0 +1,23 @@ +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.
add space after ')'.
Quoted 4 lines
Documentation/networking/bareudp.txt new file +4
-0+ +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.
Documentation/networking/bareudp.txt line 20
Quoted 10 lines
Documentation/networking/bareudp.txt new file +10
-0+ +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
add space after '.'.
add ending '.'.
drivers/net/Kconfig config GENEVE · line 219
Quoted 13 lines
Documentation/networking/bareudp.txt new file +3
-0+The device will listen on UDP port 6635 to receive traffic. + +b. ip link delete bareudp0drivers/net/Kconfig +2
-0@@ -215,6 +215,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"
drop one space between UDP and Encapsulation.
drivers/net/Kconfig config GENEVE · line 225
Quoted 6 lines
drivers/net/Kconfig +6
-0+ 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
s/udp/UDP/
Quoted 8 lines
drivers/net/Kconfig +5
-0+ kind 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
Signature · 1 line
~Randy
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
In reply to Martin Varghesedrivers/net/bareudp.c line 568
Quoted 5 lines · On Tue, 8 Oct 2019 15:18:53 +0530 Martin Varghese…
drivers/net/bareudp.c new file +5
-0+#if IS_ENABLED (CONFIG_IPV6 ) + ret =bareudp_sock_add (bareudp, true); +#endif + ret =bareudp_sock_add (bareudp, false); +
if ipv6 returns error it will get overriden by the ipv4 value
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
In reply to Martin Varghesedrivers/net/bareudp.c line 611
Quoted 5 lines · On Tue, 8 Oct 2019 15:18:53 +0530 Martin Varghese…
drivers/net/bareudp.c new file +5
-0+if (new_mtu > dev->max_mtu) + new_mtu = dev->max_mtu; +else if (new_mtu < dev->min_mtu) + new_mtu = dev->min_mtu; +
These checks are already handled as errors in dev_set_mtu_ext()
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
In reply to Martin VargheseQuoted 26 lines · Martin Varghese
From: Martin <[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.
Signed-off-by Martin Varghese <[email protected]>--- Documentation/networking/bareudp.txt | 23 + drivers/net/Kconfig | 13 + drivers/net/Makefile | 1 + drivers/net/bareudp.c | 930 +++++++++++++++++++++++++++++++++++ include/net/bareudp.h | 19 + include/uapi/linux/if_link.h | 12 + 6 files changed, 998 insertions(+) create mode 100644 Documentation/networking/bareudp.txt create mode 100644 drivers/net/bareudp.c create mode 100644 include/net/bareudp.hDocumentation/networking/bareudp.txt new file +0
-0
Documentation/networking/bareudp.txt line 10
Quoted 10 lines
Documentation/networking/bareudp.txt new file +10
-0@@ -0,0 +1,23 @@ +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.
This patch set introduces a lot of code, much of which duplicates existing tunnel devices, whether FOU using ipip tunnels and fou_build_header or separate devices like vxlan and geneve. Let's try to reuse what's there (and tested).
How does this differ from foo-over-udp (FOU). In supporting MPLS alongside IP? If so, can it reuse the existing code, possibly with patches to that existing tunnel logic?
I happened to have been playing around with MPLS in GRE recently. Have not tried the same over UDP tunnels, but most of it should apply?
ip tunnel add gre1 mode gre local 192.168.1.1 remote 192.168.1.2 dev eth0 ip addr add 192.168.101.1 peer 192.168.101.2 dev gre1
ip link set dev gre1 up
sysctl net.mpls.conf.gre1.input=1
sysctl net.mpls.platform_labels=17
ip addr add 192.168.201.1/24 dev gre1
ip route add 192.168.202.0/24 encap mpls 17 dev gre1 ip -f mpls route add 16 dev lo
Quoted 26 lines
Documentation/networking/bareudp.txt new file +26
-0+static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) +{ + struct bareudp_sock *bs; + struct ethhdr *eh; + struct bareudp_dev *bareudp; + struct metadata_dst *tun_dst = NULL; + struct pcpu_sw_netstats *stats; + unsigned int len; + int err = 0; + void *oiph; + u16 proto; + + if (unlikely(!pskb_may_pull(skb, BAREUDP_BASE_HLEN))) + goto drop; + + bs = rcu_dereference_sk_user_data(sk); + if (!bs) + goto drop; + + bareudp = bs->bareudp; + proto = bareudp->ethertype; + + if (iptunnel_pull_header(skb, BAREUDP_BASE_HLEN, + proto, + !net_eq(bareudp->net, + dev_net(bareudp->dev)))) {
Documentation/networking/bareudp.txt
Quoted 10 lines
Documentation/networking/bareudp.txt new file +10
-0+ bareudp->dev->stats.rx_dropped++; + goto drop; + } + tun_dst = udp_tun_rx_dst(skb, bareudp_get_sk_family(bs), TUNNEL_KEY, + 0, 0); + if (!tun_dst) { + bareudp->dev->stats.rx_dropped++; + goto drop; + } + skb_dst_set(skb, &tun_dst->dst);
Is this dst metadata a firm requirement? It is optional in vxlan, say. If here, too, please split such parts off into separate follow-on patches.
Documentation/networking/bareudp.txt
Quoted 11 lines
Documentation/networking/bareudp.txt new file +11
-0+ skb_push(skb, sizeof(struct ethhdr)); + eh = (struct ethhdr *)skb->data; + eh->h_proto = proto; + + skb_reset_mac_header(skb); + skb->protocol = eth_type_trans(skb, bareudp->dev); + skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN); + oiph = skb_network_header(skb); + skb_reset_network_header(skb); + + if (bareudp_get_sk_family(bs) == AF_INET)
This should be derived from packet contents, not socket state. Although the one implies the other, I imagine.
Quoted 82 lines
Documentation/networking/bareudp.txt new file +82
-0+static struct rtable *bareudp_get_v4_rt(struct sk_buff *skb, + struct net_device *dev, + struct bareudp_sock *bs4, + struct flowi4 *fl4, + const struct ip_tunnel_info *info) +{ + bool use_cache = ip_tunnel_dst_cache_usable(skb, info); + struct bareudp_dev *bareudp = netdev_priv(dev); + struct dst_cache *dst_cache; + struct rtable *rt = NULL; + __u8 tos; + + if (!bs4) + return ERR_PTR(-EIO); + + memset(fl4, 0, sizeof(*fl4)); + fl4->flowi4_mark = skb->mark; + fl4->flowi4_proto = IPPROTO_UDP; + fl4->daddr = info->key.u.ipv4.dst; + fl4->saddr = info->key.u.ipv4.src; + + tos = info->key.tos; + fl4->flowi4_tos = RT_TOS(tos); + + dst_cache = (struct dst_cache *)&info->dst_cache; + if (use_cache) { + rt = dst_cache_get_ip4(dst_cache, &fl4->saddr); + if (rt) + return rt; + } + rt = ip_route_output_key(bareudp->net, fl4); + if (IS_ERR(rt)) { + netdev_dbg(dev, "no route to %pI4\n", &fl4->daddr); + return ERR_PTR(-ENETUNREACH); + } + if (rt->dst.dev == dev) { /* is this necessary? */ + netdev_dbg(dev, "circular route to %pI4\n", &fl4->daddr); + ip_rt_put(rt); + return ERR_PTR(-ELOOP); + } + if (use_cache) + dst_cache_set_ip4(dst_cache, &rt->dst, fl4->saddr); + return rt; +} + +#if IS_ENABLED(CONFIG_IPV6) +static struct dst_entry *bareudp_get_v6_dst(struct sk_buff *skb, + struct net_device *dev, + struct bareudp_sock *bs6, + struct flowi6 *fl6, + const struct ip_tunnel_info *info) +{ + bool use_cache = ip_tunnel_dst_cache_usable(skb, info); + struct bareudp_dev *bareudp = netdev_priv(dev); + struct dst_entry *dst = NULL; + struct dst_cache *dst_cache; + __u8 prio; + + if (!bs6) + return ERR_PTR(-EIO); + + memset(fl6, 0, sizeof(*fl6)); + fl6->flowi6_mark = skb->mark; + fl6->flowi6_proto = IPPROTO_UDP; + fl6->daddr = info->key.u.ipv6.dst; + fl6->saddr = info->key.u.ipv6.src; + prio = info->key.tos; + + fl6->flowlabel = ip6_make_flowinfo(RT_TOS(prio), + info->key.label); + dst_cache = (struct dst_cache *)&info->dst_cache; + if (use_cache) { + dst = dst_cache_get_ip6(dst_cache, &fl6->saddr); + if (dst) + return dst; + } + if (ipv6_stub->ipv6_dst_lookup(bareudp->net, bs6->sock->sk, &dst, + fl6)) { + netdev_dbg(dev, "no route to %pI6\n", &fl6->daddr); + return ERR_PTR(-ENETUNREACH); + } + if (dst->dev == dev) { /* is this necessary? */
Documentation/networking/bareudp.txt
Quoted 10 lines
Documentation/networking/bareudp.txt new file +10
-0+ netdev_dbg(dev, "circular route to %pI6\n", &fl6->daddr); + dst_release(dst); + return ERR_PTR(-ELOOP); + } + + if (use_cache) + dst_cache_set_ip6(dst_cache, dst, &fl6->saddr); + return dst; +} +#endif
The route lookup logic is very similar to vxlan_get_route and vxlan6_get_route. Can be reused?
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 55 lines · Willem de Bruijn
Quoted 26 lines · Martin Varghese
From: Martin <[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.
Signed-off-by Martin Varghese <[email protected]>--- Documentation/networking/bareudp.txt | 23 + drivers/net/Kconfig | 13 + drivers/net/Makefile | 1 + drivers/net/bareudp.c | 930 +++++++++++++++++++++++++++++++++++ include/net/bareudp.h | 19 + include/uapi/linux/if_link.h | 12 + 6 files changed, 998 insertions(+) create mode 100644 Documentation/networking/bareudp.txt create mode 100644 drivers/net/bareudp.c create mode 100644 include/net/bareudp.hDocumentation/networking/bareudp.txt new file +0
-0Documentation/networking/bareudp.txt line 10
Quoted 10 lines
Documentation/networking/bareudp.txt new file +10
-0@@ -0,0 +1,23 @@ +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.This patch set introduces a lot of code, much of which duplicates existing tunnel devices, whether FOU using ipip tunnels and
fou_build_headeror separate devices like vxlan and geneve. Let's try to reuse what's there (and tested).How does this differ from foo-over-udp (FOU). In supporting MPLS alongside IP? If so, can it reuse the existing code, possibly with patches to that existing tunnel logic?
I happened to have been playing around with MPLS in GRE recently. Have not tried the same over UDP tunnels, but most of it should apply?
ip tunnel add gre1 mode gre local 192.168.1.1 remote 192.168.1.2 dev eth0 ip addr add 192.168.101.1 peer 192.168.101.2 dev gre1
ip link set dev gre1 up
Quoted 7 lines
sysctl net.mpls.conf.gre1.input=1
sysctl net.mpls.platform_labels=17
ip addr add 192.168.201.1/24 dev gre1
ip route add 192.168.202.0/24 encap mpls 17 dev gre1 ip -f mpls route add 16 dev lo
unlike FOU which does l4 encapsulation, here we are trying to acheive l3 encapsulation. For Example, What is needed for MPLSoUDP is to take packets such as:
eth header | mpls header | payload
and encapsulate them to:
eth header | ip header | udp header | mpls header | payload <--------- outer ------------------> <---- inner --------->
which is later decapsulated back to:
eth header | mpls header | payload
Note that in the decapsulated case, the ethertype in the eth header is ETH_P_MPLS_UC, while in the encapsulated case, the ethertype in the eth header is ETH_P_IP. When decapsulating, ETH_P_MPLS_UC is restored based on the configured tunnel parameters.
This cannot be done with FOU. FOU needs an ipproto, not ethertype.
During receive FOU dispatches packet to l4 handlers which makes it impossible to patch it to get it working for l3 protocols like MPLS.
Quoted 32 lines
Quoted 32 lines
Documentation/networking/bareudp.txt new file +32
-0+static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) +{ + struct bareudp_sock *bs; + struct ethhdr *eh; + struct bareudp_dev *bareudp; + struct metadata_dst *tun_dst = NULL; + struct pcpu_sw_netstats *stats; + unsigned int len; + int err = 0; + void *oiph; + u16 proto; + + if (unlikely(!pskb_may_pull(skb, BAREUDP_BASE_HLEN))) + goto drop; + + bs = rcu_dereference_sk_user_data(sk); + if (!bs) + goto drop; + + bareudp = bs->bareudp; + proto = bareudp->ethertype; + + if (iptunnel_pull_header(skb, BAREUDP_BASE_HLEN, + proto, + !net_eq(bareudp->net, + dev_net(bareudp->dev)))) { + bareudp->dev->stats.rx_dropped++; + goto drop; + } + tun_dst = udp_tun_rx_dst(skb, bareudp_get_sk_family(bs), TUNNEL_KEY, + 0, 0); + if (!tun_dst) {
Quoted 10 lines
Documentation/networking/bareudp.txt
Quoted 4 lines
Documentation/networking/bareudp.txt new file +4
-0+ bareudp->dev->stats.rx_dropped++; + goto drop; + } + skb_dst_set(skb, &tun_dst->dst);Is this dst metadata a firm requirement? It is optional in vxlan, say. If here, too, please split such parts off into separate follow-on patches.
Yes it is.
Quoted 102 lines
Documentation/networking/bareudp.txt
Quoted 11 lines
Documentation/networking/bareudp.txt new file +11
-0+ skb_push(skb, sizeof(struct ethhdr)); + eh = (struct ethhdr *)skb->data; + eh->h_proto = proto; + + skb_reset_mac_header(skb); + skb->protocol = eth_type_trans(skb, bareudp->dev); + skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN); + oiph = skb_network_header(skb); + skb_reset_network_header(skb); + + if (bareudp_get_sk_family(bs) == AF_INET)This should be derived from packet contents, not socket state. Although the one implies the other, I imagine.
Quoted 87 lines
Documentation/networking/bareudp.txt new file +87
-0+static struct rtable *bareudp_get_v4_rt(struct sk_buff *skb, + struct net_device *dev, + struct bareudp_sock *bs4, + struct flowi4 *fl4, + const struct ip_tunnel_info *info) +{ + bool use_cache = ip_tunnel_dst_cache_usable(skb, info); + struct bareudp_dev *bareudp = netdev_priv(dev); + struct dst_cache *dst_cache; + struct rtable *rt = NULL; + __u8 tos; + + if (!bs4) + return ERR_PTR(-EIO); + + memset(fl4, 0, sizeof(*fl4)); + fl4->flowi4_mark = skb->mark; + fl4->flowi4_proto = IPPROTO_UDP; + fl4->daddr = info->key.u.ipv4.dst; + fl4->saddr = info->key.u.ipv4.src; + + tos = info->key.tos; + fl4->flowi4_tos = RT_TOS(tos); + + dst_cache = (struct dst_cache *)&info->dst_cache; + if (use_cache) { + rt = dst_cache_get_ip4(dst_cache, &fl4->saddr); + if (rt) + return rt; + } + rt = ip_route_output_key(bareudp->net, fl4); + if (IS_ERR(rt)) { + netdev_dbg(dev, "no route to %pI4\n", &fl4->daddr); + return ERR_PTR(-ENETUNREACH); + } + if (rt->dst.dev == dev) { /* is this necessary? */ + netdev_dbg(dev, "circular route to %pI4\n", &fl4->daddr); + ip_rt_put(rt); + return ERR_PTR(-ELOOP); + } + if (use_cache) + dst_cache_set_ip4(dst_cache, &rt->dst, fl4->saddr); + return rt; +} + +#if IS_ENABLED(CONFIG_IPV6) +static struct dst_entry *bareudp_get_v6_dst(struct sk_buff *skb, + struct net_device *dev, + struct bareudp_sock *bs6, + struct flowi6 *fl6, + const struct ip_tunnel_info *info) +{ + bool use_cache = ip_tunnel_dst_cache_usable(skb, info); + struct bareudp_dev *bareudp = netdev_priv(dev); + struct dst_entry *dst = NULL; + struct dst_cache *dst_cache; + __u8 prio; + + if (!bs6) + return ERR_PTR(-EIO); + + memset(fl6, 0, sizeof(*fl6)); + fl6->flowi6_mark = skb->mark; + fl6->flowi6_proto = IPPROTO_UDP; + fl6->daddr = info->key.u.ipv6.dst; + fl6->saddr = info->key.u.ipv6.src; + prio = info->key.tos; + + fl6->flowlabel = ip6_make_flowinfo(RT_TOS(prio), + info->key.label); + dst_cache = (struct dst_cache *)&info->dst_cache; + if (use_cache) { + dst = dst_cache_get_ip6(dst_cache, &fl6->saddr); + if (dst) + return dst; + } + if (ipv6_stub->ipv6_dst_lookup(bareudp->net, bs6->sock->sk, &dst, + fl6)) { + netdev_dbg(dev, "no route to %pI6\n", &fl6->daddr); + return ERR_PTR(-ENETUNREACH); + } + if (dst->dev == dev) { /* is this necessary? */ + netdev_dbg(dev, "circular route to %pI6\n", &fl6->daddr); + dst_release(dst); + return ERR_PTR(-ELOOP); + } +
Quoted 8 lines
Documentation/networking/bareudp.txt
Quoted 5 lines
Documentation/networking/bareudp.txt new file +5
-0+ if (use_cache) + dst_cache_set_ip6(dst_cache, dst, &fl6->saddr); + return dst; +} +#endifThe route lookup logic is very similar to
vxlan_get_routeandvxlan6_get_route. Can be reused?
Yes we could. We can move these to a common place. include/net/ip_tunnels.h ?
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 60 lines · Martin Varghese
Quoted 39 lines · Willem de Bruijn
Quoted 10 lines · Martin Varghese
From: Martin <[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.
Signed-off-by Martin Varghese <[email protected]>+++
b/Documentation/networking/bareudp.txtDocumentation/networking/bareudp.txt line 10
Quoted 10 lines
Documentation/networking/bareudp.txt new file +10
-0@@ -0,0 +1,23 @@ +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.This patch set introduces a lot of code, much of which duplicates existing tunnel devices, whether FOU using ipip tunnels and
fou_build_headeror separate devices like vxlan and geneve. Let's try to reuse what's there (and tested).How does this differ from foo-over-udp (FOU). In supporting MPLS alongside IP? If so, can it reuse the existing code, possibly with patches to that existing tunnel logic?
I happened to have been playing around with MPLS in GRE recently. Have not tried the same over UDP tunnels, but most of it should apply?
ip tunnel add gre1 mode gre local 192.168.1.1 remote 192.168.1.2 dev eth0 ip addr add 192.168.101.1 peer 192.168.101.2 dev gre1
ip link set dev gre1 upQuoted 7 lines
sysctl net.mpls.conf.gre1.input=1
sysctl net.mpls.platform_labels=17
ip addr add 192.168.201.1/24 dev gre1
ip route add 192.168.202.0/24 encap mpls 17 dev gre1 ip -f mpls route add 16 dev lounlike FOU which does l4 encapsulation, here we are trying to acheive l3 encapsulation. For Example, What is needed for MPLSoUDP is to take packets such as:
eth header | mpls header | payload
and encapsulate them to:
eth header | ip header | udp header | mpls header | payload <--------- outer ------------------> <---- inner --------->
which is later decapsulated back to:
Quoted 8 lines
eth header | mpls header | payload
Note that in the decapsulated case, the ethertype in the eth header is
ETH_P_MPLS_UC, while in the encapsulated case, the ethertype in the eth header isETH_P_IP. When decapsulating,ETH_P_MPLS_UCis restored based on the configured tunnel parameters.This cannot be done with FOU. FOU needs an ipproto, not ethertype.
During receive FOU dispatches packet to l4 handlers which makes it impossible to patch it to get it working for l3 protocols like MPLS.
Yes, this needs a call to gro_cells_receive like geneve_udp_encap_recv and vxlan_rcv, instead of returning a negative value back to udp_queue_rcv_one_skb. Though that's not a major change.
Transmit is easier. The example I shared already encapsulates packets with MPLs and sends them through a tunnel device. Admittedly using mpls routing. But the ip tunneling infrastructure supports adding arbitrary inner headers using ip_tunnel_encap_ops.build_header. net/ipv4/fou.c could be extended with a mpls_build_header alongside fou_build_header and gue_build_header?
Extending this existing code has more benefits than code reuse (and thereby fewer bugs), it also allows reusing the existing GRO logic, say.
At a high level, I think we should try hard to avoid duplicating tunnel code for every combination of inner and outer protocol. Geneve and vxlan on the one hand and generic ip tunnel and FOU on the other implement most of these features. Indeed, already implements the IPxIPx, just not MPLS. It will be less code to add MPLS support based on existing infrastructure.
Quoted 4 lines
Quoted 2 lines
The route lookup logic is very similar to
vxlan_get_routeandvxlan6_get_route. Can be reused?Yes we could. We can move these to a common place.
include/net/ip_tunnels.h?
I think it will be preferable to work the other way around and extend existing ip tunnel infra to add MPLS.
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 4 lines
Quoted 1 line
Yes we could. We can move these to a common place.
include/net/ip_tunnels.h?I think it will be preferable to work the other way around and extend existing ip tunnel infra to add MPLS.
But that may not be entirely feasible, not sure yet. Else, indeed moving such helpers to a common location sounds good.
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
In reply to Willem de BruijnQuoted 3 lines · Willem de Bruijn
Yes, this needs a call to
gro_cells_receivelikegeneve_udp_encap_recvandvxlan_rcv, instead of returning a negative value back toudp_queue_rcv_one_skb. Though that's not a major change.
Willem, how would you do that? The whole fou code including its netlink API is built around the assumption that it's L4 encapsulation. I see no way to extend it to do L3 encapsulation without major hacks - in fact, you'll add all that Martin's patch adds, including a new netlink API, but just mix that into fou.c.
Quoted 6 lines
Transmit is easier. The example I shared already encapsulates packets with MPLs and sends them through a tunnel device. Admittedly using mpls routing. But the ip tunneling infrastructure supports adding arbitrary inner headers using ip_tunnel_encap_ops.build_header.
net/ipv4/fou.ccould be extended with ampls_build_headeralongsidefou_build_headerandgue_build_header?
The nice thing about the bareudp tunnel is that it's generic. It's just (outer) UDP header followed by (inner) L3 header. You can use it for NSH over UDP. Or for multitude of other purposes.
What you're proposing is MPLS only. And it would require similar amount of code as the bareudp generic solution. It also doesn't fit fou
design: MPLS is not an IP protocol. Trying to add it there is like forcing a round peg into a square hole. Just look at the code. Start with parse_nl_config.
Quoted 3 lines
Extending this existing code has more benefits than code reuse (and thereby fewer bugs), it also allows reusing the existing GRO logic, say.
In this case, it's the opposite: trying to retrofit L3 encapsulation into fou is going to introduce bugs.
Moreover, given the expected usage of bareudp, the nice benefit is it's lwtunnel only. No need to carry all the baggage of standalone configuration fou has.
Quoted 2 lines
At a high level, I think we should try hard to avoid duplicating tunnel code for every combination of inner and outer protocol.
Yet you're proposing to do exactly that with special casing MPLS in fou.
I'd say bareudp is as generic as you could get it. It allows any L3 protocol inside UDP. You can hardly make it more generic than that. With ETH_P_TEB, it could also encapsulate Ethernet (that is, L2).
Quoted 5 lines
Geneve
and vxlan on the one hand and generic ip tunnel and FOU on the other implement most of these features. Indeed, already implements the IPxIPx, just not MPLS. It will be less code to add MPLS support based on existing infrastructure.
You're mixing apples with oranges. IP tunnels and FOU encapsulate L4 payload. VXLAN and Geneve encapsulate L2 payload (or L3 payload for VXLAN-GPE).
I agree that VXLAN, Geneve and the proposed bareudp module have duplicated code. The solution is to factoring it out to a common location.
Quoted 2 lines
I think it will be preferable to work the other way around and extend existing ip tunnel infra to add MPLS.
You see, that's the problem: this is not IP tunneling.
Jiri
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 33 lines · Jiri Benc
Quoted 3 lines · Willem de Bruijn
Yes, this needs a call to
gro_cells_receivelikegeneve_udp_encap_recvandvxlan_rcv, instead of returning a negative value back toudp_queue_rcv_one_skb. Though that's not a major change.Willem, how would you do that? The whole fou code including its netlink API is built around the assumption that it's L4 encapsulation. I see no way to extend it to do L3 encapsulation without major hacks - in fact, you'll add all that Martin's patch adds, including a new netlink API, but just mix that into
fou.c.Quoted 6 lines
Transmit is easier. The example I shared already encapsulates packets with MPLs and sends them through a tunnel device. Admittedly using mpls routing. But the ip tunneling infrastructure supports adding arbitrary inner headers using ip_tunnel_encap_ops.build_header.
net/ipv4/fou.ccould be extended with ampls_build_headeralongsidefou_build_headerandgue_build_header?The nice thing about the bareudp tunnel is that it's generic. It's just (outer) UDP header followed by (inner) L3 header. You can use it for NSH over UDP. Or for multitude of other purposes.
What you're proposing is MPLS only. And it would require similar amount of code as the bareudp generic solution. It also doesn't fit fou
design: MPLS is not an IP protocol. Trying to add it there is like forcing a round peg into a square hole. Just look at the code. Start withparse_nl_config.Quoted 3 lines
Extending this existing code has more benefits than code reuse (and thereby fewer bugs), it also allows reusing the existing GRO logic, say.
Quoted 6 lines
In this case, it's the opposite: trying to retrofit L3 encapsulation into fou is going to introduce bugs.
Moreover, given the expected usage of bareudp, the nice benefit is it's lwtunnel only. No need to carry all the baggage of standalone configuration fou has.
That's an interesting point. Is lwtunnel support actually something that should carry over to fou?
Quoted 9 lines
Quoted 2 lines
At a high level, I think we should try hard to avoid duplicating tunnel code for every combination of inner and outer protocol.
Yet you're proposing to do exactly that with special casing MPLS in fou.
I'd say bareudp is as generic as you could get it. It allows any L3 protocol inside UDP. You can hardly make it more generic than that. With
ETH_P_TEB, it could also encapsulate Ethernet (that is, L2).
Quoted 8 lines
Quoted 5 lines
Geneve
and vxlan on the one hand and generic ip tunnel and FOU on the other implement most of these features. Indeed, already implements the IPxIPx, just not MPLS. It will be less code to add MPLS support based on existing infrastructure.You're mixing apples with oranges. IP tunnels and FOU encapsulate L4 payload.
FOU encapsulates L3, no different than IPIP or GRE?
Quoted 6 lines
VXLAN and Geneve encapsulate L2 payload (or L3 payload for VXLAN-GPE).
I agree that VXLAN, Geneve and the proposed bareudp module have duplicated code. The solution is to factoring it out to a common location.
That sounds fine. The crux is that there really are use cases besides MPLS.
Quoted 4 lines
Quoted 2 lines
I think it will be preferable to work the other way around and extend existing ip tunnel infra to add MPLS.
You see, that's the problem: this is not IP tunneling.
GRE also supports ETH_P_TEB, using the shared ip tunnel infrastructure.
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
In reply to Jiri BencQuoted 6 lines · Jiri Benc
Quoted 3 lines · Willem de Bruijn
Yes, this needs a call to
gro_cells_receivelikegeneve_udp_encap_recvandvxlan_rcv, instead of returning a negative value back toudp_queue_rcv_one_skb. Though that's not a major change.
Quoted 6 lines
Willem, how would you do that? The whole fou code including its netlink API is built around the assumption that it's L4 encapsulation. I see no way to extend it to do L3 encapsulation without major hacks - in fact, you'll add all that Martin's patch adds, including a new netlink API, but just mix that into
fou.c.
More specifically fou allows encapsulation of anything that has an IP protocol number. That includes an L3 protocols that have been assigned a number (e.g. MPLS, GRE, IPv6, IPv4, EtherIP). So the only need for an alternate method to do L3 encapsulation would be for those protocols that don't have an IP protocol number assignment. Presumably, those just have an EtherType. In that case, it seems simple enough to just extend fou to processed an encapsulated EtherType. This should be little more than modifying the "struct fou" to hold 16 bit EtherType (union with protocol), adding FOU_ENCAP_ETHER, corresponding attribute, and then populate appropriate receive functions for the socket.
Tom
Quoted 57 lines
Quoted 6 lines
Transmit is easier. The example I shared already encapsulates packets with MPLs and sends them through a tunnel device. Admittedly using mpls routing. But the ip tunneling infrastructure supports adding arbitrary inner headers using ip_tunnel_encap_ops.build_header.
net/ipv4/fou.ccould be extended with ampls_build_headeralongsidefou_build_headerandgue_build_header?The nice thing about the bareudp tunnel is that it's generic. It's just (outer) UDP header followed by (inner) L3 header. You can use it for NSH over UDP. Or for multitude of other purposes.
What you're proposing is MPLS only. And it would require similar amount of code as the bareudp generic solution. It also doesn't fit fou
design: MPLS is not an IP protocol. Trying to add it there is like forcing a round peg into a square hole. Just look at the code. Start withparse_nl_config.Quoted 3 lines
Extending this existing code has more benefits than code reuse (and thereby fewer bugs), it also allows reusing the existing GRO logic, say.
In this case, it's the opposite: trying to retrofit L3 encapsulation into fou is going to introduce bugs.
Moreover, given the expected usage of bareudp, the nice benefit is it's lwtunnel only. No need to carry all the baggage of standalone configuration fou has.
Quoted 2 lines
At a high level, I think we should try hard to avoid duplicating tunnel code for every combination of inner and outer protocol.
Yet you're proposing to do exactly that with special casing MPLS in fou.
I'd say bareudp is as generic as you could get it. It allows any L3 protocol inside UDP. You can hardly make it more generic than that. With
ETH_P_TEB, it could also encapsulate Ethernet (that is, L2).Quoted 5 lines
Geneve
and vxlan on the one hand and generic ip tunnel and FOU on the other implement most of these features. Indeed, already implements the IPxIPx, just not MPLS. It will be less code to add MPLS support based on existing infrastructure.You're mixing apples with oranges. IP tunnels and FOU encapsulate L4 payload. VXLAN and Geneve encapsulate L2 payload (or L3 payload for VXLAN-GPE).
I agree that VXLAN, Geneve and the proposed bareudp module have duplicated code. The solution is to factoring it out to a common location.
Quoted 2 lines
I think it will be preferable to work the other way around and extend existing ip tunnel infra to add MPLS.
You see, that's the problem: this is not IP tunneling.
Jiri
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 11 lines · Tom Herbert
More specifically fou allows encapsulation of anything that has an IP protocol number. That includes an L3 protocols that have been assigned a number (e.g. MPLS, GRE, IPv6, IPv4, EtherIP). So the only need for an alternate method to do L3 encapsulation would be for those protocols that don't have an IP protocol number assignment. Presumably, those just have an EtherType. In that case, it seems simple enough to just extend fou to processed an encapsulated EtherType. This should be little more than modifying the "struct fou" to hold 16 bit EtherType (union with protocol), adding
FOU_ENCAP_ETHER, corresponding attribute, and then populate appropriate receive functions for the socket.
How do you suggest to plug that in? We need the received inner packets to be "encapsulated" in an Ethernet header; the current approach of "ip link add type ipip|sit encap fou" does not work here. Are you suggesting to add another rtnl link type? How would it look like? "ip link add type ethernet encap fou" does not sound appealing, especially since "type ethernet" would have no meaning without the "encap fou".
Thanks,
Jiri
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
In reply to Willem de BruijnQuoted 104 lines · Willem de Bruijn
Quoted 26 lines · Martin Varghese
From: Martin <[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.
Signed-off-by Martin Varghese <[email protected]>--- Documentation/networking/bareudp.txt | 23 + drivers/net/Kconfig | 13 + drivers/net/Makefile | 1 + drivers/net/bareudp.c | 930 +++++++++++++++++++++++++++++++++++ include/net/bareudp.h | 19 + include/uapi/linux/if_link.h | 12 + 6 files changed, 998 insertions(+) create mode 100644 Documentation/networking/bareudp.txt create mode 100644 drivers/net/bareudp.c create mode 100644 include/net/bareudp.hDocumentation/networking/bareudp.txt new file +0
-0Documentation/networking/bareudp.txt line 10
Quoted 10 lines
Documentation/networking/bareudp.txt new file +10
-0@@ -0,0 +1,23 @@ +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.This patch set introduces a lot of code, much of which duplicates existing tunnel devices, whether FOU using ipip tunnels and
fou_build_headeror separate devices like vxlan and geneve. Let's try to reuse what's there (and tested).How does this differ from foo-over-udp (FOU). In supporting MPLS alongside IP? If so, can it reuse the existing code, possibly with patches to that existing tunnel logic?
I happened to have been playing around with MPLS in GRE recently. Have not tried the same over UDP tunnels, but most of it should apply?
ip tunnel add gre1 mode gre local 192.168.1.1 remote 192.168.1.2 dev eth0 ip addr add 192.168.101.1 peer 192.168.101.2 dev gre1
ip link set dev gre1 upsysctl net.mpls.conf.gre1.input=1
sysctl net.mpls.platform_labels=17
ip addr add 192.168.201.1/24 dev gre1
ip route add 192.168.202.0/24 encap mpls 17 dev gre1 ip -f mpls route add 16 dev loQuoted 26 lines
Documentation/networking/bareudp.txt new file +26
-0+static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) +{ + struct bareudp_sock *bs; + struct ethhdr *eh; + struct bareudp_dev *bareudp; + struct metadata_dst *tun_dst = NULL; + struct pcpu_sw_netstats *stats; + unsigned int len; + int err = 0; + void *oiph; + u16 proto; + + if (unlikely(!pskb_may_pull(skb, BAREUDP_BASE_HLEN))) + goto drop; + + bs = rcu_dereference_sk_user_data(sk); + if (!bs) + goto drop; + + bareudp = bs->bareudp; + proto = bareudp->ethertype; + + if (iptunnel_pull_header(skb, BAREUDP_BASE_HLEN, + proto, + !net_eq(bareudp->net, + dev_net(bareudp->dev)))) {Documentation/networking/bareudp.txt
Quoted 10 lines
Documentation/networking/bareudp.txt new file +10
-0+ bareudp->dev->stats.rx_dropped++; + goto drop; + } + tun_dst = udp_tun_rx_dst(skb, bareudp_get_sk_family(bs), TUNNEL_KEY, + 0, 0); + if (!tun_dst) { + bareudp->dev->stats.rx_dropped++; + goto drop; + } + skb_dst_set(skb, &tun_dst->dst);Is this dst metadata a firm requirement? It is optional in vxlan, say. If here, too, please split such parts off into separate follow-on patches.
Quoted 15 lines
Documentation/networking/bareudp.txt
Quoted 11 lines
Documentation/networking/bareudp.txt new file +11
-0+ skb_push(skb, sizeof(struct ethhdr)); + eh = (struct ethhdr *)skb->data; + eh->h_proto = proto; + + skb_reset_mac_header(skb); + skb->protocol = eth_type_trans(skb, bareudp->dev); + skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN); + oiph = skb_network_header(skb); + skb_reset_network_header(skb); + + if (bareudp_get_sk_family(bs) == AF_INET)This should be derived from packet contents, not socket state. Although the one implies the other, I imagine.
The IP Stack check IP headers & puts the packet in the correct socket, hence checking the ip headers again is reduntant correct? In geneve & vxlan it is done the same way.
Quoted 87 lines
Quoted 87 lines
Documentation/networking/bareudp.txt new file +87
-0+static struct rtable *bareudp_get_v4_rt(struct sk_buff *skb, + struct net_device *dev, + struct bareudp_sock *bs4, + struct flowi4 *fl4, + const struct ip_tunnel_info *info) +{ + bool use_cache = ip_tunnel_dst_cache_usable(skb, info); + struct bareudp_dev *bareudp = netdev_priv(dev); + struct dst_cache *dst_cache; + struct rtable *rt = NULL; + __u8 tos; + + if (!bs4) + return ERR_PTR(-EIO); + + memset(fl4, 0, sizeof(*fl4)); + fl4->flowi4_mark = skb->mark; + fl4->flowi4_proto = IPPROTO_UDP; + fl4->daddr = info->key.u.ipv4.dst; + fl4->saddr = info->key.u.ipv4.src; + + tos = info->key.tos; + fl4->flowi4_tos = RT_TOS(tos); + + dst_cache = (struct dst_cache *)&info->dst_cache; + if (use_cache) { + rt = dst_cache_get_ip4(dst_cache, &fl4->saddr); + if (rt) + return rt; + } + rt = ip_route_output_key(bareudp->net, fl4); + if (IS_ERR(rt)) { + netdev_dbg(dev, "no route to %pI4\n", &fl4->daddr); + return ERR_PTR(-ENETUNREACH); + } + if (rt->dst.dev == dev) { /* is this necessary? */ + netdev_dbg(dev, "circular route to %pI4\n", &fl4->daddr); + ip_rt_put(rt); + return ERR_PTR(-ELOOP); + } + if (use_cache) + dst_cache_set_ip4(dst_cache, &rt->dst, fl4->saddr); + return rt; +} + +#if IS_ENABLED(CONFIG_IPV6) +static struct dst_entry *bareudp_get_v6_dst(struct sk_buff *skb, + struct net_device *dev, + struct bareudp_sock *bs6, + struct flowi6 *fl6, + const struct ip_tunnel_info *info) +{ + bool use_cache = ip_tunnel_dst_cache_usable(skb, info); + struct bareudp_dev *bareudp = netdev_priv(dev); + struct dst_entry *dst = NULL; + struct dst_cache *dst_cache; + __u8 prio; + + if (!bs6) + return ERR_PTR(-EIO); + + memset(fl6, 0, sizeof(*fl6)); + fl6->flowi6_mark = skb->mark; + fl6->flowi6_proto = IPPROTO_UDP; + fl6->daddr = info->key.u.ipv6.dst; + fl6->saddr = info->key.u.ipv6.src; + prio = info->key.tos; + + fl6->flowlabel = ip6_make_flowinfo(RT_TOS(prio), + info->key.label); + dst_cache = (struct dst_cache *)&info->dst_cache; + if (use_cache) { + dst = dst_cache_get_ip6(dst_cache, &fl6->saddr); + if (dst) + return dst; + } + if (ipv6_stub->ipv6_dst_lookup(bareudp->net, bs6->sock->sk, &dst, + fl6)) { + netdev_dbg(dev, "no route to %pI6\n", &fl6->daddr); + return ERR_PTR(-ENETUNREACH); + } + if (dst->dev == dev) { /* is this necessary? */ + netdev_dbg(dev, "circular route to %pI6\n", &fl6->daddr); + dst_release(dst); + return ERR_PTR(-ELOOP); + } +
Quoted 8 lines
Documentation/networking/bareudp.txt
Quoted 5 lines
Documentation/networking/bareudp.txt new file +5
-0+ if (use_cache) + dst_cache_set_ip6(dst_cache, dst, &fl6->saddr); + return dst; +} +#endifThe route lookup logic is very similar to
vxlan_get_routeandvxlan6_get_route. Can be reused?
I had a look at the vxlan & geneve and it seems the corresponding functions in those modules are tightly coupled to the rest of the module design. More specifically wrt the ttl inheritance & the caching behaviour. It may not be possible for those modules to use a new generic API unless without a change in those module design.
The bareudp module is a generic L3 encapsulation module. It could be used to tunnel different l3 protocols. TTL Inheritance behaviour when tunnelled could be different for these inner protocols. Hence moving this function to a common place will make it tough to change it later when a need arises for a new protocol
Otherwise we should have more generic function which takes the generic IP header params as arguments. Then the point is we don’t need a function like that We can just fill up "struct flowi4" and call ip_route_output_key or dst_cache_get_ip4 to get the route table entry
Thanks
Martin
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 34 lines · Martin Varghese
Quoted 16 lines · Willem de Bruijn
Quoted 12 lines · Martin Varghese
From: Martin <[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.
Signed-off-by Martin Varghese <[email protected]>---
drivers/net/bareudp.c new file +2
-0+static int bareudp_udp_encap_recv (struct sock *sk,struct sk_buff *skb) +{Quoted 15 lines
drivers/net/bareudp.c line 112
Quoted 11 lines
drivers/net/bareudp.c new file +11
-0+skb_push (skb,sizeof (struct ethhdr )); + eh = (struct ethhdr *)skb->data; + eh->h_proto = proto; + +skb_reset_mac_header (skb); + skb->protocol =eth_type_trans (skb, bareudp->dev); +skb_postpull_rcsum (skb,eth_hdr (skb),ETH_HLEN ); + oiph =skb_network_header (skb); +skb_reset_network_header (skb); + +if (bareudp_get_sk_family (bs) ==AF_INET )This should be derived from packet contents, not socket state. Although the one implies the other, I imagine.
Quoted 1 line
The IP Stack check IP headers & puts the packet in the correct socket, hence checking the ip headers again is reduntant correct?
This parses the inner packet after decapsulation. The protocol stack has selected the socket based on the outer packet, right?
I guess the correctness comes from the administrator having configured the bareudp for this protocol type, so implicitly guarantees that no other inner packets will appear.
Also, the oiph pointer is a bit fragile now that a new mac header is constructed in the space that used to hold the encapsulation headers. I suppose it only updates eth->h_proto, which lies in the former udp header. More fundamentally, is moving the mac header needed at all, if the stack correctly uses skb_mac_header whenever it accesses also after decapsulation?
Quoted 99 lines
In geneve & vxlan it is done the same way.
Quoted 87 lines
Quoted 87 lines
drivers/net/bareudp.c new file +87
-0+static struct rtable *bareudp_get_v4_rt (struct sk_buff *skb, +struct net_device *dev, +struct bareudp_sock *bs4, +struct flowi4 *fl4, +const struct ip_tunnel_info *info) +{ +bool use_cache =ip_tunnel_dst_cache_usable (skb, info); +struct bareudp_dev *bareudp =netdev_priv (dev); +struct dst_cache *dst_cache; +struct rtable *rt =NULL ; +__u8 tos; + +if (!bs4) +return ERR_PTR (-EIO ); + +memset (fl4,0 ,sizeof (*fl4)); + fl4->flowi4_mark = skb->mark; + fl4->flowi4_proto =IPPROTO_UDP ; + fl4->daddr = info->key.u.ipv4.dst; + fl4->saddr = info->key.u.ipv4.src; + + tos = info->key.tos; + fl4->flowi4_tos =RT_TOS (tos); + + dst_cache = (struct dst_cache *)&info->dst_cache; +if (use_cache) { + rt =dst_cache_get_ip4 (dst_cache, &fl4->saddr); +if (rt) +return rt; + } + rt =ip_route_output_key (bareudp->net, fl4); +if (IS_ERR (rt)) { +netdev_dbg (dev,"no route to %pI4\n" , &fl4->daddr); +return ERR_PTR (-ENETUNREACH ); + } +if (rt->dst.dev == dev) {/* is this necessary? */ +netdev_dbg (dev,"circular route to %pI4\n" , &fl4->daddr); +ip_rt_put (rt); +return ERR_PTR (-ELOOP ); + } +if (use_cache) +dst_cache_set_ip4 (dst_cache, &rt->dst, fl4->saddr); +return rt; +} + +#if IS_ENABLED (CONFIG_IPV6 ) +static struct dst_entry *bareudp_get_v6_dst (struct sk_buff *skb, +struct net_device *dev, +struct bareudp_sock *bs6, +struct flowi6 *fl6, +const struct ip_tunnel_info *info) +{ +bool use_cache =ip_tunnel_dst_cache_usable (skb, info); +struct bareudp_dev *bareudp =netdev_priv (dev); +struct dst_entry *dst =NULL ; +struct dst_cache *dst_cache; +__u8 prio; + +if (!bs6) +return ERR_PTR (-EIO ); + +memset (fl6,0 ,sizeof (*fl6)); + fl6->flowi6_mark = skb->mark; + fl6->flowi6_proto =IPPROTO_UDP ; + fl6->daddr = info->key.u.ipv6.dst; + fl6->saddr = info->key.u.ipv6.src; + prio = info->key.tos; + + fl6->flowlabel =ip6_make_flowinfo (RT_TOS (prio), + info->key.label); + dst_cache = (struct dst_cache *)&info->dst_cache; +if (use_cache) { + dst =dst_cache_get_ip6 (dst_cache, &fl6->saddr); +if (dst) +return dst; + } +if (ipv6_stub->ipv6_dst_lookup (bareudp->net, bs6->sock->sk, &dst, + fl6)) { +netdev_dbg (dev,"no route to %pI6\n" , &fl6->daddr); +return ERR_PTR (-ENETUNREACH ); + } +if (dst->dev == dev) {/* is this necessary? */ +netdev_dbg (dev,"circular route to %pI6\n" , &fl6->daddr); +dst_release (dst); +return ERR_PTR (-ELOOP ); + } +Quoted 8 lines
drivers/net/bareudp.c line 357
Quoted 5 lines
drivers/net/bareudp.c new file +5
-0+if (use_cache) +dst_cache_set_ip6 (dst_cache, dst, &fl6->saddr); + return dst; +} +#endif The route lookup logic is very similar to
vxlan_get_routeandvxlan6_get_route. Can be reused?
Quoted 2 lines
I had a look at the vxlan & geneve and it seems the corresponding functions in those modules are tightly coupled to the rest of the module design. More specifically wrt the ttl inheritance & the caching behaviour. It may not be possible for those modules to use a new generic API unless without a change in those module design.
bareudp_get_v4_rt is identical to geneve_get_v4_rt down to the comment aside from
if ((tos == 1) && !geneve->collect_md) {
tos = ip_tunnel_get_dsfield(ip_hdr(skb), skb);
use_cache = false;
}Same for bareudp_get_v6_dst and geneve_get_v6_dst.
Worst case that one branch could be made conditional on a boolean argument? Maybe this collect_md part (eventually) makes sense to bareudp, as well.
Quoted 9 lines
The bareudp module is a generic L3 encapsulation module. It could be used to tunnel different l3 protocols. TTL Inheritance behaviour when tunnelled could be different for these inner protocols. Hence moving this function to a common place will make it tough to change it later when a need arises for a new protocol
Otherwise we should have more generic function which takes the generic IP header params as arguments. Then the point is we don’t need a function like that We can just fill up "struct flowi4" and call
ip_route_output_keyordst_cache_get_ip4to get the route table entryThanks
Martin
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Martin Varghese
Quoted 31 lines · Willem de Bruijn
Quoted 15 lines · Martin Varghese
From: Martin <[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.
Signed-off-by Martin Varghese <[email protected]>---
drivers/net/bareudp.c new file +3
-0+static int bareudp_udp_encap_recv (struct sock *sk,struct sk_buff *skb) +{ +skb_push (skb,sizeof (struct ethhdr ));drivers/net/bareudp.c line 112
Quoted 10 lines
drivers/net/bareudp.c new file +10
-0+ eh = (struct ethhdr *)skb->data; + eh->h_proto = proto; + +skb_reset_mac_header (skb); + skb->protocol =eth_type_trans (skb, bareudp->dev); +skb_postpull_rcsum (skb,eth_hdr (skb),ETH_HLEN ); + oiph =skb_network_header (skb); +skb_reset_network_header (skb); + +if (bareudp_get_sk_family (bs) ==AF_INET )This should be derived from packet contents, not socket state. Although the one implies the other, I imagine.
Quoted 5 lines
Quoted 1 line
The IP Stack check IP headers & puts the packet in the correct socket, hence checking the ip headers again is reduntant correct?
This parses the inner packet after decapsulation. The protocol stack has selected the socket based on the outer packet, right?
The check on socket " if (bareudp_get_sk_family(bs) == AF_INET)" was to find out the outer header was ipv4 and v6. Based on that TOS/ECN of outer header is derived from oiph->tos for ipv4 and using ipv6_get_dsfield(oipv6h) for ipv6. The TOS/ECN of inner header are derived in funtions IP_ECN_decapsulate & IP6_ECN_decapsulate.And they are derived from packet.
Quoted 4 lines
I guess the correctness comes from the administrator having configured the bareudp for this protocol type, so implicitly guarantees that no other inner packets will appear.
Yes that is correct.
Quoted 7 lines
Also, the oiph pointer is a bit fragile now that a new mac header is constructed in the space that used to hold the encapsulation headers. I suppose it only updates
eth->h_proto, which lies in the former udp header. More fundamentally, is moving the mac header needed at all, if the stack correctly usesskb_mac_headerwhenever it accesses also after decapsulation?
We need to move ethernet header. As there could be cases where the packet from a bareudp device is redirected via
other physical interface to a different network node for further processing.
I agree that oiph pointer is fragile, but since we are updating only proto field we are not corrupting the oiph.
But we can do ethernet header update once the oiph is no more used.It would entail setting the skb->protocol before calling IP_ECN_decapsulate
Quoted 110 lines
Quoted 99 lines
In geneve & vxlan it is done the same way.
Quoted 87 lines
Quoted 87 lines
drivers/net/bareudp.c new file +87
-0+static struct rtable *bareudp_get_v4_rt (struct sk_buff *skb, +struct net_device *dev, +struct bareudp_sock *bs4, +struct flowi4 *fl4, +const struct ip_tunnel_info *info) +{ +bool use_cache =ip_tunnel_dst_cache_usable (skb, info); +struct bareudp_dev *bareudp =netdev_priv (dev); +struct dst_cache *dst_cache; +struct rtable *rt =NULL ; +__u8 tos; + +if (!bs4) +return ERR_PTR (-EIO ); + +memset (fl4,0 ,sizeof (*fl4)); + fl4->flowi4_mark = skb->mark; + fl4->flowi4_proto =IPPROTO_UDP ; + fl4->daddr = info->key.u.ipv4.dst; + fl4->saddr = info->key.u.ipv4.src; + + tos = info->key.tos; + fl4->flowi4_tos =RT_TOS (tos); + + dst_cache = (struct dst_cache *)&info->dst_cache; +if (use_cache) { + rt =dst_cache_get_ip4 (dst_cache, &fl4->saddr); +if (rt) +return rt; + } + rt =ip_route_output_key (bareudp->net, fl4); +if (IS_ERR (rt)) { +netdev_dbg (dev,"no route to %pI4\n" , &fl4->daddr); +return ERR_PTR (-ENETUNREACH ); + } +if (rt->dst.dev == dev) {/* is this necessary? */ +netdev_dbg (dev,"circular route to %pI4\n" , &fl4->daddr); +ip_rt_put (rt); +return ERR_PTR (-ELOOP ); + } +if (use_cache) +dst_cache_set_ip4 (dst_cache, &rt->dst, fl4->saddr); +return rt; +} + +#if IS_ENABLED (CONFIG_IPV6 ) +static struct dst_entry *bareudp_get_v6_dst (struct sk_buff *skb, +struct net_device *dev, +struct bareudp_sock *bs6, +struct flowi6 *fl6, +const struct ip_tunnel_info *info) +{ +bool use_cache =ip_tunnel_dst_cache_usable (skb, info); +struct bareudp_dev *bareudp =netdev_priv (dev); +struct dst_entry *dst =NULL ; +struct dst_cache *dst_cache; +__u8 prio; + +if (!bs6) +return ERR_PTR (-EIO ); + +memset (fl6,0 ,sizeof (*fl6)); + fl6->flowi6_mark = skb->mark; + fl6->flowi6_proto =IPPROTO_UDP ; + fl6->daddr = info->key.u.ipv6.dst; + fl6->saddr = info->key.u.ipv6.src; + prio = info->key.tos; + + fl6->flowlabel =ip6_make_flowinfo (RT_TOS (prio), + info->key.label); + dst_cache = (struct dst_cache *)&info->dst_cache; +if (use_cache) { + dst =dst_cache_get_ip6 (dst_cache, &fl6->saddr); +if (dst) +return dst; + } +if (ipv6_stub->ipv6_dst_lookup (bareudp->net, bs6->sock->sk, &dst, + fl6)) { +netdev_dbg (dev,"no route to %pI6\n" , &fl6->daddr); +return ERR_PTR (-ENETUNREACH ); + } +if (dst->dev == dev) {/* is this necessary? */ +netdev_dbg (dev,"circular route to %pI6\n" , &fl6->daddr); +dst_release (dst); +return ERR_PTR (-ELOOP ); + } +Quoted 8 lines
drivers/net/bareudp.c line 357
Quoted 5 lines
drivers/net/bareudp.c new file +5
-0+if (use_cache) +dst_cache_set_ip6 (dst_cache, dst, &fl6->saddr); + return dst; +} +#endif The route lookup logic is very similar to
vxlan_get_routeandvxlan6_get_route. Can be reused?Quoted 2 lines
I had a look at the vxlan & geneve and it seems the corresponding functions in those modules are tightly coupled to the rest of the module design. More specifically wrt the ttl inheritance & the caching behaviour. It may not be possible for those modules to use a new generic API unless without a change in those module design.
bareudp_get_v4_rtis identical togeneve_get_v4_rtdown to the comment aside fromif ((tos == 1) && !geneve->collect_md) { tos = ip_tunnel_get_dsfield(ip_hdr(skb), skb); use_cache = false; }
Quoted 7 lines
Same for
bareudp_get_v6_dstandgeneve_get_v6_dst.Worst case that one branch could be made conditional on a boolean argument? Maybe this
collect_mdpart (eventually) makes sense to bareudp, as well.
Unlike Geneve, bareudp module is a generic L3 encapsulation module and it could be used to tunnel different L3 protocols. TTL inheritance requirements for these protocols will be different when tunnelled. For Example - TTL inheritance for MPLS & IP are different. And moving this function to a common place will make it tough for Geneve & bareudp if a new L3 protocol with new TTL inheritance requirements shows up
Quoted 10 lines
Quoted 10 lines
The bareudp module is a generic L3 encapsulation module. It could be used to tunnel different l3 protocols. TTL Inheritance behaviour when tunnelled could be different for these inner protocols. Hence moving this function to a common place will make it tough to change it later when a need arises for a new protocol
Otherwise we should have more generic function which takes the generic IP header params as arguments. Then the point is we don’t need a function like that We can just fill up "struct flowi4" and call
ip_route_output_keyordst_cache_get_ip4to get the route table entryThanks
Martin
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 61 lines · Martin Varghese
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Martin Varghese
Quoted 31 lines · Willem de Bruijn
Quoted 15 lines · Martin Varghese
From: Martin <[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.
Signed-off-by Martin Varghese <[email protected]>---
drivers/net/bareudp.c new file +3
-0+static int bareudp_udp_encap_recv (struct sock *sk,struct sk_buff *skb) +{ +skb_push (skb,sizeof (struct ethhdr ));drivers/net/bareudp.c line 112
Quoted 10 lines
drivers/net/bareudp.c new file +10
-0+ eh = (struct ethhdr *)skb->data; + eh->h_proto = proto; + +skb_reset_mac_header (skb); + skb->protocol =eth_type_trans (skb, bareudp->dev); +skb_postpull_rcsum (skb,eth_hdr (skb),ETH_HLEN ); + oiph =skb_network_header (skb); +skb_reset_network_header (skb); + +if (bareudp_get_sk_family (bs) ==AF_INET )This should be derived from packet contents, not socket state. Although the one implies the other, I imagine.
Quoted 5 lines
Quoted 1 line
The IP Stack check IP headers & puts the packet in the correct socket, hence checking the ip headers again is reduntant correct?
This parses the inner packet after decapsulation. The protocol stack has selected the socket based on the outer packet, right?
The check on socket " if (
bareudp_get_sk_family(bs)==AF_INET)" was to find out the outer header was ipv4 and v6. Based on that TOS/ECN of outer header is derived fromoiph->tosfor ipv4 and usingipv6_get_dsfield(oipv6h)for ipv6. The TOS/ECN of inner header are derived in funtionsIP_ECN_decapsulate& IP6_ECN_decapsulate.And they are derived from packet.Quoted 4 lines
I guess the correctness comes from the administrator having configured the bareudp for this protocol type, so implicitly guarantees that no other inner packets will appear.
Yes that is correct.
Quoted 7 lines
Also, the oiph pointer is a bit fragile now that a new mac header is constructed in the space that used to hold the encapsulation headers. I suppose it only updates
eth->h_proto, which lies in the former udp header. More fundamentally, is moving the mac header needed at all, if the stack correctly usesskb_mac_headerwhenever it accesses also after decapsulation?
Quoted 8 lines
We need to move ethernet header. As there could be cases where the packet from a bareudp device is redirected via
other physical interface to a different network node for further processing.
I agree that oiph pointer is fragile, but since we are updating only proto field we are not corrupting the oiph.
But we can do ethernet header update once the oiph is no more used.It would entail setting theskb->protocolbefore callingIP_ECN_decapsulateQuoted 1 line
Quoted 1 line
In geneve & vxlan it is done the same way.
I see, yes, geneve does the same thing.
Quoted 111 lines
Quoted 111 lines
Quoted 98 lines
Quoted 89 lines
Quoted 89 lines
drivers/net/bareudp.c new file +87
-0+static struct rtable *bareudp_get_v4_rt (struct sk_buff *skb, +struct net_device *dev, +struct bareudp_sock *bs4, +struct flowi4 *fl4, +const struct ip_tunnel_info *info) +{ +bool use_cache =ip_tunnel_dst_cache_usable (skb, info); +struct bareudp_dev *bareudp =netdev_priv (dev); +struct dst_cache *dst_cache; +struct rtable *rt =NULL ; +__u8 tos; + +if (!bs4) +return ERR_PTR (-EIO ); + +memset (fl4,0 ,sizeof (*fl4)); + fl4->flowi4_mark = skb->mark; + fl4->flowi4_proto =IPPROTO_UDP ; + fl4->daddr = info->key.u.ipv4.dst; + fl4->saddr = info->key.u.ipv4.src; + + tos = info->key.tos; + fl4->flowi4_tos =RT_TOS (tos); + + dst_cache = (struct dst_cache *)&info->dst_cache; +if (use_cache) { + rt =dst_cache_get_ip4 (dst_cache, &fl4->saddr); +if (rt) +return rt; + } + rt =ip_route_output_key (bareudp->net, fl4); +if (IS_ERR (rt)) { +netdev_dbg (dev,"no route to %pI4\n" , &fl4->daddr); +return ERR_PTR (-ENETUNREACH ); + } +if (rt->dst.dev == dev) {/* is this necessary? */ +netdev_dbg (dev,"circular route to %pI4\n" , &fl4->daddr); +ip_rt_put (rt); +return ERR_PTR (-ELOOP ); + } +if (use_cache) +dst_cache_set_ip4 (dst_cache, &rt->dst, fl4->saddr); +return rt; +} + +#if IS_ENABLED (CONFIG_IPV6 ) +static struct dst_entry *bareudp_get_v6_dst (struct sk_buff *skb, +struct net_device *dev, +struct bareudp_sock *bs6, +struct flowi6 *fl6, +const struct ip_tunnel_info *info) +{ +bool use_cache =ip_tunnel_dst_cache_usable (skb, info); +struct bareudp_dev *bareudp =netdev_priv (dev); +struct dst_entry *dst =NULL ; +struct dst_cache *dst_cache; +__u8 prio; + +if (!bs6) +return ERR_PTR (-EIO ); + +memset (fl6,0 ,sizeof (*fl6)); + fl6->flowi6_mark = skb->mark; + fl6->flowi6_proto =IPPROTO_UDP ; + fl6->daddr = info->key.u.ipv6.dst; + fl6->saddr = info->key.u.ipv6.src; + prio = info->key.tos; + + fl6->flowlabel =ip6_make_flowinfo (RT_TOS (prio), + info->key.label); + dst_cache = (struct dst_cache *)&info->dst_cache; +if (use_cache) { + dst =dst_cache_get_ip6 (dst_cache, &fl6->saddr); +if (dst) +return dst; + } +if (ipv6_stub->ipv6_dst_lookup (bareudp->net, bs6->sock->sk, &dst, + fl6)) { +netdev_dbg (dev,"no route to %pI6\n" , &fl6->daddr); +return ERR_PTR (-ENETUNREACH ); + } +if (dst->dev == dev) {/* is this necessary? */ +netdev_dbg (dev,"circular route to %pI6\n" , &fl6->daddr); +dst_release (dst); +return ERR_PTR (-ELOOP ); + } +Quoted 8 lines
drivers/net/bareudp.c line 357
Quoted 5 lines
drivers/net/bareudp.c new file +5
-0+if (use_cache) +dst_cache_set_ip6 (dst_cache, dst, &fl6->saddr); + return dst; +} +#endif The route lookup logic is very similar to
vxlan_get_routeandvxlan6_get_route. Can be reused?Quoted 2 lines
I had a look at the vxlan & geneve and it seems the corresponding functions in those modules are tightly coupled to the rest of the module design. More specifically wrt the ttl inheritance & the caching behaviour. It may not be possible for those modules to use a new generic API unless without a change in those module design.
bareudp_get_v4_rtis identical togeneve_get_v4_rtdown to the comment aside fromif ((tos == 1) && !geneve->collect_md) { tos = ip_tunnel_get_dsfield(ip_hdr(skb), skb); use_cache = false; }Same for
bareudp_get_v6_dstandgeneve_get_v6_dst.
Quoted 8 lines
Quoted 5 lines
Worst case that one branch could be made conditional on a boolean argument? Maybe this
collect_mdpart (eventually) makes sense to bareudp, as well.Unlike Geneve, bareudp module is a generic L3 encapsulation module and it could be used to tunnel different L3 protocols. TTL inheritance requirements for these protocols will be different when tunnelled. For Example - TTL inheritance for MPLS & IP are different. And moving this function to a common place will make it tough for Geneve & bareudp if a new L3 protocol with new TTL inheritance requirements shows up
But that is not in geneve_get_v4_rt and its bareudp/v6_dst variants.
I do think that with close scrutiny there is a lot more room for code deduplication. Just look at the lower half of geneve_rx and bareudp_udp_encap_recv, for instance. This, too, is identical down to the comments. Indeed, is it fair to say that geneve was taken as the basis for this device?
That said, even just avoiding duplicating those routing functions would be a good start.
I'm harping on this because in other examples in the past where a new device was created by duplicating instead of factoring out code implementations diverge over time in bad ways due to optimizations, features and most importantly bugfixes being applied only to one instance or the other. See for instance tun.c and tap.c.
Unrelated, an ipv6 socket can receive both ipv4 and ipv6 traffic if not setting the v6only bit, so does the device need to have separate sock4 and sock6 members? Both sockets currently lead to the same bareudp_udp_encap_recv callback function.
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 190 lines · Willem de Bruijn
Quoted 61 lines · Martin Varghese
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Martin Varghese
Quoted 31 lines · Willem de Bruijn
Quoted 15 lines · Martin Varghese
From: Martin <[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.
Signed-off-by Martin Varghese <[email protected]>---
drivers/net/bareudp.c new file +3
-0+static int bareudp_udp_encap_recv (struct sock *sk,struct sk_buff *skb) +{ +skb_push (skb,sizeof (struct ethhdr ));drivers/net/bareudp.c line 112
Quoted 10 lines
drivers/net/bareudp.c new file +10
-0+ eh = (struct ethhdr *)skb->data; + eh->h_proto = proto; + +skb_reset_mac_header (skb); + skb->protocol =eth_type_trans (skb, bareudp->dev); +skb_postpull_rcsum (skb,eth_hdr (skb),ETH_HLEN ); + oiph =skb_network_header (skb); +skb_reset_network_header (skb); + +if (bareudp_get_sk_family (bs) ==AF_INET )This should be derived from packet contents, not socket state. Although the one implies the other, I imagine.
Quoted 5 lines
Quoted 1 line
The IP Stack check IP headers & puts the packet in the correct socket, hence checking the ip headers again is reduntant correct?
This parses the inner packet after decapsulation. The protocol stack has selected the socket based on the outer packet, right?
The check on socket " if (
bareudp_get_sk_family(bs)==AF_INET)" was to find out the outer header was ipv4 and v6. Based on that TOS/ECN of outer header is derived fromoiph->tosfor ipv4 and usingipv6_get_dsfield(oipv6h)for ipv6. The TOS/ECN of inner header are derived in funtionsIP_ECN_decapsulate& IP6_ECN_decapsulate.And they are derived from packet.Quoted 4 lines
I guess the correctness comes from the administrator having configured the bareudp for this protocol type, so implicitly guarantees that no other inner packets will appear.
Yes that is correct.
Quoted 7 lines
Also, the oiph pointer is a bit fragile now that a new mac header is constructed in the space that used to hold the encapsulation headers. I suppose it only updates
eth->h_proto, which lies in the former udp header. More fundamentally, is moving the mac header needed at all, if the stack correctly usesskb_mac_headerwhenever it accesses also after decapsulation?Quoted 8 lines
We need to move ethernet header. As there could be cases where the packet from a bareudp device is redirected via
other physical interface to a different network node for further processing.
I agree that oiph pointer is fragile, but since we are updating only proto field we are not corrupting the oiph.
But we can do ethernet header update once the oiph is no more used.It would entail setting theskb->protocolbefore callingIP_ECN_decapsulateQuoted 1 line
Quoted 1 line
In geneve & vxlan it is done the same way.
I see, yes, geneve does the same thing.
Quoted 116 lines
Quoted 116 lines
Quoted 98 lines
Quoted 89 lines
Quoted 89 lines
drivers/net/bareudp.c new file +87
-0+static struct rtable *bareudp_get_v4_rt (struct sk_buff *skb, +struct net_device *dev, +struct bareudp_sock *bs4, +struct flowi4 *fl4, +const struct ip_tunnel_info *info) +{ +bool use_cache =ip_tunnel_dst_cache_usable (skb, info); +struct bareudp_dev *bareudp =netdev_priv (dev); +struct dst_cache *dst_cache; +struct rtable *rt =NULL ; +__u8 tos; + +if (!bs4) +return ERR_PTR (-EIO ); + +memset (fl4,0 ,sizeof (*fl4)); + fl4->flowi4_mark = skb->mark; + fl4->flowi4_proto =IPPROTO_UDP ; + fl4->daddr = info->key.u.ipv4.dst; + fl4->saddr = info->key.u.ipv4.src; + + tos = info->key.tos; + fl4->flowi4_tos =RT_TOS (tos); + + dst_cache = (struct dst_cache *)&info->dst_cache; +if (use_cache) { + rt =dst_cache_get_ip4 (dst_cache, &fl4->saddr); +if (rt) +return rt; + } + rt =ip_route_output_key (bareudp->net, fl4); +if (IS_ERR (rt)) { +netdev_dbg (dev,"no route to %pI4\n" , &fl4->daddr); +return ERR_PTR (-ENETUNREACH ); + } +if (rt->dst.dev == dev) {/* is this necessary? */ +netdev_dbg (dev,"circular route to %pI4\n" , &fl4->daddr); +ip_rt_put (rt); +return ERR_PTR (-ELOOP ); + } +if (use_cache) +dst_cache_set_ip4 (dst_cache, &rt->dst, fl4->saddr); +return rt; +} + +#if IS_ENABLED (CONFIG_IPV6 ) +static struct dst_entry *bareudp_get_v6_dst (struct sk_buff *skb, +struct net_device *dev, +struct bareudp_sock *bs6, +struct flowi6 *fl6, +const struct ip_tunnel_info *info) +{ +bool use_cache =ip_tunnel_dst_cache_usable (skb, info); +struct bareudp_dev *bareudp =netdev_priv (dev); +struct dst_entry *dst =NULL ; +struct dst_cache *dst_cache; +__u8 prio; + +if (!bs6) +return ERR_PTR (-EIO ); + +memset (fl6,0 ,sizeof (*fl6)); + fl6->flowi6_mark = skb->mark; + fl6->flowi6_proto =IPPROTO_UDP ; + fl6->daddr = info->key.u.ipv6.dst; + fl6->saddr = info->key.u.ipv6.src; + prio = info->key.tos; + + fl6->flowlabel =ip6_make_flowinfo (RT_TOS (prio), + info->key.label); + dst_cache = (struct dst_cache *)&info->dst_cache; +if (use_cache) { + dst =dst_cache_get_ip6 (dst_cache, &fl6->saddr); +if (dst) +return dst; + } +if (ipv6_stub->ipv6_dst_lookup (bareudp->net, bs6->sock->sk, &dst, + fl6)) { +netdev_dbg (dev,"no route to %pI6\n" , &fl6->daddr); +return ERR_PTR (-ENETUNREACH ); + } +if (dst->dev == dev) {/* is this necessary? */ +netdev_dbg (dev,"circular route to %pI6\n" , &fl6->daddr); +dst_release (dst); +return ERR_PTR (-ELOOP ); + } +Quoted 8 lines
drivers/net/bareudp.c line 357
Quoted 5 lines
drivers/net/bareudp.c new file +5
-0+if (use_cache) +dst_cache_set_ip6 (dst_cache, dst, &fl6->saddr); + return dst; +} +#endif The route lookup logic is very similar to
vxlan_get_routeandvxlan6_get_route. Can be reused?Quoted 2 lines
I had a look at the vxlan & geneve and it seems the corresponding functions in those modules are tightly coupled to the rest of the module design. More specifically wrt the ttl inheritance & the caching behaviour. It may not be possible for those modules to use a new generic API unless without a change in those module design.
bareudp_get_v4_rtis identical togeneve_get_v4_rtdown to the comment aside fromif ((tos == 1) && !geneve->collect_md) { tos = ip_tunnel_get_dsfield(ip_hdr(skb), skb); use_cache = false; }Same for
bareudp_get_v6_dstandgeneve_get_v6_dst.Worst case that one branch could be made conditional on a boolean argument? Maybe this
collect_mdpart (eventually) makes sense to bareudp, as well.
Quoted 6 lines
Quoted 3 lines
Unlike Geneve, bareudp module is a generic L3 encapsulation module and it could be used to tunnel different L3 protocols. TTL inheritance requirements for these protocols will be different when tunnelled. For Example - TTL inheritance for MPLS & IP are different. And moving this function to a common place will make it tough for Geneve & bareudp if a new L3 protocol with new TTL inheritance requirements shows up
But that is not in
geneve_get_v4_rtand its bareudp/v6_dst variants.
Geneve has a TTL inheritance code in the function
if ((tos == 1) && !geneve->collect_md) {
tos = ip_tunnel_get_dsfield(ip_hdr(skb), skb);
use_cache = false;
}Quoted 6 lines
I do think that with close scrutiny there is a lot more room for code deduplication. Just look at the lower half of
geneve_rxandbareudp_udp_encap_recv, for instance. This, too, is identical down to the comments. Indeed, is it fair to say that geneve was taken as the basis for this device?
Yes it is
Quoted 3 lines
That said, even just avoiding duplicating those routing functions would be a good start.
I propose to have a generic route function with the below prototype
iptunnel_get_v4_rt(struct sk_buff *skb,struct net_device *dev,struct bareudp_sock *bs4,struct flowi4 *fl4,
const struct ip_tunnel_info *info
bool use_cache )
And another patch series for other drivers to use this new function
Quoted 10 lines
I'm harping on this because in other examples in the past where a new device was created by duplicating instead of factoring out code implementations diverge over time in bad ways due to optimizations, features and most importantly bugfixes being applied only to one instance or the other. See for instance
tun.candtap.c.Unrelated, an ipv6 socket can receive both ipv4 and ipv6 traffic if not setting the v6only bit, so does the device need to have separate sock4 and sock6 members? Both sockets currently lead to the same
bareudp_udp_encap_recvcallback function.
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
In reply to Willem de BruijnQuoted 211 lines · Willem de Bruijn
Quoted 61 lines · Martin Varghese
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Martin Varghese
Quoted 31 lines · Willem de Bruijn
Quoted 15 lines · Martin Varghese
From: Martin <[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.
Signed-off-by Martin Varghese <[email protected]>---
drivers/net/bareudp.c new file +3
-0+static int bareudp_udp_encap_recv (struct sock *sk,struct sk_buff *skb) +{ +skb_push (skb,sizeof (struct ethhdr ));drivers/net/bareudp.c line 112
Quoted 10 lines
drivers/net/bareudp.c new file +10
-0+ eh = (struct ethhdr *)skb->data; + eh->h_proto = proto; + +skb_reset_mac_header (skb); + skb->protocol =eth_type_trans (skb, bareudp->dev); +skb_postpull_rcsum (skb,eth_hdr (skb),ETH_HLEN ); + oiph =skb_network_header (skb); +skb_reset_network_header (skb); + +if (bareudp_get_sk_family (bs) ==AF_INET )This should be derived from packet contents, not socket state. Although the one implies the other, I imagine.
Quoted 5 lines
Quoted 1 line
The IP Stack check IP headers & puts the packet in the correct socket, hence checking the ip headers again is reduntant correct?
This parses the inner packet after decapsulation. The protocol stack has selected the socket based on the outer packet, right?
The check on socket " if (
bareudp_get_sk_family(bs)==AF_INET)" was to find out the outer header was ipv4 and v6. Based on that TOS/ECN of outer header is derived fromoiph->tosfor ipv4 and usingipv6_get_dsfield(oipv6h)for ipv6. The TOS/ECN of inner header are derived in funtionsIP_ECN_decapsulate& IP6_ECN_decapsulate.And they are derived from packet.Quoted 4 lines
I guess the correctness comes from the administrator having configured the bareudp for this protocol type, so implicitly guarantees that no other inner packets will appear.
Yes that is correct.
Quoted 7 lines
Also, the oiph pointer is a bit fragile now that a new mac header is constructed in the space that used to hold the encapsulation headers. I suppose it only updates
eth->h_proto, which lies in the former udp header. More fundamentally, is moving the mac header needed at all, if the stack correctly usesskb_mac_headerwhenever it accesses also after decapsulation?Quoted 8 lines
We need to move ethernet header. As there could be cases where the packet from a bareudp device is redirected via
other physical interface to a different network node for further processing.
I agree that oiph pointer is fragile, but since we are updating only proto field we are not corrupting the oiph.
But we can do ethernet header update once the oiph is no more used.It would entail setting theskb->protocolbefore callingIP_ECN_decapsulateQuoted 1 line
Quoted 1 line
In geneve & vxlan it is done the same way.
I see, yes, geneve does the same thing.
Quoted 111 lines
Quoted 111 lines
Quoted 98 lines
Quoted 89 lines
Quoted 89 lines
drivers/net/bareudp.c new file +87
-0+static struct rtable *bareudp_get_v4_rt (struct sk_buff *skb, +struct net_device *dev, +struct bareudp_sock *bs4, +struct flowi4 *fl4, +const struct ip_tunnel_info *info) +{ +bool use_cache =ip_tunnel_dst_cache_usable (skb, info); +struct bareudp_dev *bareudp =netdev_priv (dev); +struct dst_cache *dst_cache; +struct rtable *rt =NULL ; +__u8 tos; + +if (!bs4) +return ERR_PTR (-EIO ); + +memset (fl4,0 ,sizeof (*fl4)); + fl4->flowi4_mark = skb->mark; + fl4->flowi4_proto =IPPROTO_UDP ; + fl4->daddr = info->key.u.ipv4.dst; + fl4->saddr = info->key.u.ipv4.src; + + tos = info->key.tos; + fl4->flowi4_tos =RT_TOS (tos); + + dst_cache = (struct dst_cache *)&info->dst_cache; +if (use_cache) { + rt =dst_cache_get_ip4 (dst_cache, &fl4->saddr); +if (rt) +return rt; + } + rt =ip_route_output_key (bareudp->net, fl4); +if (IS_ERR (rt)) { +netdev_dbg (dev,"no route to %pI4\n" , &fl4->daddr); +return ERR_PTR (-ENETUNREACH ); + } +if (rt->dst.dev == dev) {/* is this necessary? */ +netdev_dbg (dev,"circular route to %pI4\n" , &fl4->daddr); +ip_rt_put (rt); +return ERR_PTR (-ELOOP ); + } +if (use_cache) +dst_cache_set_ip4 (dst_cache, &rt->dst, fl4->saddr); +return rt; +} + +#if IS_ENABLED (CONFIG_IPV6 ) +static struct dst_entry *bareudp_get_v6_dst (struct sk_buff *skb, +struct net_device *dev, +struct bareudp_sock *bs6, +struct flowi6 *fl6, +const struct ip_tunnel_info *info) +{ +bool use_cache =ip_tunnel_dst_cache_usable (skb, info); +struct bareudp_dev *bareudp =netdev_priv (dev); +struct dst_entry *dst =NULL ; +struct dst_cache *dst_cache; +__u8 prio; + +if (!bs6) +return ERR_PTR (-EIO ); + +memset (fl6,0 ,sizeof (*fl6)); + fl6->flowi6_mark = skb->mark; + fl6->flowi6_proto =IPPROTO_UDP ; + fl6->daddr = info->key.u.ipv6.dst; + fl6->saddr = info->key.u.ipv6.src; + prio = info->key.tos; + + fl6->flowlabel =ip6_make_flowinfo (RT_TOS (prio), + info->key.label); + dst_cache = (struct dst_cache *)&info->dst_cache; +if (use_cache) { + dst =dst_cache_get_ip6 (dst_cache, &fl6->saddr); +if (dst) +return dst; + } +if (ipv6_stub->ipv6_dst_lookup (bareudp->net, bs6->sock->sk, &dst, + fl6)) { +netdev_dbg (dev,"no route to %pI6\n" , &fl6->daddr); +return ERR_PTR (-ENETUNREACH ); + } +if (dst->dev == dev) {/* is this necessary? */ +netdev_dbg (dev,"circular route to %pI6\n" , &fl6->daddr); +dst_release (dst); +return ERR_PTR (-ELOOP ); + } +Quoted 8 lines
drivers/net/bareudp.c line 357
Quoted 5 lines
drivers/net/bareudp.c new file +5
-0+if (use_cache) +dst_cache_set_ip6 (dst_cache, dst, &fl6->saddr); + return dst; +} +#endif The route lookup logic is very similar to
vxlan_get_routeandvxlan6_get_route. Can be reused?Quoted 2 lines
I had a look at the vxlan & geneve and it seems the corresponding functions in those modules are tightly coupled to the rest of the module design. More specifically wrt the ttl inheritance & the caching behaviour. It may not be possible for those modules to use a new generic API unless without a change in those module design.
bareudp_get_v4_rtis identical togeneve_get_v4_rtdown to the comment aside fromif ((tos == 1) && !geneve->collect_md) { tos = ip_tunnel_get_dsfield(ip_hdr(skb), skb); use_cache = false; }Same for
bareudp_get_v6_dstandgeneve_get_v6_dst.Quoted 8 lines
Quoted 5 lines
Worst case that one branch could be made conditional on a boolean argument? Maybe this
collect_mdpart (eventually) makes sense to bareudp, as well.Unlike Geneve, bareudp module is a generic L3 encapsulation module and it could be used to tunnel different L3 protocols. TTL inheritance requirements for these protocols will be different when tunnelled. For Example - TTL inheritance for MPLS & IP are different. And moving this function to a common place will make it tough for Geneve & bareudp if a new L3 protocol with new TTL inheritance requirements shows up
But that is not in
geneve_get_v4_rtand its bareudp/v6_dst variants.I do think that with close scrutiny there is a lot more room for code deduplication. Just look at the lower half of
geneve_rxandbareudp_udp_encap_recv, for instance. This, too, is identical down to the comments. Indeed, is it fair to say that geneve was taken as the basis for this device?That said, even just avoiding duplicating those routing functions would be a good start.
I'm harping on this because in other examples in the past where a new device was created by duplicating instead of factoring out code implementations diverge over time in bad ways due to optimizations, features and most importantly bugfixes being applied only to one instance or the other. See for instance
tun.candtap.c.
Quoted 4 lines
Unrelated, an ipv6 socket can receive both ipv4 and ipv6 traffic if not setting the v6only bit, so does the device need to have separate sock4 and sock6 members? Both sockets currently lead to the same
bareudp_udp_encap_recvcallback function.
I was checking this.AF_INET6 allows v6 and v4 mapped v6 address. And it doesnot allow both at the same time.So we need both sockets to support v4 and v6 at the same time.correct ?
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 15 lines
Quoted 15 lines
I do think that with close scrutiny there is a lot more room for code deduplication. Just look at the lower half of
geneve_rxandbareudp_udp_encap_recv, for instance. This, too, is identical down to the comments. Indeed, is it fair to say that geneve was taken as the basis for this device?That said, even just avoiding duplicating those routing functions would be a good start.
I'm harping on this because in other examples in the past where a new device was created by duplicating instead of factoring out code implementations diverge over time in bad ways due to optimizations, features and most importantly bugfixes being applied only to one instance or the other. See for instance
tun.candtap.c.
Quoted 8 lines
Quoted 4 lines
Unrelated, an ipv6 socket can receive both ipv4 and ipv6 traffic if not setting the v6only bit, so does the device need to have separate sock4 and sock6 members? Both sockets currently lead to the same
bareudp_udp_encap_recvcallback function.I was checking this.AF_INET6 allows v6 and v4 mapped v6 address. And it doesnot allow both at the same time.So we need both sockets to support v4 and v6 at the same time.correct ?
bareudp_create_sock currently creates an inet socket listening on INADDR_ANY and an inet6 socket listening on in6addr_any with v6only. If so, just the latter without v6only should offer the same.
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 20 lines · Willem de Bruijn
Quoted 20 lines
Quoted 19 lines
I do think that with close scrutiny there is a lot more room for code deduplication. Just look at the lower half of
geneve_rxandbareudp_udp_encap_recv, for instance. This, too, is identical down to the comments. Indeed, is it fair to say that geneve was taken as the basis for this device?That said, even just avoiding duplicating those routing functions would be a good start.
I'm harping on this because in other examples in the past where a new device was created by duplicating instead of factoring out code implementations diverge over time in bad ways due to optimizations, features and most importantly bugfixes being applied only to one instance or the other. See for instance
tun.candtap.c.Unrelated, an ipv6 socket can receive both ipv4 and ipv6 traffic if not setting the v6only bit, so does the device need to have separate sock4 and sock6 members? Both sockets currently lead to the same
bareudp_udp_encap_recvcallback function.
Quoted 7 lines
Quoted 3 lines
I was checking this.AF_INET6 allows v6 and v4 mapped v6 address. And it doesnot allow both at the same time.So we need both sockets to support v4 and v6 at the same time.correct ?
bareudp_create_sockcurrently creates an inet socket listening onINADDR_ANYand an inet6 socket listening onin6addr_anywith v6only. If so, just the latter without v6only should offer the same.
To receive and ipv4 packet in AF_INET6 packet we need to pass v4 address in v6 format( v4 mapped v6 address). Is it not ?
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 26 lines · Martin Varghese
Quoted 24 lines · Willem de Bruijn
Quoted 23 lines
Quoted 15 lines
I do think that with close scrutiny there is a lot more room for code deduplication. Just look at the lower half of
geneve_rxandbareudp_udp_encap_recv, for instance. This, too, is identical down to the comments. Indeed, is it fair to say that geneve was taken as the basis for this device?That said, even just avoiding duplicating those routing functions would be a good start.
I'm harping on this because in other examples in the past where a new device was created by duplicating instead of factoring out code implementations diverge over time in bad ways due to optimizations, features and most importantly bugfixes being applied only to one instance or the other. See for instance
tun.candtap.c.Quoted 4 lines
Unrelated, an ipv6 socket can receive both ipv4 and ipv6 traffic if not setting the v6only bit, so does the device need to have separate sock4 and sock6 members? Both sockets currently lead to the same
bareudp_udp_encap_recvcallback function.I was checking this.AF_INET6 allows v6 and v4 mapped v6 address. And it doesnot allow both at the same time.So we need both sockets to support v4 and v6 at the same time.correct ?
Quoted 6 lines
Quoted 3 lines
bareudp_create_sockcurrently creates an inet socket listening onINADDR_ANYand an inet6 socket listening onin6addr_anywith v6only. If so, just the latter without v6only should offer the same.To receive and ipv4 packet in
AF_INET6packet we need to pass v4 address in v6 format( v4 mapped v6 address). Is it not ?
If the bareudp device binds to a specific port on all local addresses, which I think it's doing judging from what it passes to udp_sock_create (but I may very well be missing something), then in6addr_any alone will suffice to receive both v6 and v4 packets.
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 4 lines · Willem de Bruijn
If the bareudp device binds to a specific port on all local addresses, which I think it's doing judging from what it passes to
udp_sock_create(but I may very well be missing something), thenin6addr_anyalone will suffice to receive both v6 and v4 packets.
This will not work when IPv6 is disabled, either by the kernel config or administratively. We do need to have two sockets.
Jiri
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 9 lines · Jiri Benc
Quoted 4 lines · Willem de Bruijn
If the bareudp device binds to a specific port on all local addresses, which I think it's doing judging from what it passes to
udp_sock_create(but I may very well be missing something), thenin6addr_anyalone will suffice to receive both v6 and v4 packets.This will not work when IPv6 is disabled, either by the kernel config or administratively. We do need to have two sockets.
This still needs only one socket, right? Just fall back to inet if ipv6 is disabled.
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 2 lines · Willem de Bruijn
This still needs only one socket, right? Just fall back to inet if ipv6 is disabled.
What would happen if IPv6 is disabled while the tunnel is operating?
Jiri
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 6 lines · Jiri Benc
Quoted 2 lines · Willem de Bruijn
This still needs only one socket, right? Just fall back to inet if ipv6 is disabled.
What would happen if IPv6 is disabled while the tunnel is operating?
How do you disable ipv6 at runtime?
rmmod is no longer allowed as of commit 8ce440610357 ("ipv6: do not allow ipv6 module to be removed"). The commit specifically mentions a dependency by vxlan; that sounds quite similar to this.
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
In reply to Willem de BruijnQuoted 32 lines · Willem de Bruijn
Quoted 30 lines · Martin Varghese
Quoted 27 lines · Willem de Bruijn
Quoted 15 lines
Quoted 15 lines
I do think that with close scrutiny there is a lot more room for code deduplication. Just look at the lower half of
geneve_rxandbareudp_udp_encap_recv, for instance. This, too, is identical down to the comments. Indeed, is it fair to say that geneve was taken as the basis for this device?That said, even just avoiding duplicating those routing functions would be a good start.
I'm harping on this because in other examples in the past where a new device was created by duplicating instead of factoring out code implementations diverge over time in bad ways due to optimizations, features and most importantly bugfixes being applied only to one instance or the other. See for instance
tun.candtap.c.Quoted 8 lines
Quoted 4 lines
Unrelated, an ipv6 socket can receive both ipv4 and ipv6 traffic if not setting the v6only bit, so does the device need to have separate sock4 and sock6 members? Both sockets currently lead to the same
bareudp_udp_encap_recvcallback function.I was checking this.AF_INET6 allows v6 and v4 mapped v6 address. And it doesnot allow both at the same time.So we need both sockets to support v4 and v6 at the same time.correct ?
bareudp_create_sockcurrently creates an inet socket listening onINADDR_ANYand an inet6 socket listening onin6addr_anywith v6only. If so, just the latter without v6only should offer the same.
Quoted 7 lines
Quoted 2 lines
To receive and ipv4 packet in
AF_INET6packet we need to pass v4 address in v6 format( v4 mapped v6 address). Is it not ?If the bareudp device binds to a specific port on all local addresses, which I think it's doing judging from what it passes to
udp_sock_create(but I may very well be missing something), thenin6addr_anyalone will suffice to receive both v6 and v4 packets.
Must invokde udp_encap_enable explicitly from baredudp module during setup time. Otherwise v4 packets will not land in encap_rcv handler.
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 37 lines · Martin Varghese
Quoted 35 lines · Willem de Bruijn
Quoted 32 lines · Martin Varghese
Quoted 20 lines · Willem de Bruijn
Quoted 20 lines
Quoted 19 lines
I do think that with close scrutiny there is a lot more room for code deduplication. Just look at the lower half of
geneve_rxandbareudp_udp_encap_recv, for instance. This, too, is identical down to the comments. Indeed, is it fair to say that geneve was taken as the basis for this device?That said, even just avoiding duplicating those routing functions would be a good start.
I'm harping on this because in other examples in the past where a new device was created by duplicating instead of factoring out code implementations diverge over time in bad ways due to optimizations, features and most importantly bugfixes being applied only to one instance or the other. See for instance
tun.candtap.c.Unrelated, an ipv6 socket can receive both ipv4 and ipv6 traffic if not setting the v6only bit, so does the device need to have separate sock4 and sock6 members? Both sockets currently lead to the same
bareudp_udp_encap_recvcallback function.Quoted 7 lines
Quoted 3 lines
I was checking this.AF_INET6 allows v6 and v4 mapped v6 address. And it doesnot allow both at the same time.So we need both sockets to support v4 and v6 at the same time.correct ?
bareudp_create_sockcurrently creates an inet socket listening onINADDR_ANYand an inet6 socket listening onin6addr_anywith v6only. If so, just the latter without v6only should offer the same.To receive and ipv4 packet in
AF_INET6packet we need to pass v4 address in v6 format( v4 mapped v6 address). Is it not ?
Quoted 7 lines
Quoted 4 lines
If the bareudp device binds to a specific port on all local addresses, which I think it's doing judging from what it passes to
udp_sock_create(but I may very well be missing something), thenin6addr_anyalone will suffice to receive both v6 and v4 packets.Must invokde
udp_encap_enableexplicitly from baredudp module during setup time. Otherwise v4 packets will not land inencap_rcvhandler.
The call to setup_udp_tunnel_sock should take care of that. The issue is probably that in udp_tunnel_encap_enable:
#if IS_ENABLED(CONFIG_IPV6)
if (sock->sk->sk_family == PF_INET6)
ipv6_stub->udpv6_encap_enable();
else
#endif
udp_encap_enable();does not call udp_encap_enable for IPv6 sockets. Likely because existing callers like vxlan always pass v6only = 1. Due to dual stack, PF_INET6 should enable both static keys.
Re: [PATCH net-next 1/2] UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
Quoted 57 lines · Willem de Bruijn
Quoted 37 lines · Martin Varghese
Quoted 35 lines · Willem de Bruijn
Quoted 32 lines · Martin Varghese
Quoted 20 lines · Willem de Bruijn
Quoted 20 lines
Quoted 19 lines
I do think that with close scrutiny there is a lot more room for code deduplication. Just look at the lower half of
geneve_rxandbareudp_udp_encap_recv, for instance. This, too, is identical down to the comments. Indeed, is it fair to say that geneve was taken as the basis for this device?That said, even just avoiding duplicating those routing functions would be a good start.
I'm harping on this because in other examples in the past where a new device was created by duplicating instead of factoring out code implementations diverge over time in bad ways due to optimizations, features and most importantly bugfixes being applied only to one instance or the other. See for instance
tun.candtap.c.Unrelated, an ipv6 socket can receive both ipv4 and ipv6 traffic if not setting the v6only bit, so does the device need to have separate sock4 and sock6 members? Both sockets currently lead to the same
bareudp_udp_encap_recvcallback function.Quoted 7 lines
Quoted 3 lines
I was checking this.AF_INET6 allows v6 and v4 mapped v6 address. And it doesnot allow both at the same time.So we need both sockets to support v4 and v6 at the same time.correct ?
bareudp_create_sockcurrently creates an inet socket listening onINADDR_ANYand an inet6 socket listening onin6addr_anywith v6only. If so, just the latter without v6only should offer the same.To receive and ipv4 packet in
AF_INET6packet we need to pass v4 address in v6 format( v4 mapped v6 address). Is it not ?Quoted 7 lines
Quoted 4 lines
If the bareudp device binds to a specific port on all local addresses, which I think it's doing judging from what it passes to
udp_sock_create(but I may very well be missing something), thenin6addr_anyalone will suffice to receive both v6 and v4 packets.Must invokde
udp_encap_enableexplicitly from baredudp module during setup time. Otherwise v4 packets will not land inencap_rcvhandler.The call to
setup_udp_tunnel_sockshould take care of that. The issue is probably that inudp_tunnel_encap_enable:#if IS_ENABLED(CONFIG_IPV6) if (sock->sk->sk_family == PF_INET6) ipv6_stub->udpv6_encap_enable(); else #endif udp_encap_enable();
Quoted 3 lines
does not call
udp_encap_enablefor IPv6 sockets. Likely because existing callers like vxlan always pass v6only = 1. Due to dual stack,PF_INET6should enable both static keys.
Thanks for your time.
PATCH 2/2 Special handling for IP & MPLS.
In reply to Martin VargheseFrom: Martin <[email protected]>
--- Documentation/networking/bareudp.txt | 18 ++++++++ drivers/net/bareudp.c | 82 +++++++++++++++++++++++++++++++++--- include/net/bareudp.h | 1 + include/uapi/linux/if_link.h | 1 + 4 files changed, 95 insertions(+), 7 deletions(-)
Documentation/networking/bareudp.txt +18 -0
@@ -9,6 +9,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 0x8847 (unicast) & 0x8847 (multicast). +IP proctocol can have ethertypes 0x0800 (v4) & 0x866 (v6). +This special handling can be enabled only for ethertype 0x0800 & 0x88847 with a +flag called extended mode. + Usage ------
@@ -21,3 +30,12 @@ This creates a bareudp tunnel device which tunnels L3 traffic with ethertype The device will listen on UDP port 6635 to receive traffic. b. ip link delete bareudp0 + +2. Device creation with extended mode enabled + +There are two ways to create a bareudp device for MPLS & IP with extended mode +enabled + +a. ip link add dev bareudp0 type bareudp dstport 6635 ethertype 0x8847 extmode 1 + +b. ip link add dev bareudp0 type bareudp dstport 6635 ethertype mpls
drivers/net/bareudp.c +75 -7
139 lines not on this page · raw message
include/net/bareudp.h +1 -0
@@ -10,6 +10,7 @@ struct bareudp_conf {__be16 ethertype;__be16 port;u16 sport_min; +bool ext_mode; }; struct net_device *bareudp_dev_create(struct net *net, const char *name,
include/uapi/linux/if_link.h +1 -0
@@ -586,6 +586,7 @@ enum {IFLA_BAREUDP_PORT ,IFLA_BAREUDP_ETHERTYPE ,IFLA_BAREUDP_SRCPORT_MIN , +IFLA_BAREUDP_EXTMODE , __IFLA_BAREUDP_MAX };
Signature · 1 line
1.8.3.1
Randy Dunlap
reviewerRe: [PATCH net-next 2/2] Special handling for IP & MPLS.
Quoted 5 lines · Martin Varghese
From: Martin <[email protected]>
Signed-off-by Martin Varghese <[email protected]>Signed-off-by Martin Varghese <[email protected]>
drop one of those.
Quoted 12 lines
--- Documentation/networking/bareudp.txt | 18 ++++++++ drivers/net/bareudp.c | 82 +++++++++++++++++++++++++++++++++--- include/net/bareudp.h | 1 + include/uapi/linux/if_link.h | 1 + 4 files changed, 95 insertions(+), 7 deletions(-)Documentation/networking/bareudp.txt +0
-0
Documentation/networking/bareudp.txt The Bareudp tunnel module provides a generic L3 encapsulation tunnelling · line 16
Quoted 8 lines
Documentation/networking/bareudp.txt +5
-0@@ -9,6 +9,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 0x8847 (unicast) & 0x8847 (multicast).
0x8848
Quoted 8 lines
Documentation/networking/bareudp.txt +4
-0+IP proctocol can have ethertypes 0x0800 (v4) & 0x866 (v6). +This special handling can be enabled only for ethertype 0x0800 & 0x88847 with a +flag called extended mode. + Usage ------
Documentation/networking/bareudp.txt This creates a bareudp tunnel device which tunnels L3 traffic with ethertype · line 37
Quoted 8 lines
Documentation/networking/bareudp.txt +5
-0@@ -21,3 +30,12 @@ This creates a bareudp tunnel device which tunnels L3 traffic with ethertype The device will listen on UDP port 6635 to receive traffic. b. ip link delete bareudp0 + +2. Device creation with extended mode enabled + +There are two ways to create a bareudp device for MPLS & IP with extended mode +enabled
end that sentence with a period. (or full stop)
Quoted 4 lines
Documentation/networking/bareudp.txt +4
-0+ +a. ip link add dev bareudp0 type bareudp dstport 6635 ethertype 0x8847 extmode 1 + +b. ip link add dev bareudp0 type bareudp dstport 6635 ethertype mpls
Signature · 1 line
~Randy
Re: [PATCH net-next 2/2] Special handling for IP & MPLS.
In reply to Martin VargheseQuoted 3 lines · Martin Varghese
From: Martin <[email protected]>
This commit would need a commit message.
Quoted 15 lines
Signed-off-by Martin Varghese <[email protected]>Signed-off-by Martin Varghese <[email protected]>--- Documentation/networking/bareudp.txt | 18 ++++++++ drivers/net/bareudp.c | 82 +++++++++++++++++++++++++++++++++--- include/net/bareudp.h | 1 + include/uapi/linux/if_link.h | 1 + 4 files changed, 95 insertions(+), 7 deletions(-)Documentation/networking/bareudp.txt +0
-0
Documentation/networking/bareudp.txt The Bareudp tunnel module provides a generic L3 encapsulation tunnelling · line 15
Quoted 7 lines
Documentation/networking/bareudp.txt +4
-0@@ -9,6 +9,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.
Special in what way?
Documentation/networking/bareudp.txt The Bareudp tunnel module provides a generic L3 encapsulation tunnelling · line 16
Quoted 1 line
Documentation/networking/bareudp.txt +1
-0+MPLS procotcol can have ethertypes 0x8847 (unicast) & 0x8847 (multicast).
0x8848. Use ETH_P_MPLS_UC and ETH_P_MPLS_MC instead of hard coding constants.
Documentation/networking/bareudp.txt The Bareudp tunnel module provides a generic L3 encapsulation tunnelling · line 18
Quoted 2 lines
Documentation/networking/bareudp.txt +2
-0+IP proctocol can have ethertypes 0x0800 (v4) & 0x866 (v6). +This special handling can be enabled only for ethertype 0x0800 & 0x88847 with a
Again typo.
Quoted 36 lines
Documentation/networking/bareudp.txt +11
-0+flag called extended mode. + Usage ------@@ -21,3 +30,12 @@ This creates a bareudp tunnel device which tunnels L3 traffic with ethertype The device will listen on UDP port 6635 to receive traffic. b. ip link delete bareudp0 + +2. Device creation with extended mode enabled + +There are two ways to create a bareudp device for MPLS & IP with extended mode +enabled + +a. ip link add dev bareudp0 type bareudp dstport 6635 ethertype 0x8847 extmode 1 + +b. ip link add dev bareudp0 type bareudp dstport 6635 ethertype mplsdrivers/net/bareudp.c +2
-1@@ -48,6 +48,7 @@ struct bareudp_dev {struct net_device *dev;/* netdev for bareudp tunnel */ __be16 ethertype;u16 sport_min; +bool ext_mode;struct bareudp_conf conf;struct bareudp_sock __rcu *sock4;/* IPv4 socket for bareudp tunnel */ #if IS_ENABLED (CONFIG_IPV6 )@@ -82,15 +83,64 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) goto drop; bareudp = bs->bareudp; - proto = bareudp->ethertype; +if (!bareudp)
drivers/net/bareudp.c static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) · line 96
Quoted 10 lines
drivers/net/bareudp.c +10
-0+ goto drop; + +if (bareudp->ethertype ==htons (ETH_P_IP )) { +struct iphdr *iphdr; + + iphdr = (struct iphdr *)(skb->data +BAREUDP_BASE_HLEN ); +if (iphdr->version ==4 ) { + proto = bareudp->ethertype; + }else if (bareudp->ext_mode && (iphdr->version ==6 )) { + proto =htons (ETH_P_IPV6 );
Verified packet length before reading at offset? Why does v6 needs extended mode, while v4 does not?
For any packet encapsulated in UDP, the inner packet type will be unknown, so needs to be configured on the device. That is not a special feature. FOU gives an example. My main concern is that this introduces a lot of code that nearly duplicates existing tunneling support. It is not clear to me that existing logic cannot be reused/extended.
Re: [PATCH net-next 2/2] Special handling for IP & MPLS.
Quoted 26 lines · Willem de Bruijn
Quoted 3 lines · Martin Varghese
From: Martin <[email protected]>
This commit would need a commit message.
Quoted 18 lines
Signed-off-by Martin Varghese <[email protected]>Signed-off-by Martin Varghese <[email protected]>--- Documentation/networking/bareudp.txt | 18 ++++++++ drivers/net/bareudp.c | 82 +++++++++++++++++++++++++++++++++--- include/net/bareudp.h | 1 + include/uapi/linux/if_link.h | 1 + 4 files changed, 95 insertions(+), 7 deletions(-)Documentation/networking/bareudp.txt +0
-0@@ -9,6 +9,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.
Quoted 7 lines
Documentation/networking/bareudp.txt The Bareudp tunnel module provides a generic L3 encapsulation tunnelling · line 15
Quoted 4 lines
Documentation/networking/bareudp.txt +4
-0+Special Handling +---------------- +The bareudp device supports special handling for MPLS & IP as they can have +multiple ethertypes.Special in what way?
The bareudp device associates a L3 protocol (ethertype) with a UDP port. For some protocols like MPLS,IP there exists multiplle ethertypes. IPV6 and IPV4 ethertypes for IP and MPLS unicast & Multicast ethertypes for MPLS. There coud be use cases where both MPLS unicast and multicast traffic need to be tunnelled using the same bareudp device.Similarly for ipv4 and ipv6.
This problem is solved by introducing a flag called extended mode which should be used be with IPv4 and MPLS unicast ethertypes.
The extended mode flag when used with IPV4 ethertype enables the bareudp device to recognize & support IPV4 & v6.
The extended mode flag when used with MPLS unicast ethertype enables bareudp device to recognize & support MPLS unicast & multicast.
Quoted 42 lines
Documentation/networking/bareudp.txt The Bareudp tunnel module provides a generic L3 encapsulation tunnelling · line 16
Quoted 1 line
Documentation/networking/bareudp.txt +1
-0+MPLS procotcol can have ethertypes 0x8847 (unicast) & 0x8847 (multicast).
0x8848. UseETH_P_MPLS_UCandETH_P_MPLS_MCinstead of hard coding constants.Documentation/networking/bareudp.txt The Bareudp tunnel module provides a generic L3 encapsulation tunnelling · line 18
Quoted 2 lines
Documentation/networking/bareudp.txt +2
-0+IP proctocol can have ethertypes 0x0800 (v4) & 0x866 (v6). +This special handling can be enabled only for ethertype 0x0800 & 0x88847 with aAgain typo.
Quoted 33 lines
Documentation/networking/bareudp.txt +11
-0+flag called extended mode. + Usage ------@@ -21,3 +30,12 @@ This creates a bareudp tunnel device which tunnels L3 traffic with ethertype The device will listen on UDP port 6635 to receive traffic. b. ip link delete bareudp0 + +2. Device creation with extended mode enabled + +There are two ways to create a bareudp device for MPLS & IP with extended mode +enabled + +a. ip link add dev bareudp0 type bareudp dstport 6635 ethertype 0x8847 extmode 1 + +b. ip link add dev bareudp0 type bareudp dstport 6635 ethertype mplsdrivers/net/bareudp.c +1
-0@@ -48,6 +48,7 @@ struct bareudp_dev {struct net_device *dev;/* netdev for bareudp tunnel */ __be16 ethertype;u16 sport_min; +bool ext_mode;struct bareudp_conf conf;struct bareudp_sock __rcu *sock4;/* IPv4 socket for bareudp tunnel */ #if IS_ENABLED (CONFIG_IPV6 )@@ -82,15 +83,64 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) goto drop;
Quoted 17 lines
drivers/net/bareudp.c static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) · line 96
Quoted 13 lines
drivers/net/bareudp.c +11
-1bareudp = bs->bareudp; - proto = bareudp->ethertype; +if (!bareudp) + goto drop; + +if (bareudp->ethertype ==htons (ETH_P_IP )) { +struct iphdr *iphdr; + + iphdr = (struct iphdr *)(skb->data +BAREUDP_BASE_HLEN ); +if (iphdr->version ==4 ) { + proto = bareudp->ethertype; + }else if (bareudp->ext_mode && (iphdr->version ==6 )) { + proto =htons (ETH_P_IPV6 );Verified packet length before reading at offset? Why does v6 needs extended mode, while v4 does not?
Explained above.
Quoted 6 lines
For any packet encapsulated in UDP, the inner packet type will be unknown, so needs to be configured on the device. That is not a special feature. FOU gives an example. My main concern is that this introduces a lot of code that nearly duplicates existing tunneling support. It is not clear to me that existing logic cannot be reused/extended.
Re: [PATCH net-next 2/2] Special handling for IP & MPLS.
Quoted 35 lines · Martin Varghese
Quoted 26 lines · Willem de Bruijn
Quoted 3 lines · Martin Varghese
From: Martin <[email protected]>
This commit would need a commit message.
Quoted 18 lines
Signed-off-by Martin Varghese <[email protected]>Signed-off-by Martin Varghese <[email protected]>--- Documentation/networking/bareudp.txt | 18 ++++++++ drivers/net/bareudp.c | 82 +++++++++++++++++++++++++++++++++--- include/net/bareudp.h | 1 + include/uapi/linux/if_link.h | 1 + 4 files changed, 95 insertions(+), 7 deletions(-)Documentation/networking/bareudp.txt +0
-0@@ -9,6 +9,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.Quoted 7 lines
Documentation/networking/bareudp.txt The Bareudp tunnel module provides a generic L3 encapsulation tunnelling · line 15
Quoted 4 lines
Documentation/networking/bareudp.txt +4
-0+Special Handling +---------------- +The bareudp device supports special handling for MPLS & IP as they can have +multiple ethertypes.Special in what way?
Quoted 5 lines
The bareudp device associates a L3 protocol (ethertype) with a UDP port. For some protocols like MPLS,IP there exists multiplle ethertypes. IPV6 and IPV4 ethertypes for IP and MPLS unicast & Multicast ethertypes for MPLS. There coud be use cases where both MPLS unicast and multicast traffic need to be tunnelled using the same bareudp device.Similarly for ipv4 and ipv6.
IP is already solved. I would focus on MPLS.
Also, the days where IPv6 is optional (and needs IPv4 enabled) are behind us, really.
Maybe just let the admin explicitly specify MPLS unicast, multicast or both, instead of defining a new extended label.
Re: [PATCH net-next 2/2] Special handling for IP & MPLS.
Quoted 44 lines · Willem de Bruijn
Quoted 35 lines · Martin Varghese
Quoted 26 lines · Willem de Bruijn
Quoted 3 lines · Martin Varghese
From: Martin <[email protected]>
This commit would need a commit message.
Quoted 18 lines
Signed-off-by Martin Varghese <[email protected]>Signed-off-by Martin Varghese <[email protected]>--- Documentation/networking/bareudp.txt | 18 ++++++++ drivers/net/bareudp.c | 82 +++++++++++++++++++++++++++++++++--- include/net/bareudp.h | 1 + include/uapi/linux/if_link.h | 1 + 4 files changed, 95 insertions(+), 7 deletions(-)Documentation/networking/bareudp.txt +0
-0@@ -9,6 +9,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.Quoted 7 lines
Documentation/networking/bareudp.txt The Bareudp tunnel module provides a generic L3 encapsulation tunnelling · line 15
Quoted 4 lines
Documentation/networking/bareudp.txt +4
-0+Special Handling +---------------- +The bareudp device supports special handling for MPLS & IP as they can have +multiple ethertypes.Special in what way?
Quoted 5 lines
The bareudp device associates a L3 protocol (ethertype) with a UDP port. For some protocols like MPLS,IP there exists multiplle ethertypes. IPV6 and IPV4 ethertypes for IP and MPLS unicast & Multicast ethertypes for MPLS. There coud be use cases where both MPLS unicast and multicast traffic need to be tunnelled using the same bareudp device.Similarly for ipv4 and ipv6.
Quoted 4 lines
IP is already solved. I would focus on MPLS.
Also, the days where IPv6 is optional (and needs IPv4 enabled) are behind us, really.
Ah sorry, there is nothing stopping someone from creating an ETH_P_IPV6 only device before this path.
Quoted 2 lines
Maybe just let the admin explicitly specify MPLS unicast, multicast or both, instead of defining a new extended label.
Deriving the inner protocol type from the outer protocol mode sounds fine, indeed.