]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netinet6/nd6.c
xnu-517.7.21.tar.gz
[apple/xnu.git] / bsd / netinet6 / nd6.c
index ffa6af8ec128b174a428ba45005ee30d04224cfd..baff898b4eef957a1441d070552af20330d22084 100644 (file)
@@ -102,7 +102,7 @@ int nd6_debug = 0;
 static int nd6_inuse, nd6_allocated;
 
 struct llinfo_nd6 llinfo_nd6 = {&llinfo_nd6, &llinfo_nd6};
-static size_t nd_ifinfo_indexlim = 8;
+size_t nd_ifinfo_indexlim = 8;
 struct nd_ifinfo *nd_ifinfo = NULL;
 struct nd_drhead nd_defrouter;
 struct nd_prhead nd_prefix = { 0 };
@@ -2076,6 +2076,22 @@ nd6_output(ifp, origifp, m0, dst, rt0)
        if ((ifp->if_flags & IFF_LOOPBACK) != 0) {
                m->m_pkthdr.rcvif = origifp; /* forwarding rules require the original scope_id */
                return (dlil_output(ifptodlt(origifp, PF_INET6), m, (caddr_t)rt, (struct sockaddr *)dst,0));    
+       } else {
+               /* Do not allow loopback address to wind up on a wire */
+               struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
+               
+               if ((IN6_IS_ADDR_LOOPBACK(&ip6->ip6_src) ||
+                       IN6_IS_ADDR_LOOPBACK(&ip6->ip6_dst))) {
+                       ip6stat.ip6s_badscope++;
+                       /* 
+                        * Simply drop the packet just like a firewall -- we do not want the 
+                        * the application to feel the pain, not yet...
+                        * Returning ENETUNREACH like ip6_output does in some similar cases  
+                        * could startle the otherwise clueless process that specifies
+                        * loopback as the source address.
+                        */
+                       goto bad;
+               }
        }
 
        m->m_pkthdr.rcvif = (struct ifnet *)0;