summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_usrreq.c
diff options
context:
space:
mode:
authoriedowse <iedowse@FreeBSD.org>2002-10-21 13:55:50 +0000
committeriedowse <iedowse@FreeBSD.org>2002-10-21 13:55:50 +0000
commita5bc5c7b7ede3570b7cb9530c8d8f2847945f0fa (patch)
treeafd766ec15eff4244ba3cea699f2b6825cd18fbc /sys/netinet/tcp_usrreq.c
parentda47f8f7ff907d670fb37bf616bfe3505a92288d (diff)
downloadFreeBSD-src-a5bc5c7b7ede3570b7cb9530c8d8f2847945f0fa.zip
FreeBSD-src-a5bc5c7b7ede3570b7cb9530c8d8f2847945f0fa.tar.gz
Replace in_pcbladdr() with a more generic inner subroutine for
in_pcbconnect() called in_pcbconnect_setup(). This version performs all of the functions of in_pcbconnect() except for the final committing of changes to the PCB. In the case of an EADDRINUSE error it can also provide to the caller the PCB of the duplicate connection, avoiding an extra in_pcblookup_hash() lookup in tcp_connect(). This change will allow the "temporary connect" hack in udp_output() to be removed and is part of the preparation for adding the IP_SENDSRCADDR control message. Discussed on: -net Approved by: re
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r--sys/netinet/tcp_usrreq.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 491529b..143a20c 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -832,10 +832,10 @@ struct pr_usrreqs tcp6_usrreqs = {
/*
* Common subroutine to open a TCP connection to remote host specified
* by struct sockaddr_in in mbuf *nam. Call in_pcbbind to assign a local
- * port number if needed. Call in_pcbladdr to do the routing and to choose
- * a local host address (interface). If there is an existing incarnation
- * of the same connection in TIME-WAIT state and if the remote host was
- * sending CC options and if the connection duration was < MSL, then
+ * port number if needed. Call in_pcbconnect_setup to do the routing and
+ * to choose a local host address (interface). If there is an existing
+ * incarnation of the same connection in TIME-WAIT state and if the remote
+ * host was sending CC options and if the connection duration was < MSL, then
* truncate the previous TIME-WAIT state and proceed.
* Initialize connection parameters and enter SYN-SENT state.
*/
@@ -849,9 +849,10 @@ tcp_connect(tp, nam, td)
struct socket *so = inp->inp_socket;
struct tcpcb *otp;
struct sockaddr_in *sin = (struct sockaddr_in *)nam;
- struct sockaddr_in *ifaddr;
struct rmxp_tao *taop;
struct rmxp_tao tao_noncached;
+ struct in_addr laddr;
+ u_short lport;
int error;
if (inp->inp_lport == 0) {
@@ -865,14 +866,12 @@ tcp_connect(tp, nam, td)
* earlier incarnation of this same connection still in
* TIME_WAIT state, creating an ADDRINUSE error.
*/
- error = in_pcbladdr(inp, nam, &ifaddr);
- if (error)
+ laddr = inp->inp_laddr;
+ lport = inp->inp_lport;
+ error = in_pcbconnect_setup(inp, nam, &laddr.s_addr, &lport,
+ &inp->inp_faddr.s_addr, &inp->inp_fport, &oinp, td);
+ if (error && oinp == NULL)
return error;
- oinp = in_pcblookup_hash(inp->inp_pcbinfo,
- sin->sin_addr, sin->sin_port,
- inp->inp_laddr.s_addr != INADDR_ANY ? inp->inp_laddr
- : ifaddr->sin_addr,
- inp->inp_lport, 0, NULL);
if (oinp) {
if (oinp != inp && (otp = intotcpcb(oinp)) != NULL &&
otp->t_state == TCPS_TIME_WAIT &&
@@ -882,8 +881,7 @@ tcp_connect(tp, nam, td)
else
return EADDRINUSE;
}
- if (inp->inp_laddr.s_addr == INADDR_ANY)
- inp->inp_laddr = ifaddr->sin_addr;
+ inp->inp_laddr = laddr;
inp->inp_faddr = sin->sin_addr;
inp->inp_fport = sin->sin_port;
in_pcbrehash(inp);
OpenPOWER on IntegriCloud