Subject: Re: [PATCH net-next v7 1/2] net: UDP tunnel encapsulation module for tunnelling different protocols like MPLS,IP,NSH etc.

From: Martin Varghese <[email-masked]>
Date: Sun, 23 Feb 2020 21:44:47 +0530

On Sun, Feb 16, 2020 at 09:16:34PM -0800, Willem de Bruijn wrote:
> > > There are also a couple of reverse christmas tree violations.
> > >
> > In Bareudp.c correct?
> 
> Right. Like bareudp_udp_encap_recv.
> 
> > Wondering if there is any flag in checkpatch to catch them?
> 
> It has come up, but I don't believe anything is merged.
> 
> > > > +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;
> > > > +       }
> > > > +#endif
> > >
> > > This 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.
> > Yes , We need not initialize fl4 when cache is used.
> > But i didnt get your point on restructuing to have a single #ifdef block
> > Could you please give more details
> 
> Actually, I was mistaken, missing the third #ifdef block that calls
> dst_cache_set_ip[46]. But the type of info->dst_cache is struct
> dst_cache, so I don't think the explicit cast or additional pointer
> variable (and with that the first #ifdef) is needed. But it's clearly
> not terribly important.
I tried to remove the additional pointer variable and the explicit cast.But Compiler warns as 
the info is a const variable (same for geneve)

So shall we keep as it is ?