Re: [PATCH net-next v7 1/2] net: UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: 2020-02-16 16:59:12
On Fri, Feb 14, 2020 at 11:20 PM Martin Varghese [off-list ref] wrote:
From: Martin Varghese <redacted> 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 <redacted>
A few small points
net/ipv4/route.c | 48 +++ net/ipv6/ip6_output.c | 70 ++++
Both protocols have route.c and ip(6)_output.c files. For the sake of consistency, both should ideally be in route.c. Did you choose ip6_output.c for a reason? There are also a couple of reverse christmas tree violations.
+struct rtable *ip_route_output_tunnel(struct sk_buff *skb,
+ struct net_device *dev,
+ struct net *net, __be32 *saddr,
+ const struct ip_tunnel_info *info,
+ u8 protocol, bool use_cache)
+{
+#ifdef CONFIG_DST_CACHE
+ struct dst_cache *dst_cache;
+#endif
+ struct rtable *rt = NULL;
+ struct flowi4 fl4;
+ __u8 tos;
+
+ memset(&fl4, 0, sizeof(fl4));
+ fl4.flowi4_mark = skb->mark;
+ fl4.flowi4_proto = protocol;
+ fl4.daddr = info->key.u.ipv4.dst;
+ fl4.saddr = info->key.u.ipv4.src;
+
+ tos = info->key.tos;
+ fl4.flowi4_tos = RT_TOS(tos);
+#ifdef CONFIG_DST_CACHE
+ dst_cache = (struct dst_cache *)&info->dst_cache;
+ if (use_cache) {
+ rt = dst_cache_get_ip4(dst_cache, saddr);
+ if (rt)
+ return rt;
+ }
+#endifThis is the same in geneve, but no need to initialize fl4 on a cache hit. Then can also be restructured to only have a single #ifdef block.