X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/d1ecb069dfe24481e4a83f44cb5217a2b06746d7..0b4c1975fb5e4eccf1012a35081f7e7799b81046:/bsd/netinet/ip_input.c diff --git a/bsd/netinet/ip_input.c b/bsd/netinet/ip_input.c index a6c47e084..10156a869 100644 --- a/bsd/netinet/ip_input.c +++ b/bsd/netinet/ip_input.c @@ -559,6 +559,7 @@ ip_proto_dispatch_in( int seen = (inject_ipfref == 0); int changed_header = 0; struct ip *ip; + void (*pr_input)(struct mbuf *, int len); if (!TAILQ_EMPTY(&ipv4_filters)) { ipf_ref(); @@ -598,20 +599,21 @@ ip_proto_dispatch_in( * otherwise let the protocol deal with its own locking */ ip = mtod(m, struct ip *); - + if (changed_header) { ip->ip_len = ntohs(ip->ip_len) - hlen; ip->ip_off = ntohs(ip->ip_off); } - - if (!(ip_protox[ip->ip_p]->pr_flags & PR_PROTOLOCK)) { + + if ((pr_input = ip_protox[ip->ip_p]->pr_input) == NULL) { + m_freem(m); + } else if (!(ip_protox[ip->ip_p]->pr_flags & PR_PROTOLOCK)) { lck_mtx_lock(inet_domain_mutex); - (*ip_protox[ip->ip_p]->pr_input)(m, hlen); + pr_input(m, hlen); lck_mtx_unlock(inet_domain_mutex); - } - else - (*ip_protox[ip->ip_p]->pr_input)(m, hlen); - + } else { + pr_input(m, hlen); + } } /* @@ -624,15 +626,16 @@ ip_input(struct mbuf *m) struct ip *ip; struct ipq *fp; struct in_ifaddr *ia = NULL; - int i, hlen, checkif; + int hlen, checkif; u_short sum; struct in_addr pkt_dst; - u_int32_t div_info = 0; /* packet divert/tee info */ #if IPFIREWALL + int i; + u_int32_t div_info = 0; /* packet divert/tee info */ struct ip_fw_args args; + struct m_tag *tag; #endif ipfilter_t inject_filter_ref = 0; - struct m_tag *tag; #if IPFIREWALL args.eh = NULL;