From: Felix Jia <felix....@alliedtelesis.co.nz>
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.

Reply via email to