version 1.2.8.2, 2020/04/13 08:05:15 |
version 1.3, 2020/05/30 14:16:56 |
|
|
/*- |
/*- |
* Copyright (c) 2019 The NetBSD Foundation, Inc. |
* Copyright (c) 2019-2020 The NetBSD Foundation, Inc. |
* All rights reserved. |
* All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
Line 49 struct npf_paraminfo { |
|
Line 49 struct npf_paraminfo { |
|
thmap_t * map; |
thmap_t * map; |
}; |
}; |
|
|
|
static inline void |
|
npf_param_general_register(npf_t *npf) |
|
{ |
|
npf_param_t param_map[] = { |
|
{ |
|
"ip4.reassembly", |
|
&npf->ip4_reassembly, |
|
.default_val = 0, // false |
|
.min = 0, .max = 1 |
|
}, |
|
{ |
|
"ip6.reassembly", |
|
&npf->ip6_reassembly, |
|
.default_val = 0, // false |
|
.min = 0, .max = 1 |
|
}, |
|
}; |
|
npf_param_register(npf, param_map, __arraycount(param_map)); |
|
} |
|
|
void |
void |
npf_param_init(npf_t *npf) |
npf_param_init(npf_t *npf) |
{ |
{ |
Line 57 npf_param_init(npf_t *npf) |
|
Line 77 npf_param_init(npf_t *npf) |
|
paraminfo = kmem_zalloc(sizeof(npf_paraminfo_t), KM_SLEEP); |
paraminfo = kmem_zalloc(sizeof(npf_paraminfo_t), KM_SLEEP); |
paraminfo->map = thmap_create(0, NULL, THMAP_NOCOPY); |
paraminfo->map = thmap_create(0, NULL, THMAP_NOCOPY); |
npf->paraminfo = paraminfo; |
npf->paraminfo = paraminfo; |
|
|
|
/* Register some general parameters. */ |
|
npf_param_general_register(npf); |
} |
} |
|
|
void |
void |
Line 91 npf_param_fini(npf_t *npf) |
|
Line 114 npf_param_fini(npf_t *npf) |
|
kmem_free(pinfo, sizeof(npf_paraminfo_t)); |
kmem_free(pinfo, sizeof(npf_paraminfo_t)); |
} |
} |
|
|
|
int |
|
npf_params_export(const npf_t *npf, nvlist_t *nv) |
|
{ |
|
nvlist_t *params, *dparams; |
|
|
|
/* |
|
* Export both the active and default values. The latter are to |
|
* accommodate npfctl so it could distinguish what has been set. |
|
*/ |
|
params = nvlist_create(0); |
|
dparams = nvlist_create(0); |
|
for (npf_paramreg_t *pr = npf->paraminfo->list; pr; pr = pr->next) { |
|
for (unsigned i = 0; i < pr->count; i++) { |
|
const npf_param_t *param = &pr->params[i]; |
|
const uint64_t val = *param->valp; |
|
const uint64_t defval = param->default_val; |
|
|
|
nvlist_add_number(params, param->name, val); |
|
nvlist_add_number(dparams, param->name, defval); |
|
} |
|
} |
|
nvlist_add_nvlist(nv, "params", params); |
|
nvlist_add_nvlist(nv, "params-defaults", dparams); |
|
return 0; |
|
} |
|
|
void * |
void * |
npf_param_allocgroup(npf_t *npf, npf_paramgroup_t group, size_t len) |
npf_param_allocgroup(npf_t *npf, npf_paramgroup_t group, size_t len) |
{ |
{ |