mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
pf: ensure we populate dyncnt/tblcnt in struct pf_addr_wrap
PR: 259689
MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D32892
This commit is contained in:
parent
3987e50611
commit
218a8a491c
2 changed files with 27 additions and 4 deletions
|
|
@ -287,14 +287,20 @@ pfctl_nv_add_addr_wrap(nvlist_t *nvparent, const char *name,
|
|||
static void
|
||||
pf_nvaddr_wrap_to_addr_wrap(const nvlist_t *nvl, struct pf_addr_wrap *addr)
|
||||
{
|
||||
bzero(addr, sizeof(*addr));
|
||||
|
||||
addr->type = nvlist_get_number(nvl, "type");
|
||||
addr->iflags = nvlist_get_number(nvl, "iflags");
|
||||
if (addr->type == PF_ADDR_DYNIFTL)
|
||||
if (addr->type == PF_ADDR_DYNIFTL) {
|
||||
strlcpy(addr->v.ifname, nvlist_get_string(nvl, "ifname"),
|
||||
IFNAMSIZ);
|
||||
if (addr->type == PF_ADDR_TABLE)
|
||||
addr->p.dyncnt = nvlist_get_number(nvl, "dynctl");
|
||||
}
|
||||
if (addr->type == PF_ADDR_TABLE) {
|
||||
strlcpy(addr->v.tblname, nvlist_get_string(nvl, "tblname"),
|
||||
PF_TABLE_NAME_SIZE);
|
||||
addr->p.tblcnt = nvlist_get_number(nvl, "tblcnt");
|
||||
}
|
||||
|
||||
pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "addr"), &addr->v.a.addr);
|
||||
pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "mask"), &addr->v.a.mask);
|
||||
|
|
|
|||
|
|
@ -327,6 +327,8 @@ pf_addr_wrap_to_nvaddr_wrap(const struct pf_addr_wrap *addr)
|
|||
{
|
||||
nvlist_t *nvl;
|
||||
nvlist_t *tmp;
|
||||
uint64_t num;
|
||||
struct pfr_ktable *kt;
|
||||
|
||||
nvl = nvlist_create(0);
|
||||
if (nvl == NULL)
|
||||
|
|
@ -334,10 +336,25 @@ pf_addr_wrap_to_nvaddr_wrap(const struct pf_addr_wrap *addr)
|
|||
|
||||
nvlist_add_number(nvl, "type", addr->type);
|
||||
nvlist_add_number(nvl, "iflags", addr->iflags);
|
||||
if (addr->type == PF_ADDR_DYNIFTL)
|
||||
if (addr->type == PF_ADDR_DYNIFTL) {
|
||||
nvlist_add_string(nvl, "ifname", addr->v.ifname);
|
||||
if (addr->type == PF_ADDR_TABLE)
|
||||
num = 0;
|
||||
if (addr->p.dyn != NULL)
|
||||
num = addr->p.dyn->pfid_acnt4 +
|
||||
addr->p.dyn->pfid_acnt6;
|
||||
nvlist_add_number(nvl, "dyncnt", num);
|
||||
}
|
||||
if (addr->type == PF_ADDR_TABLE) {
|
||||
nvlist_add_string(nvl, "tblname", addr->v.tblname);
|
||||
num = -1;
|
||||
kt = addr->p.tbl;
|
||||
if ((kt->pfrkt_flags & PFR_TFLAG_ACTIVE) &&
|
||||
kt->pfrkt_root != NULL)
|
||||
kt = kt->pfrkt_root;
|
||||
if (kt->pfrkt_flags & PFR_TFLAG_ACTIVE)
|
||||
num = kt->pfrkt_cnt;
|
||||
nvlist_add_number(nvl, "tblcnt", num);
|
||||
}
|
||||
|
||||
tmp = pf_addr_to_nvaddr(&addr->v.a.addr);
|
||||
if (tmp == NULL)
|
||||
|
|
|
|||
Loading…
Reference in a new issue