Hi Alexandr,
I've tested this and can confirm it works. Attempted TCP sessions get
an immediate 'Connection refused' error after the first ICMP port
unreachable error.
Personally, I like it. Thank you for the quick fix!
Paul
On Wed, Oct 30, 2019 at 05:56:38PM +0100, Alexandr Nedvedicky wrote:
| Hello,
|
| So I did poke around and it looks like tcp_notify() requires a small tweak. I
| did check NetBSD and it looks like NetBSD is suffering from the same glitch
| (unless I'm missing something).
|
| The change below makes tcp_notify() to indicate ICMP unreachable errors for
not
| connected sockets immediately.
|
| OK?
|
| thanks and
| regards
| sashan
|
| --------8<---------------8<---------------8<------------------8<--------
| diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
| index f1aa5b058f1..02dc41b4d45 100644
| --- a/sys/netinet/tcp_subr.c
| +++ b/sys/netinet/tcp_subr.c
| @@ -574,9 +574,13 @@ tcp_notify(struct inpcb *inp, int error)
| */
| if (tp->t_state == TCPS_ESTABLISHED &&
| (error == EHOSTUNREACH || error == ENETUNREACH ||
| - error == EHOSTDOWN)) {
| + error == EHOSTDOWN))
| return;
| - } else if (TCPS_HAVEESTABLISHED(tp->t_state) == 0 &&
| + else if (TCPS_HAVEESTABLISHED(tp->t_state) == 0 &&
| + (error == EHOSTUNREACH || error == ENETUNREACH ||
| + error == EHOSTDOWN || error == ECONNREFUSED))
| + so->so_error = error;
| + else if (TCPS_HAVEESTABLISHED(tp->t_state) == 0 &&
| tp->t_rxtshift > 3 && tp->t_softerror)
| so->so_error = error;
| else
|
--
>++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
http://www.weirdnet.nl/