summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in_pcb.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2006-02-16 15:45:28 +0000
committerandre <andre@FreeBSD.org>2006-02-16 15:45:28 +0000
commit5c75fa42eb9a29572dabddf9a767eefaaf664e1b (patch)
tree75c751a1f90066f1acc30d1785ac16a9c1e52bb4 /sys/netinet/in_pcb.c
parent201a4f94009c982484911945dd073976fcbc30b6 (diff)
downloadFreeBSD-src-5c75fa42eb9a29572dabddf9a767eefaaf664e1b.zip
FreeBSD-src-5c75fa42eb9a29572dabddf9a767eefaaf664e1b.tar.gz
In in_pcbconnect_setup() reduce code duplication and use ip_rtaddr()
to find the outgoing interface for this connection. Sponsored by: TCP/IP Optimization Fundraise 2005 MFC after: 2 weeks
Diffstat (limited to 'sys/netinet/in_pcb.c')
-rw-r--r--sys/netinet/in_pcb.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index f96c660..d96a838 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;
OpenPOWER on IntegriCloud