提交 1f90978d 编写于 作者: W Willy Tarreau 提交者: Zheng Zengkai

tcp: use different parts of the port_offset for index and offset

stable inclusion
from stable-v5.10.125
commit dd46a868fcfdf3aac8ffb20b2321e174a0156fb2
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6EY

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=dd46a868fcfdf3aac8ffb20b2321e174a0156fb2

--------------------------------

commit 9e9b70ae upstream.

Amit Klein suggests that we use different parts of port_offset for the
table's index and the port offset so that there is no direct relation
between them.

Cc: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Moshe Kol <moshe.kol@mail.huji.ac.il>
Cc: Yossi Gilad <yossi.gilad@mail.huji.ac.il>
Cc: Amit Klein <aksecurity@gmail.com>
Reviewed-by: NEric Dumazet <edumazet@google.com>
Signed-off-by: NWilly Tarreau <w@1wt.eu>
Signed-off-by: NJakub Kicinski <kuba@kernel.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 07505f0d
...@@ -778,7 +778,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row, ...@@ -778,7 +778,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
net_get_random_once(table_perturb, sizeof(table_perturb)); net_get_random_once(table_perturb, sizeof(table_perturb));
index = hash_32(port_offset, INET_TABLE_PERTURB_SHIFT); index = hash_32(port_offset, INET_TABLE_PERTURB_SHIFT);
offset = READ_ONCE(table_perturb[index]) + port_offset; offset = READ_ONCE(table_perturb[index]) + (port_offset >> 32);
offset %= remaining; offset %= remaining;
/* In first pass we try ports of @low parity. /* In first pass we try ports of @low parity.
* inet_csk_get_port() does the opposite choice. * inet_csk_get_port() does the opposite choice.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册