From: David Miller <davem@davemloft.net>
To: felix.jia@alliedtelesis.co.nz
Cc: blair.steven@alliedtelesis.co.nz, netdev@vger.kernel.org,
sheena.mira-ato@alliedtelesis.co.nz, masakazu.asama@gmail.com
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) [thread overview]
Message-ID: <20181123.110603.766843141551335784.davem@davemloft.net> (raw)
In-Reply-To: <20181120015324.24394-1-felix.jia@alliedtelesis.co.nz>
From: Felix Jia <felix.jia@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.
prev parent reply other threads:[~2018-11-24 5:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-20 1:53 [PATCH v1 net-next] ip6_tunnel: Adding support of mapping rules for MAP-E tunnel Felix Jia
2018-11-23 19:06 ` David Miller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181123.110603.766843141551335784.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=blair.steven@alliedtelesis.co.nz \
--cc=felix.jia@alliedtelesis.co.nz \
--cc=masakazu.asama@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=sheena.mira-ato@alliedtelesis.co.nz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox