When multiple interfaces exist in the system, with each interface having
an IPv6 address assigned to it, and if an incoming packet received on one interface has a packet destination address that belongs to another interface, the routing table is consulted to determine how to reach this packet destination. Since the packet destination is an interface address, the route table will return a host route with the loopback interface as rt_ifp. The input code must recognize this fact, instead of using the loopback interface, the input code performs a search to find the right interface that owns the given IPv6 address. Reviewed by: bz, gnn, kmacy MFC after: immediately
This commit is contained in:
parent
a3275cab81
commit
487e2c0d00
@ -628,8 +628,27 @@ ip6_input(struct mbuf *m)
|
||||
&rt6_key(rin6.ro_rt)->sin6_addr)
|
||||
#endif
|
||||
rin6.ro_rt->rt_ifp->if_type == IFT_LOOP) {
|
||||
struct in6_ifaddr *ia6 =
|
||||
(struct in6_ifaddr *)rin6.ro_rt->rt_ifa;
|
||||
int free_ia6 = 0;
|
||||
struct in6_ifaddr *ia6;
|
||||
|
||||
/*
|
||||
* found the loopback route to the interface address
|
||||
*/
|
||||
if (rin6.ro_rt->rt_gateway->sa_family == AF_LINK) {
|
||||
struct sockaddr_in6 dest6;
|
||||
|
||||
bzero(&dest6, sizeof(dest6));
|
||||
dest6.sin6_family = AF_INET6;
|
||||
dest6.sin6_len = sizeof(dest6);
|
||||
dest6.sin6_addr = ip6->ip6_dst;
|
||||
ia6 = (struct in6_ifaddr *)
|
||||
ifa_ifwithaddr((struct sockaddr *)&dest6);
|
||||
if (ia6 == NULL)
|
||||
goto bad;
|
||||
free_ia6 = 1;
|
||||
}
|
||||
else
|
||||
ia6 = (struct in6_ifaddr *)rin6.ro_rt->rt_ifa;
|
||||
|
||||
/*
|
||||
* record address information into m_tag.
|
||||
@ -647,6 +666,8 @@ ip6_input(struct mbuf *m)
|
||||
/* Count the packet in the ip address stats */
|
||||
ia6->ia_ifa.if_ipackets++;
|
||||
ia6->ia_ifa.if_ibytes += m->m_pkthdr.len;
|
||||
if (ia6 != NULL && free_ia6 != 0)
|
||||
ifa_free(&ia6->ia_ifa);
|
||||
goto hbhcheck;
|
||||
} else {
|
||||
char ip6bufs[INET6_ADDRSTRLEN];
|
||||
@ -657,6 +678,8 @@ ip6_input(struct mbuf *m)
|
||||
ip6_sprintf(ip6bufs, &ip6->ip6_src),
|
||||
ip6_sprintf(ip6bufd, &ip6->ip6_dst)));
|
||||
|
||||
if (ia6 != NULL && free_ia6 != 0)
|
||||
ifa_free(&ia6->ia_ifa);
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user