[w32socket] Turn WireGuard ENOKEY errno to WASANETUNREACH (#43734)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Fri, 23 Oct 2020 16:59:36 +0000 (12:59 -0400)
committerGitHub <noreply@github.com>
Fri, 23 Oct 2020 16:59:36 +0000 (12:59 -0400)
When the destination IP on the packet doesn't match any WireGuard peer (such as
if the peer is disconnected while the app is running), the sender may get an ENOKEY errno.

This is mentioned in Section 3 "Send/Receive" of
https://www.wireguard.com/papers/wireguard.pdf

Fixes https://github.com/mono/mono/issues/20503

Co-authored-by: lambdageek <lambdageek@users.noreply.github.com>
src/mono/mono/metadata/w32socket-unix.c

index 276aabe..3c0e13a 100644 (file)
@@ -1549,6 +1549,9 @@ mono_w32socket_convert_error (gint error)
 #ifdef ENONET
        case ENONET: return WSAENETUNREACH;
 #endif
+#ifdef ENOKEY
+       case ENOKEY: return WSAENETUNREACH;
+#endif
        default:
                g_error ("%s: no translation into winsock error for (%d) \"%s\"", __func__, error, g_strerror (error));
        }