Add support for clients that sent ipv4 addresses to a dual-stacked host

Christoph Bartoschek bartoschek at or.uni-bonn.de
Sat Nov 28 03:15:33 PST 2009


Hi,

I have problems to connect from ipv4-only thin clients to our xdm server. 
There is a bug in the novell-bugzilla:

http://bugzilla.novell.com/show_bug.cgi?id=546632

The reason is that ipv4 addresses are discarded if they are received over a 
ipv6 socket. The attached patch fixes this.

I did not test it yet. I will do it on monday when I have access to the thin 
clients. However I wanted to get feedback whether such a patch is wanted and 
what you think about the approach before I invest more time:


Christoph Bartoschek

---
 xdmcp.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/xdmcp.c b/xdmcp.c
index 7c91d1e..447b744 100644
--- a/xdmcp.c
+++ b/xdmcp.c
@@ -791,8 +791,8 @@ forward_respond (
 		{
 		    struct sockaddr_in6	in6_addr;

-		    if (clientAddress.length != 16 ||
-		        clientPort.length != 2)
+		    if ((clientAddress.length != 16 && clientAddress.length != 4) ||
+		        (clientPort.length != 2))
 		    {
 			goto badAddress;
 		    }
@@ -801,7 +801,22 @@ forward_respond (
 		    in6_addr.sin6_len = sizeof(in6_addr);
 #  endif
 		    in6_addr.sin6_family = AF_INET6;
-		    memmove(&in6_addr.sin6_addr,clientAddress.data,clientAddress.length);
+		    if (clientAddress.length == 16) {
+			memmove(in6_addr.sin6_addr.s6_addr, clientAddress.data, 16);
+		    } else {
+			/* If the client wants to forward the xdm server to an
+			   ipv4 hosts it sends an ipv4 address in the forward
+			   packet. On dual-stack hosts the packet arrives as a
+			   ipv6 packet. To respond to the ipv4 host one has
+			   to create an ipv4-mapped address.
+
+			   One example where this is necessary is an ipv4-only
+			   thin client that connects to a dual-stacked xdm.
+			*/
+			in6_addr.sin6_addr.s6_addr[10] = 0xff;
+			in6_addr.sin6_addr.s6_addr[11] = 0xff;
+			memmove(in6_addr.sin6_addr.s6_addr + 12, clientAddress.data, 4);
+		    }
 		    memmove((char *) &in6_addr.sin6_port, clientPort.data, 2);
 		    client = (struct sockaddr *) &in6_addr;
 		    clientlen = sizeof (in6_addr);
--
1.6.5.3



More information about the xorg-devel mailing list