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

Function pf_test

freebsd/netpfil/pf/pf.c:5897–6287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5895
5896#ifdef INET
5897int
5898pf_test(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb *inp)
5899{
5900 struct pfi_kkif *kif;
5901 u_short action, reason = 0, log = 0;
5902 struct mbuf *m = *m0;
5903 struct ip *h = NULL;
5904 struct m_tag *ipfwtag;
5905 struct pf_krule *a = NULL, *r = &V_pf_default_rule, *tr, *nr;
5906 struct pf_state *s = NULL;
5907 struct pf_kruleset *ruleset = NULL;
5908 struct pf_pdesc pd;
5909 int off, dirndx, pqid = 0;
5910
5911 PF_RULES_RLOCK_TRACKER;
5912
5913 M_ASSERTPKTHDR(m);
5914
5915 if (!V_pf_status.running)
5916 return (PF_PASS);
5917
5918 memset(&pd, 0, sizeof(pd));
5919
5920 kif = (struct pfi_kkif *)ifp->if_pf_kif;
5921
5922 if (kif == NULL) {
5923 DPFPRINTF(PF_DEBUG_URGENT,
5924 ("pf_test: kif == NULL, if_xname %s\n", ifp->if_xname));
5925 return (PF_DROP);
5926 }
5927 if (kif->pfik_flags & PFI_IFLAG_SKIP)
5928 return (PF_PASS);
5929
5930 if (m->m_flags & M_SKIP_FIREWALL)
5931 return (PF_PASS);
5932
5933 pd.pf_mtag = pf_find_mtag(m);
5934
5935 PF_RULES_RLOCK();
5936
5937 if (ip_divert_ptr != NULL &&
5938 ((ipfwtag = m_tag_locate(m, MTAG_IPFW_RULE, 0, NULL)) != NULL)) {
5939 struct ipfw_rule_ref *rr = (struct ipfw_rule_ref *)(ipfwtag+1);
5940 if (rr->info & IPFW_IS_DIVERT && rr->rulenum == 0) {
5941 if (pd.pf_mtag == NULL &&
5942 ((pd.pf_mtag = pf_get_mtag(m)) == NULL)) {
5943 action = PF_DROP;
5944 goto done;
5945 }
5946 pd.pf_mtag->flags |= PF_PACKET_LOOPED;
5947 m_tag_delete(m, ipfwtag);
5948 }
5949 if (pd.pf_mtag && pd.pf_mtag->flags & PF_FASTFWD_OURS_PRESENT) {
5950 m->m_flags |= M_FASTFWD_OURS;
5951 pd.pf_mtag->flags &= ~PF_FASTFWD_OURS_PRESENT;
5952 }
5953 } else if (pf_normalize_ip(m0, dir, kif, &reason, &pd) != PF_PASS) {
5954 /* We do IP header normalization and packet reassembly here */

Callers 3

pf_check_inFunction · 0.85
pf_check_outFunction · 0.85
pf_routeFunction · 0.85

Calls 15

memsetFunction · 0.85
pf_find_mtagFunction · 0.85
m_tag_locateFunction · 0.85
pf_get_mtagFunction · 0.85
m_tag_deleteFunction · 0.85
pf_normalize_ipFunction · 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

Tested by

no test coverage detected