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

Function pf_test6

freebsd/netpfil/pf/pf.c:6291–6695  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6289
6290#ifdef INET6
6291int
6292pf_test6(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb *inp)
6293{
6294 struct pfi_kkif *kif;
6295 u_short action, reason = 0, log = 0;
6296 struct mbuf *m = *m0, *n = NULL;
6297 struct m_tag *mtag;
6298 struct ip6_hdr *h = NULL;
6299 struct pf_krule *a = NULL, *r = &V_pf_default_rule, *tr, *nr;
6300 struct pf_state *s = NULL;
6301 struct pf_kruleset *ruleset = NULL;
6302 struct pf_pdesc pd;
6303 int off, terminal = 0, dirndx, rh_cnt = 0, pqid = 0;
6304
6305 PF_RULES_RLOCK_TRACKER;
6306 M_ASSERTPKTHDR(m);
6307
6308 if (!V_pf_status.running)
6309 return (PF_PASS);
6310
6311 memset(&pd, 0, sizeof(pd));
6312 pd.pf_mtag = pf_find_mtag(m);
6313
6314 if (pd.pf_mtag && pd.pf_mtag->flags & PF_TAG_GENERATED)
6315 return (PF_PASS);
6316
6317 kif = (struct pfi_kkif *)ifp->if_pf_kif;
6318 if (kif == NULL) {
6319 DPFPRINTF(PF_DEBUG_URGENT,
6320 ("pf_test6: kif == NULL, if_xname %s\n", ifp->if_xname));
6321 return (PF_DROP);
6322 }
6323 if (kif->pfik_flags & PFI_IFLAG_SKIP)
6324 return (PF_PASS);
6325
6326 if (m->m_flags & M_SKIP_FIREWALL)
6327 return (PF_PASS);
6328
6329 PF_RULES_RLOCK();
6330
6331 /* We do IP header normalization and packet reassembly here */
6332 if (pf_normalize_ip6(m0, dir, kif, &reason, &pd) != PF_PASS) {
6333 action = PF_DROP;
6334 goto done;
6335 }
6336 m = *m0; /* pf_normalize messes with m0 */
6337 h = mtod(m, struct ip6_hdr *);
6338
6339 /*
6340 * we do not support jumbogram. if we keep going, zero ip6_plen
6341 * will do something bad, so drop the packet for now.
6342 */
6343 if (htons(h->ip6_plen) == 0) {
6344 action = PF_DROP;
6345 REASON_SET(&reason, PFRES_NORM); /*XXX*/
6346 goto done;
6347 }
6348

Callers 3

pf_check6_inFunction · 0.85
pf_check6_outFunction · 0.85
pf_route6Function · 0.85

Calls 15

memsetFunction · 0.85
pf_find_mtagFunction · 0.85
pf_normalize_ip6Function · 0.85
pf_test_fragmentFunction · 0.85
pf_pull_hdrFunction · 0.85
pf_normalize_tcpFunction · 0.85
pf_test_state_tcpFunction · 0.85
pf_test_ruleFunction · 0.85
pf_test_state_udpFunction · 0.85
pf_test_state_icmpFunction · 0.85
pf_test_state_otherFunction · 0.85
pf_tag_packetFunction · 0.85

Tested by

no test coverage detected