* pfil_run_hooks() runs the specified packet filter hook chain. */
| 161 | * pfil_run_hooks() runs the specified packet filter hook chain. |
| 162 | */ |
| 163 | int |
| 164 | pfil_run_hooks(struct pfil_head *head, pfil_packet_t p, struct ifnet *ifp, |
| 165 | int flags, struct inpcb *inp) |
| 166 | { |
| 167 | pfil_chain_t *pch; |
| 168 | struct pfil_link *link; |
| 169 | pfil_return_t rv; |
| 170 | bool realloc = false; |
| 171 | |
| 172 | NET_EPOCH_ASSERT(); |
| 173 | |
| 174 | if (PFIL_DIR(flags) == PFIL_IN) |
| 175 | pch = &head->head_in; |
| 176 | else if (__predict_true(PFIL_DIR(flags) == PFIL_OUT)) |
| 177 | pch = &head->head_out; |
| 178 | else |
| 179 | panic("%s: bogus flags %d", __func__, flags); |
| 180 | |
| 181 | rv = PFIL_PASS; |
| 182 | CK_STAILQ_FOREACH(link, pch, link_chain) { |
| 183 | if ((flags & PFIL_MEMPTR) && !(link->link_flags & PFIL_MEMPTR)) |
| 184 | rv = pfil_fake_mbuf(link->link_func, &p, ifp, flags, |
| 185 | link->link_ruleset, inp); |
| 186 | else |
| 187 | rv = (*link->link_func)(p, ifp, flags, |
| 188 | link->link_ruleset, inp); |
| 189 | if (rv == PFIL_DROPPED || rv == PFIL_CONSUMED) |
| 190 | break; |
| 191 | else if (rv == PFIL_REALLOCED) { |
| 192 | flags &= ~(PFIL_MEMPTR | PFIL_LENMASK); |
| 193 | realloc = true; |
| 194 | } |
| 195 | } |
| 196 | if (realloc && rv == PFIL_PASS) |
| 197 | rv = PFIL_REALLOCED; |
| 198 | return (rv); |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | * pfil_head_register() registers a pfil_head with the packet filter hook |
no test coverage detected