From owner-dev-commits-src-main@freebsd.org Sat Jul 3 21:12:04 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8B984658DDD; Sat, 3 Jul 2021 21:12:04 +0000 (UTC) (envelope-from git@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 4GHPlm2yy5z4lpH; Sat, 3 Jul 2021 21:12:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 4CA622E330; Sat, 3 Jul 2021 21:12:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 163LC4jD056427; Sat, 3 Jul 2021 21:12:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 163LC4n4056426; Sat, 3 Jul 2021 21:12:04 GMT (envelope-from git) Date: Sat, 3 Jul 2021 21:12:04 GMT Message-Id: <202107032112.163LC4n4056426@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: f28455344483 - main - libalias: Fix API bug on initialization MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f28455344483310cfd1aa5c0bdd4d014810c0e32 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Jul 2021 21:12:04 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=f28455344483310cfd1aa5c0bdd4d014810c0e32 commit f28455344483310cfd1aa5c0bdd4d014810c0e32 Author: Lutz Donnerhacke AuthorDate: 2021-07-03 21:03:07 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-07-03 21:03:07 +0000 libalias: Fix API bug on initialization The kernel part of ipfw(8) does initialize LibAlias uncondistionally with an zeroized port range (allowed ports from 0 to 0). During restucturing of libalias, port ranges are used everytime and are therefor initialized with different values than zero. The secondary initialization from ipfw (and probably others) overrides the new default values and leave the instance in an unfunctional state. The obvious solution is to detect such reinitializations and use the new default value instead. MFC after: 3 days --- sys/netinet/libalias/alias_db.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c index 9f8c6064d2a7..5b53067705bf 100644 --- a/sys/netinet/libalias/alias_db.c +++ b/sys/netinet/libalias/alias_db.c @@ -2048,9 +2048,15 @@ LibAliasSetAliasPortRange(struct libalias *la, u_short port_low, u_short port_high) { LIBALIAS_LOCK(la); - la->aliasPortLower = port_low; - /* Add 1 to the aliasPortLength as modulo has range of 1 to n-1 */ - la->aliasPortLength = port_high - port_low + 1; + if (port_low) { + la->aliasPortLower = port_low; + /* Add 1 to the aliasPortLength as modulo has range of 1 to n-1 */ + la->aliasPortLength = port_high - port_low + 1; + } else { + /* Set default values */ + la->aliasPortLower = 0x8000; + la->aliasPortLength = 0x8000; + } LIBALIAS_UNLOCK(la); }