From fe450452985dcafab0ffaeaf32fca43267ace11f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fengbojiang=28=E5=A7=9C=E5=87=A4=E6=B3=A2=29?= Date: Thu, 14 Mar 2019 18:07:36 +0800 Subject: [PATCH] Revert "Merge branch 'master' of https://github.com/F-Stack/f-stack" Refer #322 #323 #343 This reverts commit 2bc927fd772f1b6bd5cc79aec1ac6d1265cc5862, reversing changes made to 2576201343f20814271b98558cc7215a5155388c. --- freebsd/netinet/in_pcb.c | 5 +---- freebsd/netinet/tcp_usrreq.c | 20 ++++++-------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/freebsd/netinet/in_pcb.c b/freebsd/netinet/in_pcb.c index 22730aed6..37d65330a 100644 --- a/freebsd/netinet/in_pcb.c +++ b/freebsd/netinet/in_pcb.c @@ -1126,10 +1126,7 @@ if (lport == 0) ifp_sin.sin_len = sizeof(ifp_sin); ifa = ifa_ifwithnet((struct sockaddr *)&ifp_sin, 0, RT_ALL_FIBS); if (ifa == NULL) { - ifp_sin.sin_addr.s_addr = faddr.s_addr; - ifa = ifa_ifwithnet((struct sockaddr *)&ifp_sin, 0, RT_ALL_FIBS); - if ( ifa == NULL ) - return (EADDRNOTAVAIL); + return (EADDRNOTAVAIL); } ifp = ifa->ifa_ifp; while (lport == 0) { diff --git a/freebsd/netinet/tcp_usrreq.c b/freebsd/netinet/tcp_usrreq.c index 57c7bc18f..b33efedc7 100644 --- a/freebsd/netinet/tcp_usrreq.c +++ b/freebsd/netinet/tcp_usrreq.c @@ -1321,22 +1321,14 @@ tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) error = EADDRINUSE; goto out; } - - // inp->inp_lport != lport means in_pcbconnect_setup selected new port to inp->inp_lport. - // inp will inhash. - if (in_pcbinshash(inp) != 0) { - inp->inp_laddr.s_addr = INADDR_ANY; - inp->inp_lport = 0; - return (EAGAIN); - } } - else - { - // app call bind() and connect(), lport is set when bind, and the inp is inhashed in bind() function. - // in_pcbconnect_setup() update inp->inp_faddr/inp->inp_fport, so inp should be rehashed. - in_pcbrehash(inp); + + if (in_pcbinshash(inp) != 0) { + inp->inp_laddr.s_addr = INADDR_ANY; + inp->inp_lport = 0; + return (EAGAIN); } - + if (anonport) { inp->inp_flags |= INP_ANONPORT; }