From: David Ahern <dsahern@gmail.com>
To: 张凯 <zhangkaiheb@126.com>
Cc: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org,
kuba@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipv4: only allow increasing fib_info_hash_size
Date: Tue, 12 Oct 2021 20:33:19 -0600 [thread overview]
Message-ID: <9404e2d8-0976-1726-5f08-c277cdc14945@gmail.com> (raw)
In-Reply-To: <3bd88b51.6c7.17c77339c10.Coremail.zhangkaiheb@126.com>
On 10/12/21 7:10 PM, 张凯 wrote:
>
> 1) Below shift operation will set fib_info_hash_size to zero if there
> are so many routes:
> unsigned int new_size = fib_info_hash_size << 1;
>
> This will wrap value of fib_info_hash_size, and a lot of fib_info
> will insert to a small hash bucket.
> so this patch disables above wrap.
> 2) Check whether fib_info_hash_size is zero only needed after allocation
> failed:
> if (!new_info_hash || !new_laddrhash) {
>
>
why not something simpler like this:
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 3364cb9c67e0..5c4bd1cebe0a 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1401,6 +1401,10 @@ struct fib_info *fib_create_info(struct
fib_config *cfg,
if (!new_size)
new_size = 16;
+
+ if (new_size < fib_info_hash_size)
+ goto failure;
+
bytes = new_size * sizeof(struct hlist_head *);
new_info_hash = fib_info_hash_alloc(bytes);
new_laddrhash = fib_info_hash_alloc(bytes);
next prev parent reply other threads:[~2021-10-13 2:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 11:06 [PATCH] ipv4: only allow increasing fib_info_hash_size zhang kai
2021-10-12 13:55 ` David Ahern
[not found] ` <3bd88b51.6c7.17c77339c10.Coremail.zhangkaiheb@126.com>
2021-10-13 2:33 ` David Ahern [this message]
[not found] ` <5219d023.14d1.17c778a9a18.Coremail.zhangkaiheb@126.com>
[not found] ` <1e3f52c3.350f.17c78afcc56.Coremail.zhangkaiheb@126.com>
2021-10-14 2:51 ` David Ahern
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=9404e2d8-0976-1726-5f08-c277cdc14945@gmail.com \
--to=dsahern@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.org \
--cc=zhangkaiheb@126.com \
/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).