From: Eric Dumazet <eric.dumazet@gmail.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Pravin B Shelar <pshelar@nicira.com>,
David Miller <davem@davemloft.net>,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next] ip: initialize hash list
Date: Mon, 22 Jul 2013 08:17:53 -0700 [thread overview]
Message-ID: <1374506273.4990.13.camel@edumazet-glaptop> (raw)
In-Reply-To: <20130720102657.768a11ea@nehalam.linuxnetplumber.net>
On Sat, 2013-07-20 at 10:26 -0700, Stephen Hemminger wrote:
> Rather than relying on the assumption that zero means empty on
> hash list head, the code should use the initialization macro.
> Same effect, but follows API and avoids future breakage if hlist
> implementation changes.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>
>
> --- a/net/ipv4/ip_tunnel.c 2013-07-19 09:12:37.213529343 -0700
> +++ b/net/ipv4/ip_tunnel.c 2013-07-19 09:37:00.960764421 -0700
> @@ -838,10 +838,15 @@ int ip_tunnel_init_net(struct net *net,
> {
> struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id);
> struct ip_tunnel_parm parms;
> + unsigned i;
>
> - itn->tunnels = kzalloc(IP_TNL_HASH_SIZE * sizeof(struct hlist_head), GFP_KERNEL);
> + itn->tunnels = kmalloc(IP_TNL_HASH_SIZE * sizeof(struct hlist_head),
> + GFP_KERNEL);
> if (!itn->tunnels)
> return -ENOMEM;
> +
> + for (i = 0; i < IP_TNL_HASH_SIZE; i++)
> + INIT_HLIST_HEAD(&itn->tunnels[i]);
>
What about adding a variant of INIT_HLIST_HEAD() that does nothing for
already cleared memory ?
prev parent reply other threads:[~2013-07-22 15:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-20 17:26 [PATCH net-next] ip: initialize hash list Stephen Hemminger
2013-07-20 17:46 ` Joe Perches
2013-07-22 14:52 ` Stephen Hemminger
2013-07-22 15:06 ` Joe Perches
2013-07-22 15:15 ` Eric Dumazet
2013-07-22 15:31 ` Joe Perches
2013-07-20 19:20 ` David Miller
2013-07-20 20:28 ` Joe Perches
2013-07-22 15:17 ` Eric Dumazet [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=1374506273.4990.13.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=pshelar@nicira.com \
--cc=stephen@networkplumber.org \
/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;
as well as URLs for NNTP newsgroup(s).