diff options
| author | Andre Oppermann <andre@FreeBSD.org> | 2006-02-16 15:45:28 +0000 |
|---|---|---|
| committer | Andre Oppermann <andre@FreeBSD.org> | 2006-02-16 15:45:28 +0000 |
| commit | cf744713e87e77504a25a4ece5ad95b87f6b5753 (patch) | |
| tree | 75c751a1f90066f1acc30d1785ac16a9c1e52bb4 /sys | |
| parent | a4684d742dbebeb758bf8f2bdada11e417153cd8 (diff) | |
Notes
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/netinet/in_pcb.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index f96c660916b3..d96a838a65ac 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -591,29 +591,23 @@ in_pcbconnect_setup(struct inpcb *inp, struct sockaddr *nam, &in_ifaddrhead)->ia_broadaddr)->sin_addr; } if (laddr.s_addr == INADDR_ANY) { - struct route sro; - - bzero(&sro, sizeof(sro)); ia = (struct in_ifaddr *)0; /* * If route is known our src addr is taken from the i/f, * else punt. + * + * Find out route to destination */ - if ((inp->inp_socket->so_options & SO_DONTROUTE) == 0) { - /* Find out route to destination */ - sro.ro_dst.sa_family = AF_INET; - sro.ro_dst.sa_len = sizeof(struct sockaddr_in); - ((struct sockaddr_in *)&sro.ro_dst)->sin_addr = faddr; - rtalloc_ign(&sro, RTF_CLONING); - } + if ((inp->inp_socket->so_options & SO_DONTROUTE) == 0) + ia = ip_rtaddr(faddr); /* - * If we found a route, use the address - * corresponding to the outgoing interface. + * If we found a route, use the address corresponding to + * the outgoing interface. + * + * Otherwise assume faddr is reachable on a directly connected + * network and try to find a corresponding interface to take + * the source address from. */ - if (sro.ro_rt) { - ia = ifatoia(sro.ro_rt->rt_ifa); - RTFREE(sro.ro_rt); - } if (ia == 0) { bzero(&sa, sizeof(sa)); sa.sin_addr = faddr; |
