| 2120 | } |
| 2121 | |
| 2122 | struct pfr_ktable * |
| 2123 | pfr_attach_table(struct pf_kruleset *rs, char *name) |
| 2124 | { |
| 2125 | struct pfr_ktable *kt, *rt; |
| 2126 | struct pfr_table tbl; |
| 2127 | struct pf_kanchor *ac = rs->anchor; |
| 2128 | |
| 2129 | PF_RULES_WASSERT(); |
| 2130 | |
| 2131 | bzero(&tbl, sizeof(tbl)); |
| 2132 | strlcpy(tbl.pfrt_name, name, sizeof(tbl.pfrt_name)); |
| 2133 | if (ac != NULL) |
| 2134 | strlcpy(tbl.pfrt_anchor, ac->path, sizeof(tbl.pfrt_anchor)); |
| 2135 | kt = pfr_lookup_table(&tbl); |
| 2136 | if (kt == NULL) { |
| 2137 | kt = pfr_create_ktable(&tbl, time_second, 1); |
| 2138 | if (kt == NULL) |
| 2139 | return (NULL); |
| 2140 | if (ac != NULL) { |
| 2141 | bzero(tbl.pfrt_anchor, sizeof(tbl.pfrt_anchor)); |
| 2142 | rt = pfr_lookup_table(&tbl); |
| 2143 | if (rt == NULL) { |
| 2144 | rt = pfr_create_ktable(&tbl, 0, 1); |
| 2145 | if (rt == NULL) { |
| 2146 | pfr_destroy_ktable(kt, 0); |
| 2147 | return (NULL); |
| 2148 | } |
| 2149 | pfr_insert_ktable(rt); |
| 2150 | } |
| 2151 | kt->pfrkt_root = rt; |
| 2152 | } |
| 2153 | pfr_insert_ktable(kt); |
| 2154 | } |
| 2155 | if (!kt->pfrkt_refcnt[PFR_REFCNT_RULE]++) |
| 2156 | pfr_setflags_ktable(kt, kt->pfrkt_flags|PFR_TFLAG_REFERENCED); |
| 2157 | return (kt); |
| 2158 | } |
| 2159 | |
| 2160 | void |
| 2161 | pfr_detach_table(struct pfr_ktable *kt) |
no test coverage detected