]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netinet/ip_input.c
xnu-517.tar.gz
[apple/xnu.git] / bsd / netinet / ip_input.c
index bd5edb4fba6f4482e1b9e76a2fc008426f4c52ec..424c4445d2d1ad89aba79a0f3cd3ad19911fab6f 100644 (file)
@@ -286,6 +286,9 @@ void        ipintr __P((void));
 extern u_short ip_id;
 #endif
 
 extern u_short ip_id;
 #endif
 
+extern u_long  route_generation;
+extern int apple_hwcksum_rx;
+
 /*
  * IP initialization: fill in IP protocol switch table.
  * All protocols not implemented in kernel go to raw IP protocol handler.
 /*
  * IP initialization: fill in IP protocol switch table.
  * All protocols not implemented in kernel go to raw IP protocol handler.
@@ -363,7 +366,7 @@ ip_input(struct mbuf *m)
        u_int16_t divert_cookie;                /* firewall cookie */
        struct in_addr pkt_dst;
 #if IPDIVERT
        u_int16_t divert_cookie;                /* firewall cookie */
        struct in_addr pkt_dst;
 #if IPDIVERT
-       u_int32_t divert_info = 0;              /* packet divert/tee info */
+       u_int16_t divert_info = 0;              /* packet divert/tee info */
 #endif
        struct ip_fw_chain *rule = NULL;
 
 #endif
        struct ip_fw_chain *rule = NULL;
 
@@ -450,11 +453,9 @@ ip_input(struct mbuf *m)
                                goto bad;
                }
        }
                                goto bad;
                }
        }
-       if (m->m_pkthdr.rcvif->if_hwassist == 0)
-               m->m_pkthdr.csum_flags = 0;
-
-       if ((m->m_pkthdr.csum_flags & CSUM_TCP_SUM16) && ip->ip_p != IPPROTO_TCP)
-               m->m_pkthdr.csum_flags = 0;
+       if ((m->m_pkthdr.rcvif->if_hwassist == 0) || (apple_hwcksum_rx == 0) ||
+          ((m->m_pkthdr.csum_flags & CSUM_TCP_SUM16) && ip->ip_p != IPPROTO_TCP))
+               m->m_pkthdr.csum_flags = 0; /* invalidate HW generated checksum flags */
 
        if (m->m_pkthdr.csum_flags & CSUM_IP_CHECKED) {
                sum = !(m->m_pkthdr.csum_flags & CSUM_IP_VALID);
 
        if (m->m_pkthdr.csum_flags & CSUM_IP_CHECKED) {
                sum = !(m->m_pkthdr.csum_flags & CSUM_IP_VALID);
@@ -658,7 +659,7 @@ pass:
                 * ether_output() with the loopback into the stack for
                 * SIMPLEX interfaces handled by ether_output().
                 */
                 * ether_output() with the loopback into the stack for
                 * SIMPLEX interfaces handled by ether_output().
                 */
-               if (ia->ia_ifp == m->m_pkthdr.rcvif &&
+               if ((!checkif || ia->ia_ifp == m->m_pkthdr.rcvif) &&
                    ia->ia_ifp && ia->ia_ifp->if_flags & IFF_BROADCAST) {
                        if (satosin(&ia->ia_broadaddr)->sin_addr.s_addr ==
                            pkt_dst.s_addr)
                    ia->ia_ifp && ia->ia_ifp->if_flags & IFF_BROADCAST) {
                        if (satosin(&ia->ia_broadaddr)->sin_addr.s_addr ==
                            pkt_dst.s_addr)
@@ -685,7 +686,7 @@ pass:
                        }
 
                        /*
                        }
 
                        /*
-                        * The process-level routing demon needs to receive
+                        * The process-level routing daemon needs to receive
                         * all multicast IGMP packets, whether or not this
                         * host belongs to their destination groups.
                         */
                         * all multicast IGMP packets, whether or not this
                         * host belongs to their destination groups.
                         */
@@ -836,6 +837,9 @@ found:
                                goto bad;
                        }
                        m->m_flags |= M_FRAG;
                                goto bad;
                        }
                        m->m_flags |= M_FRAG;
+               } else {
+                       /* Clear the flag in case packet comes from loopback */
+                       m->m_flags &= ~M_FRAG;
                }
                ip->ip_off <<= 3;
 
                }
                ip->ip_off <<= 3;
 
@@ -1567,7 +1571,8 @@ ip_rtaddr(dst)
 
        sin = (struct sockaddr_in *) &ipforward_rt.ro_dst;
 
 
        sin = (struct sockaddr_in *) &ipforward_rt.ro_dst;
 
-       if (ipforward_rt.ro_rt == 0 || dst.s_addr != sin->sin_addr.s_addr) {
+       if (ipforward_rt.ro_rt == 0 || dst.s_addr != sin->sin_addr.s_addr ||
+               ipforward_rt.ro_rt->generation_id != route_generation) {
                if (ipforward_rt.ro_rt) {
                        rtfree(ipforward_rt.ro_rt);
                        ipforward_rt.ro_rt = 0;
                if (ipforward_rt.ro_rt) {
                        rtfree(ipforward_rt.ro_rt);
                        ipforward_rt.ro_rt = 0;
@@ -1769,7 +1774,8 @@ ip_forward(m, srcrt)
 
        sin = (struct sockaddr_in *)&ipforward_rt.ro_dst;
        if ((rt = ipforward_rt.ro_rt) == 0 ||
 
        sin = (struct sockaddr_in *)&ipforward_rt.ro_dst;
        if ((rt = ipforward_rt.ro_rt) == 0 ||
-           ip->ip_dst.s_addr != sin->sin_addr.s_addr) {
+           ip->ip_dst.s_addr != sin->sin_addr.s_addr ||
+           ipforward_rt.ro_rt->generation_id != route_generation) {
                if (ipforward_rt.ro_rt) {
                        rtfree(ipforward_rt.ro_rt);
                        ipforward_rt.ro_rt = 0;
                if (ipforward_rt.ro_rt) {
                        rtfree(ipforward_rt.ro_rt);
                        ipforward_rt.ro_rt = 0;
@@ -2033,6 +2039,10 @@ makedummy:
                if (*mp)
                        mp = &(*mp)->m_next;
        }
                if (*mp)
                        mp = &(*mp)->m_next;
        }
+       if (inp->inp_flags & INP_RECVTTL) {
+               *mp = sbcreatecontrol((caddr_t)&ip->ip_ttl, sizeof(ip->ip_ttl), IP_RECVTTL, IPPROTO_IP);
+               if (*mp) mp = &(*mp)->m_next;
+       }
 }
 
 int
 }
 
 int