Debian Bug report logs - #382189
no IPv6 support

version graph

Package: nbd-server; Maintainer for nbd-server is Wouter Verhelst <wouter@debian.org>; Source for nbd-server is src:nbd.

Reported by: Wouter Verhelst <wouter@debian.org>

Date: Wed, 9 Aug 2006 13:33:22 UTC

Severity: important

Tags: ipv6, patch, sid, squeeze

Found in versions nbd/1:2.8.5-1, 2.9.14-3

Fixed in version nbd/1:2.9.15-1

Done: Wouter Verhelst <wouter@debian.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org:
Bug#382189; Package nbd-server. Full text and rfc822 format available.

Acknowledgement sent to Wouter Verhelst <wouter@debian.org>:
New Bug report received and forwarded. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Wouter Verhelst <wouter@debian.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: no IPv6 support
Date: Wed, 09 Aug 2006 15:27:52 +0200
Package: nbd-server
Version: 1:2.8.5-1
Severity: important

nbd-server has no IPv6-support as of this writing.

I'll try to fix it, but of course help is always welcome ;-)

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-686-smp
Locale: LANG=nl_BE.UTF-8@euro, LC_CTYPE=nl_BE.UTF-8@euro (charmap=UTF-8)

Versions of packages nbd-server depends on:
ii  debconf [debconf-2.0]         1.5.3      Debian configuration management sy
ii  libc6                         2.3.6-18   GNU C Library: Shared libraries
ii  libglib2.0-0                  2.10.3-3   The GLib library of C routines

nbd-server recommends no packages.

-- debconf information excluded



Tags added: ipv6 Request was from Simon Paillard <simon.paillard@resel.enst-bretagne.fr> to control@bugs.debian.org. (Sun, 04 Jan 2009 16:15:06 GMT) Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Wouter Verhelst <wouter@debian.org>:
Bug#382189; Package nbd-server. (Tue, 16 Mar 2010 11:39:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Neutron Soutmun <neo.neutron@gmail.com>:
Extra info received and forwarded to list. Copy sent to Wouter Verhelst <wouter@debian.org>. (Tue, 16 Mar 2010 11:39:03 GMT) Full text and rfc822 format available.

Message #12 received at 382189@bugs.debian.org (full text, mbox):

From: Neutron Soutmun <neo.neutron@gmail.com>
To: Debian Bug Tracking System <382189@bugs.debian.org>
Subject: Re: IPv6 support
Date: Tue, 16 Mar 2010 18:36:22 +0700
[Message part 1 (text/plain, inline)]
Package: nbd
Version: 2.9.14-3
Severity: normal
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I have provide the initial patch for IPv6 support in
nbd-{server, client} which the nbd-server able to
serve in both IPv4 and IPv6 requests.

Patch is attached.

The client can connect to the server that listen on
IPv6 or IPv4 like this on command line

# nbd-client ::1@11111 /dev/nbd0
or
# nbd-client 127.0.0.1@11111 /dev/nbd0

Substitute the port separator from ":" to "@".

Please test and also advice me if you have seen
something wrong in the code.

Regards,
Neutron Soutmun

- -- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=th_TH.UTF-8, LC_CTYPE=th_TH.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkufbTEACgkQ1k7Ar9TO/TfBjwCfUfGLSRwg3Mlo0TvcubZQzQbY
7lYAniCEFhJAIdChCnli0NC4as5VNzTW
=FF47
-----END PGP SIGNATURE-----
[nbd-ipv6.patch (text/x-diff, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#382189; Package nbd-server. (Tue, 16 Mar 2010 12:27:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Wouter Verhelst <wouter@debian.org>:
Extra info received and forwarded to list. (Tue, 16 Mar 2010 12:27:03 GMT) Full text and rfc822 format available.

Message #17 received at 382189@bugs.debian.org (full text, mbox):

From: Wouter Verhelst <wouter@debian.org>
To: Neutron Soutmun <neo.neutron@gmail.com>, 382189@bugs.debian.org
Subject: Re: Bug#382189: IPv6 support
Date: Tue, 16 Mar 2010 13:24:54 +0100
Whee! Thanks!

I'd had this on my TODO list for, well, quite a while, but never had
gotten around to actually work on this.

On Tue, Mar 16, 2010 at 06:36:22PM +0700, Neutron Soutmun wrote:
> Package: nbd
> Version: 2.9.14-3
> Severity: normal
> Tags: patch

I should probably point out that there's a git tree for the upstream
code: it's on github ("/yoe/nbd"), and on sourceforge
(nbd.git.sourceforge.net).

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> I have provide the initial patch for IPv6 support in
> nbd-{server, client} which the nbd-server able to
> serve in both IPv4 and IPv6 requests.
> 
> Patch is attached.
> 
> The client can connect to the server that listen on
> IPv6 or IPv4 like this on command line
> 
> # nbd-client ::1@11111 /dev/nbd0
> or
> # nbd-client 127.0.0.1@11111 /dev/nbd0
> 
> Substitute the port separator from ":" to "@".

Indeed, that would be required for proper IPv6 support.

However, I'd like to have some way of backwards compatibility. Since
IPv6 addresses have at least two colons in them, we could check whether
there are two or more, and if not, assume that the colon is still the
separator.

That shouldn't cause too much of a problem.

> Please test and also advice me if you have seen
> something wrong in the code.
> 
> Regards,
> Neutron Soutmun
> 
> - -- System Information:
> Debian Release: squeeze/sid
>   APT prefers unstable
>   APT policy: (500, 'unstable')
> Architecture: amd64 (x86_64)
> 
> Kernel: Linux 2.6.32-2-amd64 (SMP w/2 CPU cores)
> Locale: LANG=th_TH.UTF-8, LC_CTYPE=th_TH.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/bash
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> 
> iEYEARECAAYFAkufbTEACgkQ1k7Ar9TO/TfBjwCfUfGLSRwg3Mlo0TvcubZQzQbY
> 7lYAniCEFhJAIdChCnli0NC4as5VNzTW
> =FF47
> -----END PGP SIGNATURE-----

> diff -u nbd-2.9.14/nbd-server.c nbd-2.9.14/nbd-server.c
> --- nbd-2.9.14/nbd-server.c
> +++ nbd-2.9.14/nbd-server.c
> @@ -49,6 +49,10 @@
>   * 11/02/2004 - Doxygenified the source, modularized it a bit. Needs a 
>   * 	lot more work, but this is a start. Wouter Verhelst
>   * 	<wouter@debian.org>
> + * 16/03/2010 - Add IPv6 support.
> + * 	Kitt Tientanopajai <kitt@kitty.in.th>
> + *	Neutron Soutmun <neo.neutron@gmail.com>
> + *	Suriya Soutmun <darksolar@gmail.com>
>   */
>  
>  /* Includes LFS defines, which defines behaviours of some of the following
> @@ -70,8 +74,8 @@
>  #include <signal.h>		/* sigaction */
>  #include <errno.h>
>  #include <netinet/tcp.h>
> -#include <netinet/in.h>		/* sockaddr_in, htons, in_addr */
> -#include <netdb.h>		/* hostent, gethostby*, getservby* */
> +#include <netinet/in.h>
> +#include <netdb.h>
>  #include <syslog.h>
>  #include <unistd.h>
>  #include <stdio.h>
> @@ -178,6 +182,7 @@
>  	char* authname;      /**< filename of the authorization file */
>  	int flags;           /**< flags associated with this exported file */
>  	int socket;	     /**< The socket of this server. */
> +	int socket_family;   /**< family of the socket */
>  	VIRT_STYLE virtstyle;/**< The style of virtualization, if any */
>  	uint8_t cidrlen;     /**< The length of the mask when we use
>  				  CIDR-style virtualization */
> @@ -338,7 +343,7 @@
>   */
>  void usage() {
>  	printf("This is nbd-server version " VERSION "\n");
> -	printf("Usage: [ip:]port file_to_export [size][kKmM] [-l authorize_file] [-r] [-m] [-c] [-C configuration file] [-p PID file name] [-o section name]\n"
> +	printf("Usage: [ip@]port file_to_export [size][kKmM] [-l authorize_file] [-r] [-m] [-c] [-C configuration file] [-p PID file name] [-o section name]\n"
>  	       "\t-r|--read-only\t\tread only\n"
>  	       "\t-m|--multi-file\t\tmultiple file\n"
>  	       "\t-c|--copy-on-write\tcopy on write\n"
> @@ -417,7 +422,7 @@
>  			/* non-option argument */
>  			switch(nonspecial++) {
>  			case 0:
> -				addr_port=g_strsplit(optarg, ":", 2);
> +				addr_port=g_strsplit(optarg, "@", 2);
>  				if(addr_port[1]) {
>  					serve->port=strtol(addr_port[1], NULL, 0);
>  					serve->listenaddr=g_strdup(addr_port[0]);
> @@ -526,6 +531,46 @@
>  }
>  
>  /**
> + * duplicate server 
> + * @param s the old server we want to duplicate
> + **/
> +SERVER* dup_serve(SERVER *s) {
> +	SERVER *serve = NULL;
> +
> +	serve=g_new0(SERVER, 1);
> +	if (serve == NULL)
> +		return NULL;
> +
> +	memset(serve,0,sizeof(SERVER));

g_new0 already does this (that's the 0 in the function name)

> +	if (s->exportname)
> +		serve->exportname = g_strdup(s->exportname);
> +
> +	serve->expected_size = s->expected_size;
> +
> +	if (s->listenaddr)
> +		serve->listenaddr = g_strdup(s->listenaddr);
> +
> +	serve->port = s->port;	
> +
> +	if (s->authname)
> +		serve->authname = strdup(s->authname);
> +
> +	serve->flags = s->flags;
> +	serve->socket = serve->socket;
> +	serve->socket_family = serve->socket_family;
> +	serve->cidrlen = s->cidrlen;
> +
> +	if (s->prerun)
> +		serve->prerun = g_strdup(s->prerun);
> +
> +	if (s->postrun)
> +		serve->postrun = g_strdup(s->postrun);
> +
> +	return serve;
> +}
> +
> +/**
>   * Parse the config file.
>   *
>   * @param f the name of the config file
> @@ -539,6 +584,7 @@
>  	const char* DEFAULT_ERROR = "Could not parse %s in group %s: %s";
>  	const char* MISSING_REQUIRED_ERROR = "Could not find required value %s in group %s: %s";
>  	SERVER s;
> +	SERVER *ns = NULL;
>  	gchar *virtstyle=NULL;
>  	PARAM lp[] = {
>  		{ "exportname", TRUE,	PARAM_STRING, 	NULL, 0 },
> @@ -690,7 +736,17 @@
>  		if(i>0) {
>  			if(!s.listenaddr) {
>  				s.listenaddr = g_strdup("0.0.0.0");
> +				s.socket_family = AF_UNSPEC;
> +
> +			  ns = dup_serve (&s);	
> +				if (ns) {
> +					ns->socket_family = AF_INET6;
> +					g_array_append_val(retval, *ns);
> +					free(ns);
> +					ns = NULL;
> +				}	
>  			}

What is the reason for that? Doesn't AF_UNSPEC already mean we're
listening for v6 addresses, too? Or am I missing something?

> +
>  			g_array_append_val(retval, s);
>  		}
>  #ifndef WITH_SDP
> @@ -1346,15 +1402,34 @@
>  void set_peername(int net, CLIENT *client) {
>  	struct sockaddr_storage addrin;
>  	struct sockaddr_storage netaddr;
> +	struct sockaddr_in  *netaddr4 = NULL;
> +	struct sockaddr_in6 *netaddr6 = NULL;
>  	size_t addrinlen = sizeof( addrin );
> -	char *peername;
> -	char *netname;
> -	char *tmp;
> +	struct addrinfo hints;
> +	struct addrinfo *ai = NULL;
> +	char peername[NI_MAXHOST];
> +	char netname[NI_MAXHOST];
> +	char *tmp = NULL;
>  	int i;
> +	int e;
> +	int shift;
>  
> -	if (getpeername(net, (struct sockaddr *) &addrin, (socklen_t *)&addrinlen) < 0)
> +	if (getpeername(net, (struct sockaddr *)&addrin, (socklen_t *)&addrinlen) < 0)

Please don't do gratuitous whitespace changes; they convolute the patch
and make it harder to see what's going on.

>  		err("getsockname failed: %m");
> -	peername = g_strdup(inet_ntoa(addrin.sin_addr));
> +
> +	getnameinfo((struct sockaddr *)&addrin, (socklen_t)addrinlen,
> +		peername, sizeof (peername), NULL, 0, NI_NUMERICHOST);
> +
> +	memset(&hints, '\0', sizeof (hints));
> +	hints.ai_flags = AI_ADDRCONFIG;
> +	e = getaddrinfo(peername, NULL, &hints, &ai);
> +
> +	if(e != 0) {
> +		fprintf(stderr, "getaddrinfo failed: %s", gai_strerror(e));
> +		freeaddrinfo(ai);
> +		return;
> +	}
> +
>  	switch(client->server->virtstyle) {
>  		case VIRT_NONE:
>  			client->exportname=g_strdup(client->server->exportname);
> @@ -1370,18 +1445,42 @@
>  			break;
>  		case VIRT_CIDR:
>  			memcpy(&netaddr, &addrin, addrinlen);
> -			netaddr.sin_addr.s_addr>>=32-(client->server->cidrlen);
> -			netaddr.sin_addr.s_addr<<=32-(client->server->cidrlen);
> -			netname = inet_ntoa(netaddr.sin_addr);
> -			tmp=g_strdup_printf("%s/%s", netname, peername);
> -			client->exportname=g_strdup_printf(client->server->exportname, tmp);
> +			if(ai->ai_family == AF_INET) {
> +				netaddr4 = (struct sockaddr_in *)&netaddr;
> +				(netaddr4->sin_addr).s_addr>>=32-(client->server->cidrlen);
> +				(netaddr4->sin_addr).s_addr<<=32-(client->server->cidrlen);
> +
> +				getnameinfo((struct sockaddr *) netaddr4, (socklen_t) addrinlen,
> +							netname, sizeof (netname), NULL, 0, NI_NUMERICHOST);
> +				tmp=g_strdup_printf("%s/%s", netname, peername);
> +			}else if(ai->ai_family == AF_INET6) {
> +				netaddr6 = (struct sockaddr_in6 *)&netaddr;
> +
> +				shift = 128-(client->server->cidrlen);
> +				i = 3;
> +				while(shift >= 32) {
> +					((netaddr6->sin6_addr).s6_addr32[i])=0;
> +					shift-=32;
> +					i--;
> +				}
> +				(netaddr6->sin6_addr).s6_addr32[i]>>=shift;
> +				(netaddr6->sin6_addr).s6_addr32[i]<<=shift;
> +
> +				getnameinfo((struct sockaddr *)netaddr6, (socklen_t)addrinlen,
> +					    netname, sizeof(netname), NULL, 0, NI_NUMERICHOST);
> +				tmp=g_strdup_printf("%s/%s", netname, peername);
> +			}
> +
> +			if(tmp != NULL)
> +			  client->exportname=g_strdup_printf(client->server->exportname, tmp);
> +
>  			break;
>  	}
>  
> +	freeaddrinfo(ai);
>  	msg4(LOG_INFO, "connect from %s, assigned file is %s", 
>  	     peername, client->exportname);
>  	client->clientname=g_strdup(peername);
> -	g_free(peername);
>  }
>  
>  /**
> @@ -1493,23 +1592,53 @@
>   **/
>  void setup_serve(SERVER *serve) {
>  	struct sockaddr_storage addrin;
> +	struct addrinfo hints;
> +	struct addrinfo *ai = NULL;
>  	struct sigaction sa;
>  	int addrinlen = sizeof(addrin);
>  	int sock_flags;
> -	int af;
>  #ifndef sun
>  	int yes=1;
>  #else
>  	char yes='1';
>  #endif /* sun */
> +	gchar *port = NULL;
> +	int e;
> +
> +	memset(&hints,'\0',sizeof(hints));
> +	hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG | AI_NUMERICSERV;
> +	hints.ai_socktype = SOCK_STREAM;
> +
> +	port = g_strdup_printf ("%d", serve->port);
> +	if (port == NULL)
> +		return;
> +
> +	if(g_strcmp0(serve->listenaddr, "0.0.0.0") == 0) {

This would mean that if someone were to use 'nbd-server 0.0.0.0:1234' to
explicitly bind to an IPv4 address, this would not work.

I think the disabling of IPv6 for those who want it, should still be
possible.

> +		hints.ai_family = serve->socket_family;
> +		e = getaddrinfo(NULL,port,&hints,&ai); 
> +	} else {
> +		e = getaddrinfo(serve->listenaddr,port,&hints,&ai); 
> +	}
> +
> +	g_free(port);
> +
> +	if(e!=0) {
> +		freeaddrinfo(ai);
> +		return;
> +	}

This should probably use the err() function (which logs an error and
exits) instead.

> +
> +	if(serve->socket_family == AF_UNSPEC)
> +		serve->socket_family = ai->ai_family;
>  
> -	af = AF_INET;
>  #ifdef WITH_SDP
> -	if ((serve->flags) && F_SDP) {
> -		af = AF_INET_SDP;
> +	if((serve->flags) && F_SDP) {
> +		if (ai->ai_family == AF_INET)
> +			ai->ai_family = AF_INET_SDP;
> +		else (ai->ai_family == AF_INET6)
> +			ai->ai_family = AF_INET6_SDP;
>  	}
>  #endif
> -	if ((serve->socket = socket(af, SOCK_STREAM, IPPROTO_TCP)) < 0)
> +	if ((serve->socket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0)
>  		err("socket: %m");
>  
>  	/* lose the pesky "Address already in use" error message */
> @@ -1529,20 +1658,15 @@
>  	}
>  
>  	DEBUG("Waiting for connections... bind, ");
> -	addrin.sin_family = AF_INET;
> -#ifdef WITH_SDP
> -	if(serve->flags & F_SDP) {
> -		addrin.sin_family = AF_INET_SDP;
> -	}
> -#endif
> -	addrin.sin_port = htons(serve->port);
> -	if(!inet_aton(serve->listenaddr, &(addrin.sin_addr)))
> -		err("could not parse listen address");
> -	if (bind(serve->socket, (struct sockaddr *) &addrin, addrinlen) < 0)
> +	e = bind(serve->socket, ai->ai_addr, ai->ai_addrlen);
> +	if (e != 0 && errno != EADDRINUSE)
>  		err("bind: %m");
>  	DEBUG("listen, ");
>  	if (listen(serve->socket, 1) < 0)
>  		err("listen: %m");
> +
> +	freeaddrinfo (ai);
> +
>  	sa.sa_handler = sigchld_handler;
>  	sigemptyset(&sa.sa_mask);
>  	sa.sa_flags = SA_RESTART;
[... packaging bits snipped ...]
> --- nbd-2.9.14.orig/nbd-client.c
> +++ nbd-2.9.14/nbd-client.c
> @@ -11,6 +11,10 @@
>   * Version 2.1 - Check for disconnection before INIT_PASSWD is received
>   * 	to make errormsg a bit more helpful in case the server can't
>   * 	open the exported file.
> + * 16/03/2010 - Add IPv6 support.
> + * 	Kitt Tientanopajai <kitt@kitty.in.th>
> + *	Neutron Soutmun <neo.neutron@gmail.com>
> + *	Suriya Soutmun <darksolar@gmail.com>
>   */
>  
>  #include "config.h"
> @@ -21,8 +25,8 @@
>  #include <sys/types.h>
>  #include <unistd.h>
>  #include <netinet/tcp.h>
> -#include <netinet/in.h>		/* sockaddr_in, htons, in_addr */
> -#include <netdb.h>		/* hostent, gethostby*, getservby* */
> +#include <netinet/in.h>
> +#include <netdb.h>
>  #include <stdio.h>
>  #include <fcntl.h>
>  #include <syslog.h>
> @@ -67,33 +71,54 @@
>  
>  int opennet(char *name, int port, int sdp) {
>  	int sock;
> -	struct sockaddr_in xaddrin;
> -	int xaddrinlen = sizeof(xaddrin);
> -	struct hostent *hostn;
> -	int af;
> -
> -	hostn = gethostbyname(name);
> -	if (!hostn)
> -		err("Gethostname failed: %h\n");
> +	char portstr[6];
> +	struct addrinfo hints;
> +	struct addrinfo *ai = NULL;
> +	struct addrinfo *rp = NULL;
> +	int e;
> +
> +	snprintf(portstr, sizeof(portstr), "%d", port);
> +
> +	memset(&hints,'\0',sizeof(hints));
> +	hints.ai_family = AF_UNSPEC;
> +	hints.ai_socktype = SOCK_STREAM;
> +	hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV;
> +	hints.ai_protocol = IPPROTO_TCP;
> +
> +	e = getaddrinfo(name, portstr, &hints, &ai);
> +
> +	if(e != 0) {
> +		freeaddrinfo(ai);
> +		return -1;
> +	}

Again, use err() here.

> -	af = AF_INET;
>  	if(sdp) {
>  #ifdef WITH_SDP
> -		af = AF_INET_SDP;
> +	if (ai->ai_family == AF_INET)
> +		ai->ai_family = AF_INET_SDP;
> +	else (ai->ai_family == AF_INET6)
> +		ai->ai_family = AF_INET6_SDP;
>  #else
>  		err("Can't do SDP: I was not compiled with SDP support!");
>  #endif
>  	}
> -	if ((sock = socket(af, SOCK_STREAM, IPPROTO_TCP)) < 0)
> -		err("Socket failed: %m");
>  
> -	xaddrin.sin_family = af;
> -	xaddrin.sin_port = htons(port);
> -	xaddrin.sin_addr.s_addr = *((int *) hostn->h_addr);
> -	if ((connect(sock, (struct sockaddr *) &xaddrin, xaddrinlen) < 0))
> -		err("Connect: %m");
> +	for(rp = ai; rp != NULL; rp = rp->ai_next) {
> +		sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
> +
> +		if(sock == -1)
> +			continue;	/* error */
> +
> +		if(connect(sock, rp->ai_addr, rp->ai_addrlen) != -1)
> +			break;		/* success */
> +	}
> +
> +	if (rp == NULL)
> +		err("Socket failed: %m");
>  
>  	setmysockopt(sock);
> +
> +	freeaddrinfo(ai);
>  	return sock;
>  }

The rest of the patch looks fine, on first glance.

If you could update it with those comments (I'm not sure I understand
all the intricacies yet), I'll push the patch upstream and do an upload
ASAP.

Thanks,

-- 
The biometric identification system at the gates of the CIA headquarters
works because there's a guard with a large gun making sure no one is
trying to fool the system.
  http://www.schneier.com/blog/archives/2009/01/biometrics.html




Added tag(s) patch. Request was from Wouter Verhelst <wouter@debian.org> to control@bugs.debian.org. (Tue, 16 Mar 2010 12:33:06 GMT) Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Wouter Verhelst <wouter@debian.org>:
Bug#382189; Package nbd-server. (Wed, 17 Mar 2010 21:15:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Neutron Soutmun <neo.neutron@gmail.com>:
Extra info received and forwarded to list. Copy sent to Wouter Verhelst <wouter@debian.org>. (Wed, 17 Mar 2010 21:15:03 GMT) Full text and rfc822 format available.

Message #24 received at 382189@bugs.debian.org (full text, mbox):

From: Neutron Soutmun <neo.neutron@gmail.com>
To: Debian Bug Tracking System <382189@bugs.debian.org>
Subject: Re: IPv6 support
Date: Thu, 18 Mar 2010 04:13:05 +0700
[Message part 1 (text/plain, inline)]
Package: nbd
Version: 2.9.14-3
Severity: normal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Mar 16, 2010 at 01:24:54PM +0100, Wouter Verhelst wrote:
> On Tue, Mar 16, 2010 at 06:36:22PM +0700, Neutron Soutmun wrote:
> I should probably point out that there's a git tree for the upstream
> code: it's on github ("/yoe/nbd"), and on sourceforge
> (nbd.git.sourceforge.net).

$ git clone http://github.com/yoe/nbd.git

now, follow up but keep working continue on the old patch which won't get me
more confusion. 

>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>> 
>> I have provide the initial patch for IPv6 support in
>> nbd-{server, client} which the nbd-server able to
>> serve in both IPv4 and IPv6 requests.
>> 
>> Patch is attached.
>> 
>> The client can connect to the server that listen on
>> IPv6 or IPv4 like this on command line
>> 
>> # nbd-client ::1@11111 /dev/nbd0
>> or
>> # nbd-client 127.0.0.1@11111 /dev/nbd0
>> 
>> Substitute the port separator from ":" to "@".
>
> Indeed, that would be required for proper IPv6 support.
>
> However, I'd like to have some way of backwards compatibility. Since
> IPv6 addresses have at least two colons in them, we could check whether
> there are two or more, and if not, assume that the colon is still the
> separator.
>
> That shouldn't cause too much of a problem.

Update as your advice which now the IPv4 address and port could either have
separator ":" or "@" but the IPv6 is strictly "@".
  
>>  /**
>> + * duplicate server 
>> + * @param s the old server we want to duplicate
>> + **/
>> +SERVER* dup_serve(SERVER *s) {
>> +	SERVER *serve = NULL;
>> +
>> +	serve=g_new0(SERVER, 1);
>> +	if (serve == NULL)
>> +		return NULL;
>> +
>> +	memset(serve,0,sizeof(SERVER));
>
> g_new0 already does this (that's the 0 in the function name)

Fixed. (Now I possible to read more on devhelp, thanks Theppitak)

>> @@ -690,7 +736,17 @@
>>  		if(i>0) {
>>  			if(!s.listenaddr) {
>>  				s.listenaddr = g_strdup("0.0.0.0");
>> +				s.socket_family = AF_UNSPEC;
>> +
>> +			  ns = dup_serve (&s);	
>> +				if (ns) {
>> +					ns->socket_family = AF_INET6;
>> +					g_array_append_val(retval, *ns);
>> +					free(ns);
>> +					ns = NULL;
>> +				}	
>
>What is the reason for that? Doesn't AF_UNSPEC already mean we're
>listening for v6 addresses, too? Or am I missing something?

nbd-server using SERVER that only has a single listening socket which
if I need to handle both IPv4 (AF_INET) and IPv6 (AF_INET6),
I must setup both in separated server (IPv6 could handle the IPv4 connection
but only in the system that allow to do the v4 mapped).

The AF_UNSPEC is only using for the hinting to calling getaddrinfo() which
it may return the addresses (linked-list) of IPv4 and/or IPv6.
We could use these addrinfo data to setup the listening socket and also bind it.

>>  
>> -	if (getpeername(net, (struct sockaddr *) &addrin, (socklen_t *)&addrinlen) < 0)
>> +	if (getpeername(net, (struct sockaddr *)&addrin, (socklen_t *)&addrinlen) < 0)
>
> Please don't do gratuitous whitespace changes; they convolute the patch
> and make it harder to see what's going on.

Sorry, just confuse a litle bit to follow your code-style but I try to keep it
as you want.

>>  /**
>> @@ -1493,23 +1592,53 @@
>>   **/
>>  void setup_serve(SERVER *serve) {
>>  	struct sockaddr_storage addrin;
>> +	struct addrinfo hints;
>> +	struct addrinfo *ai = NULL;
>>  	struct sigaction sa;
>>  	int addrinlen = sizeof(addrin);
>>  	int sock_flags;
>> -	int af;
>>  #ifndef sun
>>  	int yes=1;
>>  #else
>>  	char yes='1';
>>  #endif /* sun */
>> +	gchar *port = NULL;
>> +	int e;
>> +
>> +	memset(&hints,'\0',sizeof(hints));
>> +	hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG | AI_NUMERICSERV;
>> +	hints.ai_socktype = SOCK_STREAM;
>> +
>> +	port = g_strdup_printf ("%d", serve->port);
>> +	if (port == NULL)
>> +		return;
>> +
>> +	if(g_strcmp0(serve->listenaddr, "0.0.0.0") == 0) {
>
> This would mean that if someone were to use 'nbd-server 0.0.0.0:1234' to
> explicitly bind to an IPv4 address, this would not work.
>
> I think the disabling of IPv6 for those who want it, should still be
> possible.

Aha, it must possible to do so.
I fixed it in the new patch and I found that the last time patch only
handle the parsing config file to setup the server(s) but not for the
parsing cmdline which if I parsing like this

# nbd-server 12345 /path/to/file.img

It only bind to AF_INET or AF_INET6 depending on which one return first
but not both.
Therefore, the new patch has added more patching on the code to manipulate the
serve that return from the cmdline() parsing function.

>> +		hints.ai_family = serve->socket_family;
>> +		e = getaddrinfo(NULL,port,&hints,&ai); 
>> +	} else {
>> +		e = getaddrinfo(serve->listenaddr,port,&hints,&ai); 
>> +	}
>> +
>> +	g_free(port);
>> +
>> +	if(e!=0) {
>> +		freeaddrinfo(ai);
>> +		return;
>> +	}
>
> This should probably use the err() function (which logs an error and
> exits) instead.

Fixed. Now it definitely exit with failure status if error here.

>> --- nbd-2.9.14.orig/nbd-client.c
>> +++ nbd-2.9.14/nbd-client.c
>> @@ -11,6 +11,10 @@
>>   * Version 2.1 - Check for disconnection before INIT_PASSWD is received
>>   * 	to make errormsg a bit more helpful in case the server can't
>>   * 	open the exported file.
>> + * 16/03/2010 - Add IPv6 support.
>> + * 	Kitt Tientanopajai <kitt@kitty.in.th>
>> + *	Neutron Soutmun <neo.neutron@gmail.com>
>> + *	Suriya Soutmun <darksolar@gmail.com>
>>   */
>>  
>>  #include "config.h"
>> @@ -21,8 +25,8 @@
>>  #include <sys/types.h>
>>  #include <unistd.h>
>>  #include <netinet/tcp.h>
>> -#include <netinet/in.h>		/* sockaddr_in, htons, in_addr */
>> -#include <netdb.h>		/* hostent, gethostby*, getservby* */
>> +#include <netinet/in.h>
>> +#include <netdb.h>
>>  #include <stdio.h>
>>  #include <fcntl.h>
>>  #include <syslog.h>
>> @@ -67,33 +71,54 @@
>>  
>>  int opennet(char *name, int port, int sdp) {
>>  	int sock;
>> -	struct sockaddr_in xaddrin;
>> -	int xaddrinlen = sizeof(xaddrin);
>> -	struct hostent *hostn;
>> -	int af;
>> -
>> -	hostn = gethostbyname(name);
>> -	if (!hostn)
>> -		err("Gethostname failed: %h\n");
>> +	char portstr[6];
>> +	struct addrinfo hints;
>> +	struct addrinfo *ai = NULL;
>> +	struct addrinfo *rp = NULL;
>> +	int e;
>> +
>> +	snprintf(portstr, sizeof(portstr), "%d", port);
>> +
>> +	memset(&hints,'\0',sizeof(hints));
>> +	hints.ai_family = AF_UNSPEC;
>> +	hints.ai_socktype = SOCK_STREAM;
>> +	hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV;
>> +	hints.ai_protocol = IPPROTO_TCP;
>> +
>> +	e = getaddrinfo(name, portstr, &hints, &ai);
>> +
>> +	if(e != 0) {
>> +		freeaddrinfo(ai);
>> +		return -1;
>> +	}
>
> Again, use err() here.
>

Fixed.


> The rest of the patch looks fine, on first glance.
>
> If you could update it with those comments (I'm not sure I understand
> all the intricacies yet), I'll push the patch upstream and do an upload
> ASAP.

Thanks for your instantly reply, today just go outside for sites seeing.
It's the schedule of Thailand MiniDebCamp 2010 and after come back to the
resident and have a time to review your comments and hands-on the code,
finally I have new patch and please review again.

Regards,
Neutron Soutmun

- -- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=th_TH.UTF-8, LC_CTYPE=th_TH.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkuhRdsACgkQ1k7Ar9TO/Tct1wCcDm1Sxn1Hcn2Gkn0M67zdLfEs
EV4An1XMbBn5unELRTxIlNLeMDvguR8a
=sMEN
-----END PGP SIGNATURE-----
[01_ipv6_support.patch (text/x-diff, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#382189; Package nbd-server. (Wed, 17 Mar 2010 22:06:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Wouter Verhelst <wouter@debian.org>:
Extra info received and forwarded to list. (Wed, 17 Mar 2010 22:06:03 GMT) Full text and rfc822 format available.

Message #29 received at 382189@bugs.debian.org (full text, mbox):

From: Wouter Verhelst <wouter@debian.org>
To: Neutron Soutmun <neo.neutron@gmail.com>, 382189@bugs.debian.org
Subject: Re: Bug#382189: IPv6 support
Date: Wed, 17 Mar 2010 23:04:39 +0100
On Thu, Mar 18, 2010 at 04:13:05AM +0700, Neutron Soutmun wrote:
> Package: nbd
> Version: 2.9.14-3
> Severity: normal
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On Tue, Mar 16, 2010 at 01:24:54PM +0100, Wouter Verhelst wrote:
> > On Tue, Mar 16, 2010 at 06:36:22PM +0700, Neutron Soutmun wrote:
> > I should probably point out that there's a git tree for the upstream
> > code: it's on github ("/yoe/nbd"), and on sourceforge
> > (nbd.git.sourceforge.net).
> 
> $ git clone http://github.com/yoe/nbd.git
> 
> now, follow up but keep working continue on the old patch which won't get me
> more confusion. 

Well, part of the reason I pointed you to that repository is the fact
that there's a patch in there (for #557810) that conflicts with yours.
It'd be cool if you could update it so that it would apply cleanly to
that version, and then I can easily do an upstream release immediately
followed by a Debian package.

> >> -----BEGIN PGP SIGNED MESSAGE-----
> >> Hash: SHA1
> >> 
> >> I have provide the initial patch for IPv6 support in
> >> nbd-{server, client} which the nbd-server able to
> >> serve in both IPv4 and IPv6 requests.
> >> 
> >> Patch is attached.
> >> 
> >> The client can connect to the server that listen on
> >> IPv6 or IPv4 like this on command line
> >> 
> >> # nbd-client ::1@11111 /dev/nbd0
> >> or
> >> # nbd-client 127.0.0.1@11111 /dev/nbd0
> >> 
> >> Substitute the port separator from ":" to "@".
> >
> > Indeed, that would be required for proper IPv6 support.
> >
> > However, I'd like to have some way of backwards compatibility. Since
> > IPv6 addresses have at least two colons in them, we could check whether
> > there are two or more, and if not, assume that the colon is still the
> > separator.
> >
> > That shouldn't cause too much of a problem.
> 
> Update as your advice which now the IPv4 address and port could either have
> separator ":" or "@" but the IPv6 is strictly "@".

Good.

> >>  /**
> >> + * duplicate server 
> >> + * @param s the old server we want to duplicate
> >> + **/
> >> +SERVER* dup_serve(SERVER *s) {
> >> +	SERVER *serve = NULL;
> >> +
> >> +	serve=g_new0(SERVER, 1);
> >> +	if (serve == NULL)
> >> +		return NULL;
> >> +
> >> +	memset(serve,0,sizeof(SERVER));
> >
> > g_new0 already does this (that's the 0 in the function name)
> 
> Fixed. (Now I possible to read more on devhelp, thanks Theppitak)
> 
> >> @@ -690,7 +736,17 @@
> >>  		if(i>0) {
> >>  			if(!s.listenaddr) {
> >>  				s.listenaddr = g_strdup("0.0.0.0");
> >> +				s.socket_family = AF_UNSPEC;
> >> +
> >> +			  ns = dup_serve (&s);	
> >> +				if (ns) {
> >> +					ns->socket_family = AF_INET6;
> >> +					g_array_append_val(retval, *ns);
> >> +					free(ns);
> >> +					ns = NULL;
> >> +				}	
> >
> >What is the reason for that? Doesn't AF_UNSPEC already mean we're
> >listening for v6 addresses, too? Or am I missing something?
> 
> nbd-server using SERVER that only has a single listening socket which
> if I need to handle both IPv4 (AF_INET) and IPv6 (AF_INET6), I must
> setup both in separated server (IPv6 could handle the IPv4 connection
> but only in the system that allow to do the v4 mapped).

Ah, right, I forgot about that bit. Yes, indeed, v6-mapped-v4 is no
longer the default, for some strange reason.

> The AF_UNSPEC is only using for the hinting to calling getaddrinfo()
> which it may return the addresses (linked-list) of IPv4 and/or IPv6.
> We could use these addrinfo data to setup the listening socket and
> also bind it.

Okay.

> >> -	if (getpeername(net, (struct sockaddr *) &addrin, (socklen_t *)&addrinlen) < 0)
> >> +	if (getpeername(net, (struct sockaddr *)&addrin, (socklen_t *)&addrinlen) < 0)
> >
> > Please don't do gratuitous whitespace changes; they convolute the patch
> > and make it harder to see what's going on.
> 
> Sorry, just confuse a litle bit to follow your code-style but I try to keep it
> as you want.

Indeed. Code style cleanups are certainly welcome, but it's preferable
if they're separate from functional patches.

[...]
> > This would mean that if someone were to use 'nbd-server 0.0.0.0:1234' to
> > explicitly bind to an IPv4 address, this would not work.
> >
> > I think the disabling of IPv6 for those who want it, should still be
> > possible.
> 
> Aha, it must possible to do so.
> I fixed it in the new patch and I found that the last time patch only
> handle the parsing config file to setup the server(s) but not for the
> parsing cmdline which if I parsing like this
> 
> # nbd-server 12345 /path/to/file.img
> 
> It only bind to AF_INET or AF_INET6 depending on which one return first
> but not both.

Right, that's not good :)

> Therefore, the new patch has added more patching on the code to
> manipulate the serve that return from the cmdline() parsing function.

Great.

[...]
> > The rest of the patch looks fine, on first glance.
> >
> > If you could update it with those comments (I'm not sure I understand
> > all the intricacies yet), I'll push the patch upstream and do an upload
> > ASAP.
> 
> Thanks for your instantly reply, today just go outside for sites seeing.
> It's the schedule of Thailand MiniDebCamp 2010 and after come back to the
> resident and have a time to review your comments and hands-on the code,
> finally I have new patch and please review again.
[...]

No further comments on that one. If you can update to the 'master'
branch in git, and my tests reveal that it works properly, I'll do an
upstream release and Debian upload ASAP.

Thanks!

-- 
The biometric identification system at the gates of the CIA headquarters
works because there's a guard with a large gun making sure no one is
trying to fool the system.
  http://www.schneier.com/blog/archives/2009/01/biometrics.html




Severity set to 'serious' from 'important' Request was from Clint Adams <schizo@debian.org> to control@bugs.debian.org. (Tue, 23 Mar 2010 01:03:02 GMT) Full text and rfc822 format available.

Added tag(s) sid and squeeze. Request was from Gerfried Fuchs <rhonda@debian.at> to control@bugs.debian.org. (Tue, 23 Mar 2010 07:51:47 GMT) Full text and rfc822 format available.

Severity set to 'important' from 'serious' Request was from Gerfried Fuchs <rhonda@deb.at> to control@bugs.debian.org. (Tue, 23 Mar 2010 08:30:05 GMT) Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Wouter Verhelst <wouter@debian.org>:
Bug#382189; Package nbd-server. (Tue, 23 Mar 2010 09:39:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Wouter Verhelst <w@uter.be>:
Extra info received and forwarded to list. Copy sent to Wouter Verhelst <wouter@debian.org>. (Tue, 23 Mar 2010 09:39:05 GMT) Full text and rfc822 format available.

Message #40 received at 382189@bugs.debian.org (full text, mbox):

From: Wouter Verhelst <w@uter.be>
To: Neutron Soutmun <neo.neutron@gmail.com>, 382189@bugs.debian.org
Subject: Re: Bug#382189: IPv6 support
Date: Tue, 23 Mar 2010 10:35:49 +0100
Hi,

On Wed, Mar 17, 2010 at 11:04:39PM +0100, Wouter Verhelst wrote:
> On Thu, Mar 18, 2010 at 04:13:05AM +0700, Neutron Soutmun wrote:
> > Package: nbd
> > Version: 2.9.14-3
> > Severity: normal
> > 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > On Tue, Mar 16, 2010 at 01:24:54PM +0100, Wouter Verhelst wrote:
> > > On Tue, Mar 16, 2010 at 06:36:22PM +0700, Neutron Soutmun wrote:
> > > I should probably point out that there's a git tree for the upstream
> > > code: it's on github ("/yoe/nbd"), and on sourceforge
> > > (nbd.git.sourceforge.net).
> > 
> > $ git clone http://github.com/yoe/nbd.git
> > 
> > now, follow up but keep working continue on the old patch which won't get me
> > more confusion. 
> 
> Well, part of the reason I pointed you to that repository is the fact
> that there's a patch in there (for #557810) that conflicts with yours.
> It'd be cool if you could update it so that it would apply cleanly to
> that version, and then I can easily do an upstream release immediately
> followed by a Debian package.

Are you working on that? If not, that's not a problem, I'll do it
myself; it's just that it'd probably be easier for you at this point.

But if you don't have the time, or are tired of it, or are working on
something else, I'll finish this off.

-- 
The biometric identification system at the gates of the CIA headquarters
works because there's a guard with a large gun making sure no one is
trying to fool the system.
  http://www.schneier.com/blog/archives/2009/01/biometrics.html




Information forwarded to debian-bugs-dist@lists.debian.org, Wouter Verhelst <wouter@debian.org>:
Bug#382189; Package nbd-server. (Tue, 23 Mar 2010 10:18:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Neutron Soutmun <neo.neutron@gmail.com>:
Extra info received and forwarded to list. Copy sent to Wouter Verhelst <wouter@debian.org>. (Tue, 23 Mar 2010 10:18:03 GMT) Full text and rfc822 format available.

Message #45 received at 382189@bugs.debian.org (full text, mbox):

From: Neutron Soutmun <neo.neutron@gmail.com>
To: Wouter Verhelst <w@uter.be>
Cc: 382189@bugs.debian.org
Subject: Re: Bug#382189: IPv6 support
Date: Tue, 23 Mar 2010 17:16:07 +0700
On Tue, Mar 23, 2010 at 4:35 PM, Wouter Verhelst <w@uter.be> wrote:
> Hi,
>
> On Wed, Mar 17, 2010 at 11:04:39PM +0100, Wouter Verhelst wrote:
>> On Thu, Mar 18, 2010 at 04:13:05AM +0700, Neutron Soutmun wrote:
>> > Package: nbd
>> > Version: 2.9.14-3
>> > Severity: normal
>> >
>> > -----BEGIN PGP SIGNED MESSAGE-----
>> > Hash: SHA1
>> >
>> > On Tue, Mar 16, 2010 at 01:24:54PM +0100, Wouter Verhelst wrote:
>> > > On Tue, Mar 16, 2010 at 06:36:22PM +0700, Neutron Soutmun wrote:
>> > > I should probably point out that there's a git tree for the upstream
>> > > code: it's on github ("/yoe/nbd"), and on sourceforge
>> > > (nbd.git.sourceforge.net).
>> >
>> > $ git clone http://github.com/yoe/nbd.git
>> >
>> > now, follow up but keep working continue on the old patch which won't get me
>> > more confusion.
>>
>> Well, part of the reason I pointed you to that repository is the fact
>> that there's a patch in there (for #557810) that conflicts with yours.
>> It'd be cool if you could update it so that it would apply cleanly to
>> that version, and then I can easily do an upstream release immediately
>> followed by a Debian package.
>
> Are you working on that? If not, that's not a problem, I'll do it
> myself; it's just that it'd probably be easier for you at this point.
> But if you don't have the time, or are tired of it, or are working on
> something else, I'll finish this off.

Sorry for late response, I have something else to do, but I still thinking
of the solution for #557810 which the user parsing the hostname for
listening address that case for example

# nbd-server localhost:12345 `pwd`/nbd-file 1G -C /dev/null

which localhost may resolve in both IPv4 (127.0.0.1) and IPv6 (::1)
Therefore, I think that if I'm using getaddrinfo() to get each information
and add to server listening pool only if it valid, it's better, isn't it ?

Or localhost:12345 is only mean 127.0.0.1 port 12345 ?
If it is this case, when parsing this command line should set the
socket family to AF_INET.

If now this case is ignored, I think I can prepare the patch for you which
diff from git repository that I reviewed already that the patch does
not conflict much.
I test that hostname parsing is OK but only the first info that
getaddrinfo() return could
setup for listening.

Regards,
Neutron Soutmun




Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#382189; Package nbd-server. (Tue, 23 Mar 2010 10:30:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Wouter Verhelst <wouter@debian.org>:
Extra info received and forwarded to list. (Tue, 23 Mar 2010 10:30:06 GMT) Full text and rfc822 format available.

Message #50 received at 382189@bugs.debian.org (full text, mbox):

From: Wouter Verhelst <wouter@debian.org>
To: Neutron Soutmun <neo.neutron@gmail.com>, 382189@bugs.debian.org
Subject: Re: Bug#382189: IPv6 support
Date: Tue, 23 Mar 2010 11:28:41 +0100
On Tue, Mar 23, 2010 at 05:16:07PM +0700, Neutron Soutmun wrote:
> Sorry for late response, I have something else to do,

No problem; I've been in that situation myself, too.

> but I still thinking of the solution for #557810 which the user
> parsing the hostname for listening address that case for example

Great.

> # nbd-server localhost:12345 `pwd`/nbd-file 1G -C /dev/null
> 
> which localhost may resolve in both IPv4 (127.0.0.1) and IPv6 (::1)
> Therefore, I think that if I'm using getaddrinfo() to get each information
> and add to server listening pool only if it valid, it's better, isn't it ?

Yes.

> Or localhost:12345 is only mean 127.0.0.1 port 12345 ?

I would refrain from making any special case regarding any hostname.
When the user specifies a hostname on the command line, you should
perform a lookup of that hostname and listen on the addresses returned.
If the hostname does not resolve to any address we have assigned
locally, then we will be listening to an address that can never result
in traffic; that would not be a bug in nbd-server.

So 'localhost:12345' would mean 'whatever localhost resolves to, on port
12345'. If the user makes 'localhost' resolve to '192.168.1.1', then
we'd be listening on 192.168.1.1; if the user makes 'localhost' resolve
to '::1', then we'd be listening to [::1]:12345. If it returns both
'127.0.0.1' and '::1', then we should probably listen on both, I guess.

> If it is this case, when parsing this command line should set the
> socket family to AF_INET.

Mm. Having a command line option to force either IPv6 or IPv4 could be a
good idea, but it's not critical.

> If now this case is ignored, I think I can prepare the patch for you which
> diff from git repository that I reviewed already that the patch does
> not conflict much.

Great.

Thanks for your continued work on this; it really is appreciated.

-- 
The biometric identification system at the gates of the CIA headquarters
works because there's a guard with a large gun making sure no one is
trying to fool the system.
  http://www.schneier.com/blog/archives/2009/01/biometrics.html




Information forwarded to debian-bugs-dist@lists.debian.org, Wouter Verhelst <wouter@debian.org>:
Bug#382189; Package nbd-server. (Wed, 24 Mar 2010 05:27:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Neutron Soutmun <neo.neutron@gmail.com>:
Extra info received and forwarded to list. Copy sent to Wouter Verhelst <wouter@debian.org>. (Wed, 24 Mar 2010 05:27:03 GMT) Full text and rfc822 format available.

Message #55 received at 382189@bugs.debian.org (full text, mbox):

From: Neutron Soutmun <neo.neutron@gmail.com>
To: Debian Bug Tracking System <382189@bugs.debian.org>
Subject: Re: IPv6 support
Date: Wed, 24 Mar 2010 12:25:59 +0700
[Message part 1 (text/plain, inline)]
Package: nbd
Version: 2.9.14-3
Severity: normal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The latest patch to master branch of git repository is attached.
Please review the patch again.

It's also solved the #557810.

Add append_serve() more over the last patch to verify the parsing
listening address which now the parsing listening address could
be IPv4/IPv6 and also hostname. The service will resolve the hostname
and try to listening on all of them.

If the hostname/address could not solve, must show the error

# nbd-server testing:12345 /home/neutron/temp/test.img -C /dev/null
getaddrinfo failed on listen host/address: testing (Name or service not known)

If parsing hostname,

# nbd-server localhost:12345 /home/neutron/temp/test.img -C /dev/null
It will listen on 127.0.0.1:12345

# nbd-server ip6-localhost:12345 /home/neutron/temp/test.img -C /dev/null
It will listen on ::1@12345

Regards,
Neutron Soutmun

- -- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=th_TH.UTF-8, LC_CTYPE=th_TH.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkupomIACgkQ1k7Ar9TO/TdLngCgvGp2oGKR0PLGmMFVTUkxh9yO
NrQAnR4FqtwoEuo/aZoEFhdhFI3mOVbU
=1UBe
-----END PGP SIGNATURE-----
[ipv6.patch (text/x-diff, attachment)]

Reply sent to Wouter Verhelst <wouter@debian.org>:
You have taken responsibility. (Wed, 24 Mar 2010 21:51:13 GMT) Full text and rfc822 format available.

Notification sent to Wouter Verhelst <wouter@debian.org>:
Bug acknowledged by developer. (Wed, 24 Mar 2010 21:51:14 GMT) Full text and rfc822 format available.

Message #60 received at 382189-close@bugs.debian.org (full text, mbox):

From: Wouter Verhelst <wouter@debian.org>
To: 382189-close@bugs.debian.org
Subject: Bug#382189: fixed in nbd 1:2.9.15-1
Date: Wed, 24 Mar 2010 21:45:08 +0000
Source: nbd
Source-Version: 1:2.9.15-1

We believe that the bug you reported is fixed in the latest version of
nbd, which is due to be installed in the Debian FTP archive:

nbd-client-udeb_2.9.15-1_amd64.udeb
  to main/n/nbd/nbd-client-udeb_2.9.15-1_amd64.udeb
nbd-client_2.9.15-1_amd64.deb
  to main/n/nbd/nbd-client_2.9.15-1_amd64.deb
nbd-server_2.9.15-1_amd64.deb
  to main/n/nbd/nbd-server_2.9.15-1_amd64.deb
nbd_2.9.15-1.diff.gz
  to main/n/nbd/nbd_2.9.15-1.diff.gz
nbd_2.9.15-1.dsc
  to main/n/nbd/nbd_2.9.15-1.dsc
nbd_2.9.15.orig.tar.gz
  to main/n/nbd/nbd_2.9.15.orig.tar.gz



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 382189@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Wouter Verhelst <wouter@debian.org> (supplier of updated nbd package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.8
Date: Wed, 24 Mar 2010 22:06:16 +0100
Source: nbd
Binary: nbd-server nbd-client nbd-client-udeb
Architecture: source amd64
Version: 1:2.9.15-1
Distribution: unstable
Urgency: low
Maintainer: Wouter Verhelst <wouter@debian.org>
Changed-By: Wouter Verhelst <wouter@debian.org>
Description: 
 nbd-client - Network Block Device protocol - client
 nbd-client-udeb - Network Block Device protocol - client for Debian Installer (udeb)
 nbd-server - Network Block Device protocol - server
Closes: 382189 557810 571768
Changes: 
 nbd (1:2.9.15-1) unstable; urgency=low
 .
   * New upstream release
     - Adds IPv6 support; Closes: #382189. Thanks to Neutron Soutmun for
       the patch.
     - Allows for using hostnames as the listen address; Closes: #557810.
     - nbd-server is now a bit more explicit when it exits. Closes: #571768.
Checksums-Sha1: 
 72e4674f0da9a832e270ea37d64c08624917f397 1133 nbd_2.9.15-1.dsc
 7542a8330d400e26996e9a6015307036f0c83653 183635 nbd_2.9.15.orig.tar.gz
 676f36b41e59be9e37941673f073da934390bc88 68195 nbd_2.9.15-1.diff.gz
 08d17f9d4e708386931e51ec91b14bd2b57bd9c6 57460 nbd-server_2.9.15-1_amd64.deb
 6fff85e89809ebc2c629668ccb6c42d943878687 46474 nbd-client_2.9.15-1_amd64.deb
 c668c5df69bb5a9315bdb65391688fa7b98581aa 6586 nbd-client-udeb_2.9.15-1_amd64.udeb
Checksums-Sha256: 
 a9b7554be5d83f79b2bea647928e9a2462450618ddc9d32dc6d5bc353427ddbb 1133 nbd_2.9.15-1.dsc
 67dee762f87f3de0aa1b94325329123273570509a88314c904f259e93133d4fe 183635 nbd_2.9.15.orig.tar.gz
 b3502047d8777897b4661446d888e07afdcc3f1e4ee3d7f676ed7587de4b1b89 68195 nbd_2.9.15-1.diff.gz
 19ccf18ca5e31ee7caa91c7bc14c49d260a6aaec379b88d4d55a61024b3a5a44 57460 nbd-server_2.9.15-1_amd64.deb
 1323e0ad57cd582ac6a79db6bd8678826ef49fdbf64dbca60b329e4071986355 46474 nbd-client_2.9.15-1_amd64.deb
 cbeced5baf2f5a84c1fc8ac6a82ea998ab817f80a7a28b7962e01b24123ac7f4 6586 nbd-client-udeb_2.9.15-1_amd64.udeb
Files: 
 d59dca648e9c6ae9c2e417fdb7d1ad86 1133 admin optional nbd_2.9.15-1.dsc
 86545fee9fde3907d3e8cde428238825 183635 admin optional nbd_2.9.15.orig.tar.gz
 745c6a8e054e081119a30aab845273a8 68195 admin optional nbd_2.9.15-1.diff.gz
 550dfdd6221801eb3161775d5832cac7 57460 admin optional nbd-server_2.9.15-1_amd64.deb
 0a374f799f416b2c6aea6a1a20b31485 46474 admin optional nbd-client_2.9.15-1_amd64.deb
 b3dba2b2afee52dd89166fc151b024e5 6586 debian-installer optional nbd-client-udeb_2.9.15-1_amd64.udeb
Package-Type: udeb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkuqg7UACgkQhbxvHru886y20gCeJ+qut7GTP2ptqN6WTNziUyjL
JikAn3rrOPhLFzELlf0NksNsPAYNViZo
=ELIK
-----END PGP SIGNATURE-----





Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Wed, 07 Sep 2011 07:39:52 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Mon Apr 21 16:31:14 2014; Machine Name: beach.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.