From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH v1 net-next] ip6_tunnel: Adding support of mapping rules for MAP-E tunnel Date: Fri, 23 Nov 2018 11:06:03 -0800 (PST) Message-ID: <20181123.110603.766843141551335784.davem@davemloft.net> References: <20181120015324.24394-1-felix.jia@alliedtelesis.co.nz> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: blair.steven@alliedtelesis.co.nz, netdev@vger.kernel.org, sheena.mira-ato@alliedtelesis.co.nz, masakazu.asama@gmail.com To: felix.jia@alliedtelesis.co.nz Return-path: Received: from shards.monkeyblade.net ([23.128.96.9]:32780 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437213AbeKXFvj (ORCPT ); Sat, 24 Nov 2018 00:51:39 -0500 In-Reply-To: <20181120015324.24394-1-felix.jia@alliedtelesis.co.nz> Sender: netdev-owner@vger.kernel.org List-ID: From: Felix Jia Date: Tue, 20 Nov 2018 14:53:24 +1300 > +struct ip6_tnl_rule { > + u8 version; > + struct in6_addr ipv6_subnet; > + u8 ipv6_prefixlen; > + struct in_addr ipv4_subnet; > + u8 ipv4_prefixlen; > + u8 ea_length; > + u8 psid_offset; Please arrange the members of this structure better so that there is no internal padding. Putting a u8 before an in6_addr puts at least 3 bytes of wasted padding after the u8, for example. > + u8 *ptr; > + struct iphdr *icmpiph = NULL; > + struct tcphdr *tcph, *icmptcph; > + struct udphdr *udph, *icmpudph; > + struct icmphdr *icmph, *icmpicmph; Please arrange all local variables from longest to shortest line, ie. reverse christmas tree format. > + int i, pbw0, pbi0, pbi1; > + __u32 addr[4]; > + __u32 psid = 0; > + __u32 mask = 0; > + __u32 a = ntohl(addr4); > + __u16 p = ntohs(port4); > + int psid_prefix_length = 0; > + int psid_mask; > + __u32 id0 = 0; > + __u32 id1 = 0; Likewise. Also, many of these explicit "= 0" initializations are unnecessary and make the declarations more ugly than they need to be. > +static void > +ip6_tnl_mape_dst(struct net_device *dev, struct sk_buff *skb, > + struct flowi6 *fl6) > +{ > + struct ip6_tnl *t = netdev_priv(dev); > + struct iphdr *iph; > + __be32 saddr4, daddr4, addr; > + __be16 sport4, dport4, port; > + __u8 proto; > + int icmperr; > + struct ip6_tnl_rule *mr = NULL; Reverse christmas tree please. > +static struct ip6_tnl __rcu ** > +ip6_tnl_bucket_r_any(struct ip6_tnl_net *ip6n, const struct __ip6_tnl_parm *p) > +{ > + const struct in6_addr *local = &p->laddr; > + unsigned int h = 0; > + int prio = 0; > + struct in6_addr any; Likewise. And so on and so forth for your entire patch.