GNOME Bugzilla – Bug 310965
IPv6 support for vino server
Last modified: 2006-11-07 15:48:14 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.
Created attachment 49443 [details] [review] Proposed Patch
marking new, and setting priority to High due to the patch.
Markmc: ping :)
Okay, I've re-worked this patch substantially and comitted the following: http://www.gnome.org/~markmc/code/vino-ipv6-remove-dead-code.patch http://www.gnome.org/~markmc/code/vino-ipv6-use-getaddrinfo.patch http://www.gnome.org/~markmc/code/vino-ipv6-use-inet-ntop.patch http://www.gnome.org/~markmc/code/vino-ipv6-configure-check.patch http://www.gnome.org/~markmc/code/vino-ipv6-create-ipv6-socket.patch http://www.gnome.org/~markmc/code/vino-ipv6-create-ipv6-http-socket.patch Please test and open new bugs for any more changes that may be required ... e.g. on Solaris
Created attachment 75509 [details] [review] patch for branch gnome-2-16
Created attachment 75510 [details] [review] vino-ipv6-create-ipv6-socket.patch for branch gnome-2-16
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.
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)
(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 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; }
Mark, your patches works fine on Solaris. Since we need use latest official tarball(vino-2.16.0.tar.bz2), I use the modified patches I upload in Comment #5 and #10. The whole patch list for gnome-2-16 branch is: http://bugzilla.gnome.org/attachment.cgi?id=75509&action=view http://www.gnome.org/~markmc/code/vino-ipv6-use-getaddrinfo.patch http://www.gnome.org/~markmc/code/vino-ipv6-use-inet-ntop.patch http://www.gnome.org/~markmc/code/vino-ipv6-configure-check.patch http://bugzilla.gnome.org/show_bug.cgi?id=310965#c10 http://www.gnome.org/~markmc/code/vino-ipv6-create-ipv6-http-socket.patch