diff options
author | ume <ume@FreeBSD.org> | 2002-01-21 20:04:22 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2002-01-21 20:04:22 +0000 |
commit | 590d306747e211057f089ee9f21cda8d6f9b9b08 (patch) | |
tree | f1d0e2bb684624d1cce9cf1ed2331e9cfff12de8 /sys/netinet/in_pcb.c | |
parent | ab65ed6b0b6ebf920fb25663dff5b1b6ea50c023 (diff) | |
download | FreeBSD-src-590d306747e211057f089ee9f21cda8d6f9b9b08.zip FreeBSD-src-590d306747e211057f089ee9f21cda8d6f9b9b08.tar.gz |
- Check the address family of the destination cached in a PCB.
- Clear the cached destination before getting another cached route.
Otherwise, garbage in the padding space (which might be filled in if it was
used for IPv4) could annoy rtalloc.
Obtained from: KAME
Diffstat (limited to 'sys/netinet/in_pcb.c')
-rw-r--r-- | sys/netinet/in_pcb.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index e8506c3..59aec2e 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -413,12 +413,15 @@ in_pcbladdr(inp, nam, plocal_sin) /* * If route is known or can be allocated now, * our src addr is taken from the i/f, else punt. + * Note that we should check the address family of the cached + * destination, in case of sharing the cache with IPv6. */ ro = &inp->inp_route; if (ro->ro_rt && - (satosin(&ro->ro_dst)->sin_addr.s_addr != - sin->sin_addr.s_addr || - inp->inp_socket->so_options & SO_DONTROUTE)) { + (ro->ro_dst.sa_family != AF_INET || + satosin(&ro->ro_dst)->sin_addr.s_addr != + sin->sin_addr.s_addr || + inp->inp_socket->so_options & SO_DONTROUTE)) { RTFREE(ro->ro_rt); ro->ro_rt = (struct rtentry *)0; } @@ -426,6 +429,7 @@ in_pcbladdr(inp, nam, plocal_sin) (ro->ro_rt == (struct rtentry *)0 || ro->ro_rt->rt_ifp == (struct ifnet *)0)) { /* No route yet, so try to acquire one */ + bzero(&ro->ro_dst, sizeof(struct sockaddr_in)); ro->ro_dst.sa_family = AF_INET; ro->ro_dst.sa_len = sizeof(struct sockaddr_in); ((struct sockaddr_in *) &ro->ro_dst)->sin_addr = |