MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pf_src_tree_remove_state

Function pf_src_tree_remove_state

freebsd/netpfil/pf/pf.c:1645–1675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1643}
1644
1645static void
1646pf_src_tree_remove_state(struct pf_state *s)
1647{
1648 struct pf_ksrc_node *sn;
1649 struct pf_srchash *sh;
1650 uint32_t timeout;
1651
1652 timeout = s->rule.ptr->timeout[PFTM_SRC_NODE] ?
1653 s->rule.ptr->timeout[PFTM_SRC_NODE] :
1654 V_pf_default_rule.timeout[PFTM_SRC_NODE];
1655
1656 if (s->src_node != NULL) {
1657 sn = s->src_node;
1658 sh = &V_pf_srchash[pf_hashsrc(&sn->addr, sn->af)];
1659 PF_HASHROW_LOCK(sh);
1660 if (s->src.tcp_est)
1661 --sn->conn;
1662 if (--sn->states == 0)
1663 sn->expire = time_uptime + timeout;
1664 PF_HASHROW_UNLOCK(sh);
1665 }
1666 if (s->nat_src_node != s->src_node && s->nat_src_node != NULL) {
1667 sn = s->nat_src_node;
1668 sh = &V_pf_srchash[pf_hashsrc(&sn->addr, sn->af)];
1669 PF_HASHROW_LOCK(sh);
1670 if (--sn->states == 0)
1671 sn->expire = time_uptime + timeout;
1672 PF_HASHROW_UNLOCK(sh);
1673 }
1674 s->src_node = s->nat_src_node = NULL;
1675}
1676
1677/*
1678 * Unlink and potentilly free a state. Function may be

Callers 2

pf_unlink_stateFunction · 0.85
pf_create_stateFunction · 0.85

Calls 1

pf_hashsrcFunction · 0.85

Tested by

no test coverage detected