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?
FreeBSD has implemented a special PRC_UNREACH_PORT handling in
tcp_ctlinput(). Should we do that, too?
bluhm
> --------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