opnsense-src/sys
David Sips 6c6e7cbe47 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 entries.
trunk-hwidth will still be 5. If an entry is removed, vlan_remhash() will
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 called. 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 VLAN is
added. The table will again be expanded. If an entry is then removed, again
the table is contracted.

If the number of VLANS stays in the range of 128-512, each time an insert
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 = 1 << (trunk->hwidth - 1);

PR:		265382
Reviewed by:	kp
MFC after:	2 weeks
Sponsored by:	NetApp, Inc.

(cherry picked from commit 151abc80cd)
2022-08-05 13:54:25 +02:00
..
amd64 Fix unused variable warning in amd64's pmap.c 2022-07-29 20:30:00 +02:00
arm busdma: _bus_dmamap_addseg repaired 2022-07-12 11:26:11 -05:00
arm64 arm64, qoriq_therm: fix handling sites on version 1 and 2 2022-07-26 22:41:47 +00:00
bsm
cam ses: don't panic if disk elements have really weird descriptors 2022-07-24 09:41:18 -06:00
cddl Adjust fbt_unload() definition to avoid clang 15 warning 2022-07-24 13:00:08 +02:00
compat Adjust linux_get_char_devices() definition to avoid clang 15 warning 2022-07-27 21:17:22 +02:00
conf Suppress -Wstrict-prototypes for several zlib files 2022-07-29 20:29:59 +02:00
contrib rtw88: update Realtek's rtw88 driver 2022-07-01 13:49:02 +00:00
crypto crypto: Add an API supporting curve25519. 2022-07-13 12:28:41 -07:00
ddb Adjust db_flush_line() definition to avoid clang 15 warning 2022-07-23 10:56:44 +02:00
dev hidbus(4): Align refcount checks for hidbus_intr_start() and hidbus_intr_stop(). 2022-08-04 15:17:56 +02:00
dts add overlay for enabling i2c1 on allwinner h3 2022-02-09 11:35:59 +02:00
fs nfsd: Fix CreateSession for an established ClientID 2022-07-28 13:20:33 -07:00
gdb gdb(4): Do not use run length encoding for 3-symbol repetitions 2022-02-04 20:58:34 -05:00
geom Adjust function definition in geom_subr.c to avoid clang 15 warnings 2022-07-29 20:31:13 +02:00
gnu bwn: eliminate dead writes in BWN_GPL_PHY 2022-05-12 08:56:04 -04:00
i386 set_cputicker: use a bool 2022-07-04 13:37:05 -03:00
isa Adjust function definition in isa's pnp.c to avoid clang 15 warning 2022-08-01 20:07:10 +02:00
kern sockets: fix setsockopt(SO_RCVTIMEO) on a listening socket 2022-08-03 16:28:38 -07:00
kgssapi
libkern libkern: Fix a typo in a source code comment 2022-06-10 14:24:24 +02:00
mips mips busdma: expunge an extra closing brace 2022-07-12 13:47:44 -05:00
modules Remove unnecessary terminating slash in iscsi module Makefile 2022-08-01 20:07:17 +02:00
net if_vlan: avoid hash table thrashing when adding and removing entries 2022-08-05 13:54:25 +02:00
net80211 Fix unused variable warning in ieee80211_proto.c 2022-07-29 20:29:09 +02:00
netgraph Adjust ng_{name,ID}_rehash() definitions to avoid clang 15 warnings 2022-07-29 20:28:08 +02:00
netinet Adjust sctp_drain() definition to avoid clang 15 warning 2022-07-29 20:28:09 +02:00
netinet6 Adjust function definition in nd6.c to avoid clang 15 warnings 2022-07-29 20:29:08 +02:00
netipsec Fix unused variable warning in netipsec's key_debug.c 2022-07-29 20:31:13 +02:00
netpfil Adjust function definitions in if_pfsync.c to avoid clang 15 warnings 2022-07-29 20:28:08 +02:00
netsmb
nfs nfs: do not panic on bootpc_init when no interfaces are found 2022-05-06 09:14:28 -03:00
nfsclient
nfsserver
nlm
ofed ibcore: Fix sysfs registration error flow 2022-06-27 10:14:49 +02:00
opencrypto crypto: Validate return values from CRYPTODEV_PROCESS() 2022-07-15 12:33:49 -04:00
powerpc busdma: _bus_dmamap_addseg repaired 2022-07-12 11:26:11 -05:00
riscv riscv: Avoid passing invalid addresses to pmap_fault() 2022-08-04 09:57:15 -04:00
rpc Adjust local_rpcb() definition to avoid clang 15 warning 2022-07-27 21:17:23 +02:00
security sysent: Get rid of bogus sys/sysent.h include. 2022-06-17 22:35:31 +03:00
sys Add ELFCOMPRESS_ZSTD ELF compression constant 2022-08-03 20:35:42 -04:00
teken teken: color #3 is yellow not brown - use TC_YELLOW as the name 2022-05-03 14:20:44 -04:00
tests
tools firmware: Map '@' in filenames to '_' in symbols. 2022-07-13 09:19:51 -07:00
ufs Adjust function definitions in ufs_dirhash.c to avoid clang 15 warnings 2022-07-29 20:30:01 +02:00
vm vm_mmap: Remove obsolete code and comments from vm_mmap() 2022-07-27 09:50:55 -04:00
x86 x86: Add a required store-load barrier in cpu_idle() 2022-08-01 10:12:49 -04:00
xdr
xen Create wrapper for Giant taken for newbus 2022-06-21 17:13:20 +02:00
Makefile