Date: Thu, 4 Mar 2021 09:24:19 GMT From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 952ad2822359 - stable/11 - ipfw: make algo name argument optional for some table types Message-ID: <202103040924.1249OJrE092797@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/11 has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=952ad28223596ef4e323a9a7da81ef3faf1c919a commit 952ad28223596ef4e323a9a7da81ef3faf1c919a Author: Andrey V. Elsukov <ae@FreeBSD.org> AuthorDate: 2021-02-25 13:57:47 +0000 Commit: Andrey V. Elsukov <ae@FreeBSD.org> CommitDate: 2021-03-04 09:23:01 +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 e914ad63343c..12e5a4cc435f 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 }, @@ -469,8 +478,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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103040924.1249OJrE092797>