From owner-dev-commits-src-branches@freebsd.org Thu Mar 4 09:20:25 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 4DF0C569196; Thu, 4 Mar 2021 09:20:25 +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 4DrlhT1QRWz4tV1; Thu, 4 Mar 2021 09:20:25 +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 23D381A833; Thu, 4 Mar 2021 09:20:25 +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 1249KP1K087434; Thu, 4 Mar 2021 09:20:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1249KPho087433; Thu, 4 Mar 2021 09:20:25 GMT (envelope-from git) Date: Thu, 4 Mar 2021 09:20:25 GMT Message-Id: <202103040920.1249KPho087433@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Andrey V. Elsukov" Subject: git: 8d0f1438b0d7 - stable/13 - ipfw: make algo name argument optional for some table types MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ae X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8d0f1438b0d73dfa880cfafc5d09beb4e7100a3f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Mar 2021 09:20:25 -0000 The branch stable/13 has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=8d0f1438b0d73dfa880cfafc5d09beb4e7100a3f commit 8d0f1438b0d73dfa880cfafc5d09beb4e7100a3f Author: Andrey V. Elsukov AuthorDate: 2021-02-25 13:57:47 +0000 Commit: Andrey V. Elsukov CommitDate: 2021-03-04 09:19:31 +0000 ipfw: make algo name argument optional for some table types Most of table types currently supported by ipfw have only one algorithm implementation. When user creates such tables, allow to omit algo name in arguments. E.g. now it is possible: ipfw table T1 create type number ipfw table T2 create type iface ipfw table T3 create type flow PR: 233072 Sponsored by: Yandex LLC (cherry picked from commit 13ad237a19b7368124483d9d1dc3258c27880fef) --- sbin/ipfw/tables.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sbin/ipfw/tables.c b/sbin/ipfw/tables.c index 57b8cef00889..81cf7e392586 100644 --- a/sbin/ipfw/tables.c +++ b/sbin/ipfw/tables.c @@ -83,6 +83,15 @@ static struct _s_x tabletypes[] = { { NULL, 0 } }; +/* Default algorithms for various table types */ +static struct _s_x tablealgos[] = { + { "addr:radix", IPFW_TABLE_ADDR }, + { "flow:hash", IPFW_TABLE_FLOW }, + { "iface:array", IPFW_TABLE_INTERFACE }, + { "number:array", IPFW_TABLE_NUMBER }, + { NULL, 0 } +}; + static struct _s_x tablevaltypes[] = { { "skipto", IPFW_VTYPE_SKIPTO }, { "pipe", IPFW_VTYPE_PIPE }, @@ -468,8 +477,15 @@ table_create(ipfw_obj_header *oh, int ac, char *av[]) } /* Set some defaults to preserve compatibility. */ - if (xi.algoname[0] == '\0' && xi.type == 0) - xi.type = IPFW_TABLE_ADDR; + if (xi.algoname[0] == '\0') { + const char *algo; + + if (xi.type == 0) + xi.type = IPFW_TABLE_ADDR; + algo = match_value(tablealgos, xi.type); + if (algo != NULL) + strlcpy(xi.algoname, algo, sizeof(xi.algoname)); + } if (xi.vmask == 0) xi.vmask = IPFW_VTYPE_LEGACY;