| 5895 | |
| 5896 | #ifdef INET |
| 5897 | int |
| 5898 | pf_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 */ |
no test coverage detected