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

Function pfil_run_hooks

freebsd/net/pfil.c:163–199  ·  view source on GitHub ↗

* pfil_run_hooks() runs the specified packet filter hook chain. */

Source from the content-addressed store, hash-verified

161 * pfil_run_hooks() runs the specified packet filter hook chain.
162 */
163int
164pfil_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

Callers 12

ip_inputFunction · 0.85
ip_output_pfilFunction · 0.85
ip_fastfwd.cFile · 0.85
ip6_forwardFunction · 0.85
ip6_inputFunction · 0.85
ip6_outputFunction · 0.85
ip6_tryforwardFunction · 0.85
rxd_frag_to_sdFunction · 0.85
ether_output_frameFunction · 0.85
ether_demuxFunction · 0.85
enc_hhookFunction · 0.85
bridge_pfilFunction · 0.85

Calls 2

pfil_fake_mbufFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected