mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-19 02:29:40 +00:00
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 13ad237a19
)
This commit is contained in:
parent
05e742af6f
commit
8d0f1438b0
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user