Reported by Peter Breitenlohner <peb@mppmu.mpg.de> in a thread on devel@XFree86.org: > I fully understand that XFree86 has to support IPv6. The current > implementation has, however, a serious flaw: when compiled with IPv6 support > (which is the default for most linux/gnu systems) the progams implicitly > assume that IPv6 is supported by the kernel. In our case that is not so, and > in order to get things working I had to > #define BuildIPv6 NO > in xc/config/cf/host.def, thereby permanantly disabling IPv6 support. > It would be extremely helpful if one could compile XFree86 with IPv6 > support, but then disable IPv6 at runtime via configuration files > (resources) and/or command line options (in order to avoid various > timeouts), and the programs should automatically fall back to IPv4 in case > IPv6 is not supported by the kernel. > The actual problems encountered were twofold: > 1. xdm produced an error message > chooser socket creation failed > and there was just a useless parent process but no child process(es) and no > Xserver was started. I think the lines 69ff in xc/programs/xdm/socket.c > #if defined(IPv6) && defined(AF_INET6) > chooserFd = socket (AF_INET6, SOCK_STREAM, 0); > #else > chooserFd = socket (AF_INET, SOCK_STREAM, 0); > #endif > ought to be > #if defined(IPv6) && defined(AF_INET6) > chooserFd = socket (AF_INET6, SOCK_STREAM, 0); > if (chooserFd == -1) > #endif > chooserFd = socket (AF_INET, SOCK_STREAM, 0); > although I haven't tested this. > 2. Trying to start chooser by hand lead to a segmentation fault! With a > little tracing I found the following code in xc/programs/xdm/chooser.c in > lines 844ff > #if defined(IPv6) && defined(AF_INET6) > socket6FD = socket (AF_INET6, SOCK_DGRAM, 0); > #endif > and later in lines 856ff > XtAddInput (socketFD, (XtPointer) XtInputReadMask, ReceivePacket, > (XtPointer) &socketFD); > #if defined(IPv6) && defined(AF_INET6) > XtAddInput (socket6FD, (XtPointer) XtInputReadMask, ReceivePacket, > (XtPointer) &socket6FD); > #endif > The second code fragment certainly ought to be > XtAddInput (socketFD, (XtPointer) XtInputReadMask, ReceivePacket, > (XtPointer) &socketFD); > #if defined(IPv6) && defined(AF_INET6) > if (socket6FD != -1) > XtAddInput (socket6FD, (XtPointer) XtInputReadMask, ReceivePacket, > (XtPointer) &socket6FD); > #endif > but that may not suffice. Calling XtAddInput with a untested first argument > is just asking for serious trouble.
Created attachment 133 [details] [review] Patch for some of the problems provided by Peter Breitenlohner
The fixes look reasonable to me, but I don't have a system that I can remove IPv6 support from to test on, so I don't know if they fix all the problems. Unfortunately, when originally developing the IPv6 changes I did so on Solaris, where if you had IPv6 support at compile time, you had it at run time, so I didn't include fallbacks to AF_INET if AF_INET6 failed, but probably should have for systems like Linux without such a guarantee.
Scheduled for commit to RELEASE-1 branch.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.