lang/mono: fix DNS Name Resolution Failure

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

lang/mono: fix DNS Name Resolution Failure

Thomas Frohwein-2
Hi,

Me and David Bern noticed for a while that mono runs into DNS Name Resolution
Failure in draft for a port of OpenRA. I recently encountered it again when
working with SMAPI, a modding plugin for the MonoGame Stardew Valley. It turns
out that OpenBSD just gets ignored when checking for IPv4 and IPv6 capability.

Adding OpenBSD in the same way as FreeBSD, so that MacOsNetworkInterfaceAPI is
used for to set things up fixes the issue. I have tested this with both SMAPI
and the OpenRA draft where the error is now gone and on OpenRA I can now
download the assets from the menu as intended. SMAPI only uses this to check
for updates of existing mods and there were none, but the NameResolutionFailure
message is now gone.

This fixes issue #8168 on GitHub [1] and has been submitted to upstream in pull
request #13633 [2].

ok?

[1] https://github.com/mono/mono/issues/8168
[2] https://github.com/mono/mono/pull/13633

Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/mono/Makefile,v
retrieving revision 1.123
diff -u -p -r1.123 Makefile
--- Makefile 11 Jan 2019 18:49:37 -0000 1.123
+++ Makefile 25 Mar 2019 00:17:55 -0000
@@ -5,7 +5,7 @@ USE_WXNEEDED= Yes
 COMMENT= cross platform, open source .NET developement framework
 
 V= 5.14.0.177
-REVISION= 0
+REVISION= 1
 
 DISTNAME= mono-${V}
 
Index: patches/patch-mcs_class_System_System_Net_NetworkInformation_NetworkInterface_cs
===================================================================
RCS file: patches/patch-mcs_class_System_System_Net_NetworkInformation_NetworkInterface_cs
diff -N patches/patch-mcs_class_System_System_Net_NetworkInformation_NetworkInterface_cs
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-mcs_class_System_System_Net_NetworkInformation_NetworkInterface_cs 25 Mar 2019 00:17:55 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+
+Initialize network interface for OpenBSD like for FreeBSD to address issue
+https://github.com/mono/mono/issues/8168
+Pull Request: https://github.com/mono/mono/pull/13633
+
+Index: mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs
+--- mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs.orig
++++ mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs
+@@ -526,7 +526,7 @@ namespace System.Net.NetworkInformation {
+ bool runningOnUnix = (Environment.OSVersion.Platform == PlatformID.Unix);
+
+ if (runningOnUnix) {
+- if (Platform.IsMacOS || Platform.IsFreeBSD)
++ if (Platform.IsMacOS || Platform.IsFreeBSD || Platform.IsOpenBSD)
+ return new MacOsNetworkInterfaceAPI ();
+
+ return new LinuxNetworkInterfaceAPI ();
Index: patches/patch-mcs_class_System_System_Platform_cs
===================================================================
RCS file: patches/patch-mcs_class_System_System_Platform_cs
diff -N patches/patch-mcs_class_System_System_Platform_cs
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-mcs_class_System_System_Platform_cs 25 Mar 2019 00:17:55 -0000
@@ -0,0 +1,42 @@
+$OpenBSD$
+
+add bool for Platform.IsOpenBSD, to address
+https://github.com/mono/mono/issues/8168
+Upstreamed in PR: https://github.com/mono/mono/pull/13633
+
+Index: mcs/class/System/System/Platform.cs
+--- mcs/class/System/System/Platform.cs.orig
++++ mcs/class/System/System/Platform.cs
+@@ -48,6 +48,7 @@ namespace System {
+
+ #else
+ static bool isFreeBSD;
++ static bool isOpenBSD;
+
+ [DllImport ("libc")]
+ static extern int uname (IntPtr buf);
+@@ -68,6 +69,9 @@ namespace System {
+ case "FreeBSD":
+ isFreeBSD = true;
+ break;
++ case "OpenBSD":
++ isOpenBSD = true;
++ break;
+ }
+ }
+ Marshal.FreeHGlobal (buf);
+@@ -88,6 +92,14 @@ namespace System {
+ if (!checkedOS)
+ CheckOS();
+ return isFreeBSD;
++ }
++ }
++
++ public static bool IsOpenBSD {
++ get {
++ if (!checkedOS)
++ CheckOS();
++ return isOpenBSD;
+ }
+ }
+ }

Reply | Threaded
Open this post in threaded view
|

Re: lang/mono: fix DNS Name Resolution Failure

Thomas Frohwein-2
PS: There is a simple way to see the effect of the proposed diff, for example
in the csharp console. Here how to check it and the output:

Without the diff:
=================

$ csharp
Mono C# Shell, type "help;" for help

Enter statements below.
csharp> using System.Net;
csharp> Using System.Net.Sockets;
(1,13): error CS1525: Unexpected symbol `.', expecting `,', `;', or `='
csharp> using System.Net.Sockets;
csharp> Console.WriteLine("Socket.OSSupportsIPv4: " + Socket.OSSupportsIPv4);                     Socket.OSSupportsIPv4: False                                                                      
csharp> Console.WriteLine("Socket.OSSupportsIPv6: " + Socket.OSSupportsIPv6);                     Socket.OSSupportsIPv6: False                                                                      
csharp> var addresses = Dns.GetHostAddresses("www.google.com");                                  
System.Net.Sockets.SocketException (0x80004005): Could not resolve host 'www.google.com'          
at System.Net.Dns.Error_11001 (System.String hostName) [0x00015] in <407a163f6ff946669bdcb3f2610def4c>:0                                                                                          
at System.Net.Dns.hostent_to_IPHostEntry (System.String originalHostName, System.String h_name, System.String[] h_aliases, System.String[] h_addrlist) [0x00068] in <407a163f6ff946669bdcb3f2610def4c>:0
at System.Net.Dns.GetHostByName (System.String hostName) [0x00027] in <407a163f6ff946669bdcb3f2610def4c>:0
at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00052] in <407a163f6ff946669bdcb3f2610def4c>:0
at System.Net.Dns.GetHostAddresses (System.String hostNameOrAddress) [0x00056] in <407a163f6ff946669bdcb3f2610def4c>:0
at <InteractiveExpressionClass>.Host (System.Object& $retval) [0x00000] in <c312742762344fdc8389ca5b4cab4da5>:0
at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object& result, System.Boolean& result_set) [0x00038] in <8cd285bf020445feb0748aa9b076a2b6>:0
at Mono.CSharpShell.Evaluate (System.String input) [0x00000] in <b90b88ab8c20455c8b76edb869554fa4>:0
csharp>

With the diff:
==============

Enter statements below.
csharp> using System.Net;
csharp> using System.Net.Sockets;
csharp> Console.WriteLine("Socket.OSSupportsIPv4: " + Socket.OSSupportsIPv4);
Socket.OSSupportsIPv4: True
csharp> var addresses = Dns.GetHostAddresses("www.google.com");
csharp> Console.WriteLine(addresses[0]);
172.217.14.228
csharp>

Reply | Threaded
Open this post in threaded view
|

Re: lang/mono: fix DNS Name Resolution Failure

Robert Nagy
In reply to this post by Thomas Frohwein-2
ok!

On 24/03/19 17:26 -0700, Thomas Frohwein wrote:

> Hi,
>
> Me and David Bern noticed for a while that mono runs into DNS Name Resolution
> Failure in draft for a port of OpenRA. I recently encountered it again when
> working with SMAPI, a modding plugin for the MonoGame Stardew Valley. It turns
> out that OpenBSD just gets ignored when checking for IPv4 and IPv6 capability.
>
> Adding OpenBSD in the same way as FreeBSD, so that MacOsNetworkInterfaceAPI is
> used for to set things up fixes the issue. I have tested this with both SMAPI
> and the OpenRA draft where the error is now gone and on OpenRA I can now
> download the assets from the menu as intended. SMAPI only uses this to check
> for updates of existing mods and there were none, but the NameResolutionFailure
> message is now gone.
>
> This fixes issue #8168 on GitHub [1] and has been submitted to upstream in pull
> request #13633 [2].
>
> ok?
>
> [1] https://github.com/mono/mono/issues/8168
> [2] https://github.com/mono/mono/pull/13633
>
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/lang/mono/Makefile,v
> retrieving revision 1.123
> diff -u -p -r1.123 Makefile
> --- Makefile 11 Jan 2019 18:49:37 -0000 1.123
> +++ Makefile 25 Mar 2019 00:17:55 -0000
> @@ -5,7 +5,7 @@ USE_WXNEEDED= Yes
>  COMMENT= cross platform, open source .NET developement framework
>  
>  V= 5.14.0.177
> -REVISION= 0
> +REVISION= 1
>  
>  DISTNAME= mono-${V}
>  
> Index: patches/patch-mcs_class_System_System_Net_NetworkInformation_NetworkInterface_cs
> ===================================================================
> RCS file: patches/patch-mcs_class_System_System_Net_NetworkInformation_NetworkInterface_cs
> diff -N patches/patch-mcs_class_System_System_Net_NetworkInformation_NetworkInterface_cs
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-mcs_class_System_System_Net_NetworkInformation_NetworkInterface_cs 25 Mar 2019 00:17:55 -0000
> @@ -0,0 +1,18 @@
> +$OpenBSD$
> +
> +Initialize network interface for OpenBSD like for FreeBSD to address issue
> +https://github.com/mono/mono/issues/8168
> +Pull Request: https://github.com/mono/mono/pull/13633
> +
> +Index: mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs
> +--- mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs.orig
> ++++ mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs
> +@@ -526,7 +526,7 @@ namespace System.Net.NetworkInformation {
> + bool runningOnUnix = (Environment.OSVersion.Platform == PlatformID.Unix);
> +
> + if (runningOnUnix) {
> +- if (Platform.IsMacOS || Platform.IsFreeBSD)
> ++ if (Platform.IsMacOS || Platform.IsFreeBSD || Platform.IsOpenBSD)
> + return new MacOsNetworkInterfaceAPI ();
> +
> + return new LinuxNetworkInterfaceAPI ();
> Index: patches/patch-mcs_class_System_System_Platform_cs
> ===================================================================
> RCS file: patches/patch-mcs_class_System_System_Platform_cs
> diff -N patches/patch-mcs_class_System_System_Platform_cs
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-mcs_class_System_System_Platform_cs 25 Mar 2019 00:17:55 -0000
> @@ -0,0 +1,42 @@
> +$OpenBSD$
> +
> +add bool for Platform.IsOpenBSD, to address
> +https://github.com/mono/mono/issues/8168
> +Upstreamed in PR: https://github.com/mono/mono/pull/13633
> +
> +Index: mcs/class/System/System/Platform.cs
> +--- mcs/class/System/System/Platform.cs.orig
> ++++ mcs/class/System/System/Platform.cs
> +@@ -48,6 +48,7 @@ namespace System {
> +
> + #else
> + static bool isFreeBSD;
> ++ static bool isOpenBSD;
> +
> + [DllImport ("libc")]
> + static extern int uname (IntPtr buf);
> +@@ -68,6 +69,9 @@ namespace System {
> + case "FreeBSD":
> + isFreeBSD = true;
> + break;
> ++ case "OpenBSD":
> ++ isOpenBSD = true;
> ++ break;
> + }
> + }
> + Marshal.FreeHGlobal (buf);
> +@@ -88,6 +92,14 @@ namespace System {
> + if (!checkedOS)
> + CheckOS();
> + return isFreeBSD;
> ++ }
> ++ }
> ++
> ++ public static bool IsOpenBSD {
> ++ get {
> ++ if (!checkedOS)
> ++ CheckOS();
> ++ return isOpenBSD;
> + }
> + }
> + }
>

Reply | Threaded
Open this post in threaded view
|

Re: lang/mono: fix DNS Name Resolution Failure

Edd Barrett-3
In reply to this post by Thomas Frohwein-2
On Sun, Mar 24, 2019 at 05:26:21PM -0700, Thomas Frohwein wrote:
> Me and David Bern noticed for a while that mono runs into DNS Name Resolution
> Failure in draft for a port of OpenRA.

Ah ha!

I bet this is the same issue as:
https://github.com/OpenRA/OpenRA/issues/15070

I had all but given up porting OpenRA!

--
Best Regards
Edd Barrett

http://www.theunixzoo.co.uk