diff options
author | Ian Dowse <iedowse@FreeBSD.org> | 2002-10-24 02:02:34 +0000 |
---|---|---|
committer | Ian Dowse <iedowse@FreeBSD.org> | 2002-10-24 02:02:34 +0000 |
commit | efac726eebd08c4f0af264f39b5a9fa74051daf5 (patch) | |
tree | f1afe29c68f4d9a3c87f21700f56887304a97253 /sys/netinet/tcp_usrreq.c | |
parent | f64a0a56d49a94d0f8fbe94add3432468f15c6fb (diff) | |
download | src-efac726eebd08c4f0af264f39b5a9fa74051daf5.tar.gz src-efac726eebd08c4f0af264f39b5a9fa74051daf5.zip |
Unbreak the automatic remapping of an INADDR_ANY destination address
to the primary local IP address when doing a TCP connect(). The
tcp_connect() code was relying on in_pcbconnect (actually in_pcbladdr)
modifying the passed-in sockaddr, and I failed to notice this in
the recent change that added in_pcbconnect_setup(). As a result,
tcp_connect() was ending up using the unmodified sockaddr address
instead of the munged version.
There are two cases to handle: if in_pcbconnect_setup() succeeds,
then the PCB has already been updated with the correct destination
address as we pass it pointers to inp_faddr and inp_fport directly.
If in_pcbconnect_setup() fails due to an existing but dead connection,
then copy the destination address from the old connection.
Notes
Notes:
svn path=/head/; revision=105840
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 143a20c55ecd..11351503fe5a 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -848,7 +848,6 @@ tcp_connect(tp, nam, td) struct inpcb *inp = tp->t_inpcb, *oinp; struct socket *so = inp->inp_socket; struct tcpcb *otp; - struct sockaddr_in *sin = (struct sockaddr_in *)nam; struct rmxp_tao *taop; struct rmxp_tao tao_noncached; struct in_addr laddr; @@ -876,14 +875,14 @@ tcp_connect(tp, nam, td) if (oinp != inp && (otp = intotcpcb(oinp)) != NULL && otp->t_state == TCPS_TIME_WAIT && (ticks - otp->t_starttime) < tcp_msl && - (otp->t_flags & TF_RCVD_CC)) + (otp->t_flags & TF_RCVD_CC)) { + inp->inp_faddr = oinp->inp_faddr; + inp->inp_fport = oinp->inp_fport; otp = tcp_close(otp); - else + } else return EADDRINUSE; } inp->inp_laddr = laddr; - inp->inp_faddr = sin->sin_addr; - inp->inp_fport = sin->sin_port; in_pcbrehash(inp); /* Compute window scaling to request. */ |