From nobody Fri Jul 22 14:29:52 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4LqBfT1hYVz4XLt1 for ; Fri, 22 Jul 2022 14:29:53 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LqBfS670Sz3HrN for ; Fri, 22 Jul 2022 14:29:52 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4LqBfS4ww1z142c for ; Fri, 22 Jul 2022 14:29:52 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 26METqYR076925 for ; Fri, 22 Jul 2022 14:29:52 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 26METqVJ076924 for bugs@FreeBSD.org; Fri, 22 Jul 2022 14:29:52 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 265382] VLAN hash-list table thrashing when adding and removing entries Date: Fri, 22 Jul 2022 14:29:52 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: dsips@netapp.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter cc Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658500192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4sZ68K5p3oxV1lT6ASbIA96KPhzUc6ZcL8Dzjr7AxH8=; b=sWP/voq8fgtJvmY/oCLeQpCFG0tCcf2dm2qepSdirG9Ya9Z6ixHQMr+IkPNfc0KIZHy3JT EfDvugRIl/mHdfBT5TsWkQ/ClqgDERkZ/U0cG6Jvr1Q55yvZ2CxknyoIn2zm3LTppxc93w oXKLJiRuhLUx5M5l8DSPSsu+b6fX1hD6fsXoDHysQeJnsaazhoDxgrWFX7NjoNINuuUt11 4dc3TaTFMfKNzJrUtDQg/1duPzOPc8+gAlPDP5xmfSIL4yxQAmCLuRHCKKkM/2yaM2Jl6w R59FKFEEHz5ngwtZO2aYg1sbKG5XGaOxDoqC8eKtnlm/dsj2K1cBw4IbF2dmKg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658500192; a=rsa-sha256; cv=none; b=fxRr5j7rCZsvknWkYoXeiNVo+5exJcXfLsaO3/mmzyGyQFtIqlI5V3rxAZ+a3ACxSNAyny xUOeCR/zhVqZQES56Jty+Ms8ifTM3q9+QSxwaQTNP6mpekHeJHX0+f5cTaU0r3zaN4TF7I +DoAXc9/+UGYFIptu5zNZkANy6v2S0t7+JaZLAS4r/1CTyyvNKrLI9xE3w7xX4J5PdOs1n rzjwAQ4VuUY79ZcfMej8rZpqovpzRp2CvqgNv46DOXdSJgE7y6WTHHR0njFvT59AqIx2+A gzR9LHvy42537DFIiKD6IwyuUpw5iByr33U6hqRZsUc67QBUboAFcsg9/Q8hlw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D265382 Bug ID: 265382 Summary: VLAN hash-list table thrashing when adding and removing entries Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: dsips@netapp.com CC: dsips@netapp.com vlan_remhash() uses incorrect value for b. When using the default value for VLAN_DEF_HWIDTH (4), the VLAN hash-list ta= ble expands from 16 chains to 32 chains as the 129th entry is added. trunk->hwi= dth=20 becomes 5. Say a few more entries are added and there are now 135 entries.= =20 trunk-hwidth will still be 5. If an entry is removed, vlan_remhash() will=20 calculate a value of 32 for b. refcnt will be decremented to 134. The if=20 comparison at line 473 will return true and vlan_growhash() will be called.= The=20 VLAN hash-list table will be compressed from 32 chains wide to 16 chains wi= de. hwidth will become 4. This is an error, and it can be seen when a new VLAN = is=20 added. The table will again be expanded. If an entry is then removed, again= =20 the table is contracted.=20 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=20 value of hwidth. line 467 should be: b =3D 1 << (trunk->hwidth - 1); For reference: 458 static int 459 vlan_remhash(struct ifvlantrunk *trunk, struct ifvlan *ifv) 460 { 461 int i, b; 462 struct ifvlan *ifv2; 463=20=20 464 VLAN_XLOCK_ASSERT(); 465 KASSERT(trunk->hwidth > 0, ("%s: hwidth not positive", __func__)); 466=20=20 467 b =3D 1 << trunk->hwidth; 468 i =3D HASH(ifv->ifv_vid, trunk->hmask); 469 CK_SLIST_FOREACH(ifv2, &trunk->hash[i], ifv_list) 470 if (ifv2 =3D=3D ifv) { 471 trunk->refcnt--; 472 CK_SLIST_REMOVE(&trunk->hash[i], ifv2, ifvlan, ifv_list); 473 if (trunk->refcnt < (b * b) / 2) 474 vlan_growhash(trunk, -1); 475 return (0); 476 } 477=20=20 478 panic("%s: vlan not found\n", __func__); 479 return (ENOENT); /*NOTREACHED*/ 480 } --=20 You are receiving this mail because: You are the assignee for the bug.=