After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 310965 - IPv6 support for vino server
IPv6 support for vino server
Status: RESOLVED FIXED
Product: vino
Classification: Applications
Component: Server
unspecified
Other Linux
: High enhancement
: ---
Assigned To: Vino Maintainer(s)
Vino Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2005-07-20 09:06 UTC by Srirama Sharma
Modified: 2006-11-07 15:48 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Proposed Patch (19.42 KB, patch)
2005-07-20 09:09 UTC, Srirama Sharma
none Details | Review
patch for branch gnome-2-16 (17.66 KB, patch)
2006-10-27 15:03 UTC, Halton Huo
none Details | Review
vino-ipv6-create-ipv6-socket.patch for branch gnome-2-16 (2.94 KB, patch)
2006-10-27 15:05 UTC, Halton Huo
none Details | Review

Description Srirama Sharma 2005-07-20 09:06:08 UTC
Will be attaching the patch in a minute.

Following are the changes done to add support for IPv6:

- configure.in: Added IPv6 specific checks and host check.

- capplet/vino-preferences.c: (vino_preferences_get_local_hostname) : 
  Make use of getaddrinfo function to get the hostname when IPv6 is enabled, 
  else use gethostbyname.

- server/libvncserver/main.c: (listenerRun) : use sockaddr_in6 structure 
  incase of IPv6 availability. 

- server/libvncserver/rfbserver.c: (rfbNewClient) : For IPv6 address 
  conversion, make use of inet_ntop function as inet_ntoa supports only
  IPv4 addresses.

- server/libvncserver/sockets.c: 
  (rfbProcessNewConnection) : Use inet_ntop and inet_ntoa appropriately for 
  address conversion.
  (ListenOnTCPPort) : create and bind with IPv6 sockets when IPv6 support is 
  present 
  (have_ipv6) and (have_ipv6_solaris): Functions to check for IPv6 support at 
  runtime.

- server/libvncserver/rfb/rfb.h: Declared have_ipv6 and have_ipv6_solaris 
  functions.

- server/vino-http.c: (vino_http_create_listening_socket) : Changed so that 
  we create and bind with Ipv6 sockets when IPv6 support is present.
Comment 1 Srirama Sharma 2005-07-20 09:09:30 UTC
Created attachment 49443 [details] [review]
Proposed Patch
Comment 2 Brent Smith (smitten) 2005-08-03 04:56:26 UTC
marking new, and setting priority to High due to the patch.
Comment 3 Srirama Sharma 2005-10-06 11:54:39 UTC
Markmc: ping :)
Comment 5 Halton Huo 2006-10-27 15:03:01 UTC
Created attachment 75509 [details] [review]
patch for branch gnome-2-16
Comment 6 Halton Huo 2006-10-27 15:05:57 UTC
Created attachment 75510 [details] [review]
vino-ipv6-create-ipv6-socket.patch for branch gnome-2-16
Comment 7 Halton Huo 2006-10-27 15:10:43 UTC
Mark, when will you going to commit this fix into branch gnome-2-16?

Two of your patches do not work on that branch,
* vino-ipv6-remove-dead-code.patch
* vino-ipv6-create-ipv6-socket.patch

I found function ListenOnTCPPort in patch vino-ipv6-create-ipv6-socket.patch is different in HEAD and branch gnome-2-16.

I created the two new patches based on tarball version 2.16.0, need your review.
Comment 8 Mark McLoughlin 2006-10-27 16:07:18 UTC
It's a new feature, with a fair bit of code churn, much of which even affects the non-IPv6 code.

So, I don't think it's appropriate for the gnome-2-16 branch ...

(I isolated the patches specifically to make it easier for distributors to incorporate them in their versions, though)
Comment 9 Halton Huo 2006-10-27 16:58:17 UTC
(In reply to comment #8)
> It's a new feature, with a fair bit of code churn, much of which even affects
> the non-IPv6 code.
> 
> So, I don't think it's appropriate for the gnome-2-16 branch ...
> 
> (I isolated the patches specifically to make it easier for distributors to
> incorporate them in their versions, though)
> 

I do not read your patch carefully, where can I get the separate ipv6 patch? Does Srirama Sharma's patch okay? 
Comment 10 Halton Huo 2006-11-07 15:22:02 UTC
Comment on attachment 75510 [details] [review]
vino-ipv6-create-ipv6-socket.patch for branch gnome-2-16

--- vino-2.16.0.old/server/libvncserver/rfb/rfb.h	2006-11-07 21:53:23.035257000 +0800
+++ vino-2.16.0/server/libvncserver/rfb/rfb.h	2006-11-07 21:55:06.163532000 +0800
@@ -112,6 +112,7 @@
     char rfbThisHost[255];
 
     rfbBool autoPort;
+    rfbBool localOnly;
     int rfbPort;
     SOCKET rfbListenSock;
     int maxSock;
@@ -392,7 +393,7 @@
 extern int WriteExact(rfbClientPtr cl, const char *buf, int len);
 extern void rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen);
 extern void rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec);
-extern int ListenOnTCPPort(int port);
+extern int ListenOnTCPPort(int port, rfbBool localOnly);
 
 /* rfbserver.c */
 
--- vino-2.16.0.old/server/libvncserver/sockets.c	2006-11-07 21:53:23.036271000 +0800
+++ vino-2.16.0/server/libvncserver/sockets.c	2006-11-07 21:54:03.941308000 +0800
@@ -132,7 +132,7 @@
         rfbLog("Autoprobing TCP port \n");
 
         for (i = 5900; i < 6000; i++) {
-            if ((rfbScreen->rfbListenSock = ListenOnTCPPort(i)) >= 0) {
+            if ((rfbScreen->rfbListenSock = ListenOnTCPPort(i, rfbScreen->localOnly)) >= 0) {
 		rfbScreen->rfbPort = i;
 		break;
 	    }
@@ -151,7 +151,7 @@
     else if(rfbScreen->rfbPort>0) {
       rfbLog("Listening for VNC connections on TCP port %d\n", rfbScreen->rfbPort);
 
-      if ((rfbScreen->rfbListenSock = ListenOnTCPPort(rfbScreen->rfbPort)) < 0) {
+      if ((rfbScreen->rfbListenSock = ListenOnTCPPort(rfbScreen->rfbPort, rfbScreen->localOnly)) < 0) {
 	rfbLogPerror("ListenOnTCPPort");
 	return;
       }
@@ -471,28 +471,48 @@
 }
 
 int
-ListenOnTCPPort(port)
+ListenOnTCPPort(port, localOnly)
     int port;
+    rfbBool localOnly;
 {
-    struct sockaddr_in addr;
-    int sock;
+    int sock = -1;
     int one = 1;
+    struct sockaddr_in addr_in;
+    struct sockaddr *addr;
+    socklen_t addrlen;
+
+#ifdef ENABLE_IPV6
+    struct sockaddr_in6 addr_in6;
+    memset(&addr_in6, 0, sizeof(addr_in6));
+    addr_in6.sin6_family = AF_INET6;
+    addr_in6.sin6_port = htons(port);
+    addr_in6.sin6_addr = localOnly ? in6addr_loopback : in6addr_any;
 
-    memset(&addr, 0, sizeof(addr));
-    addr.sin_family = AF_INET;
-    addr.sin_port = htons(port);
-    /* addr.sin_addr.s_addr = interface.s_addr; */
-    addr.sin_addr.s_addr = INADDR_ANY;
+    addr = (struct sockaddr *)&addr_in6;
+    addrlen = sizeof(addr_in6);
 
-    if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-	return -1;
+    sock = socket(AF_INET6, SOCK_STREAM, 0);
+#endif
+
+    if (sock < 0) {
+        if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+            return -1;
+
+        memset(&addr_in, 0, sizeof(addr_in));
+        addr_in.sin_family = AF_INET;
+        addr_in.sin_port = htons(port);
+        addr_in.sin_addr.s_addr = localOnly ? htonl(INADDR_LOOPBACK) : htonl(INADDR_ANY);
+
+        addr = (struct sockaddr *)&addr_in;
+        addrlen = sizeof(addr_in);
     }
+
     if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
 		   (char *)&one, sizeof(one)) < 0) {
 	close(sock);
 	return -1;
     }
-    if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+    if (bind(sock, addr, addrlen) < 0) {
 	close(sock);
 	return -1;
     }