Date: Fri, 22 Jul 2022 23:20:04 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 265382] VLAN hash-list table thrashing when adding and removing entries Message-ID: <bug-265382-227-Rsg7Z9vXDO@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-265382-227@https.bugs.freebsd.org/bugzilla/> References: <bug-265382-227@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D265382 --- Comment #1 from commit-hook@FreeBSD.org --- A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=3D151abc80cde778bc18b91c334d07fbd52= bbb38fb commit 151abc80cde778bc18b91c334d07fbd52bbb38fb Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2022-07-22 17:17:04 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2022-07-22 17:18:41 +0000 if_vlan: avoid hash table thrashing when adding and removing entries vlan_remhash() uses incorrect value for b. When using the default value for VLAN_DEF_HWIDTH (4), the VLAN hash-list table expands from 16 chains to 32 chains as the 129th entry is added. trunk->hwidth becomes 5. Say a few more entries are added and there are now 135 entri= es. trunk-hwidth will still be 5. If an entry is removed, vlan_remhash() wi= ll calculate a value of 32 for b. refcnt will be decremented to 134. The if comparison at line 473 will return true and vlan_growhash() will be cal= led. The VLAN hash-list table will be compressed from 32 chains wide to 16 chains wide. hwidth will become 4. This is an error, and it can be seen when a new V= LAN is added. The table will again be expanded. If an entry is then removed, a= gain the table is contracted. If the number of VLANS stays in the range of 128-512, each time an inse= rt follows a remove, the table will expand. Each time a remove follows an insert, the table will be contracted. The fix is simple. The line 473 should test that the number of entries = has decreased such that the table should be contracted using what would be = the new value of hwidth. line 467 should be: b =3D 1 << (trunk->hwidth - 1); PR: 265382 Reviewed by: kp MFC after: 2 weeks Sponsored by: NetApp, Inc. sys/net/if_vlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-265382-227-Rsg7Z9vXDO>