[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: rsync ipv6 patch merge?



Martin,

> rsync 2.4.7pre4 now includes IPv6 support based on the KAME.net patch,
> plus code from other groups including ISC, OpenBSD and the OpenSSH
> portability team.  Thankyou to everybody who has helped with this.

client_addr(), client_name() always fails for IPv6 connection sice in
most of system,
   sizeof(struct sockaddr_in) < sizeof(struct sockaddr) < sizeof(struct sockaddr_in6)

you should use sockaddr_storage for getpeername(). here is the patch.

this patch does not contains compatible declaration and detecting by
configure for the system which does not have struct sockaddr_storage.

I'll prepare the patch if necessary.

---
Munechika SUMIKAWA @ KAME Project

Index: socket.c
===================================================================
RCS file: /cvsroot/apps/rsync/socket.c,v
retrieving revision 1.1.1.4
retrieving revision 1.15
diff -u -r1.1.1.4 -r1.15
--- socket.c	2001/11/28 20:07:38	1.1.1.4
+++ socket.c	2001/12/03 06:02:32	1.15
@@ -372,7 +379,7 @@
 	while (1) {
 		fd_set fds;
 		int fd;
-		struct sockaddr addr;
+		struct sockaddr_storage addr;
 		int in_addrlen = sizeof(addr);
 
 		/* close log file before the potentially very long select so
@@ -555,7 +562,7 @@
  **/
 char *client_addr(int fd)
 {
-	struct sockaddr ss;
+	struct sockaddr_storage ss;
 	int     length = sizeof(ss);
 	static char addr_buf[100];
 	static int initialised;
@@ -564,11 +571,10 @@
 
 	initialised = 1;
 
-	if (getpeername(fd, &ss, &length)) {
+	if (getpeername(fd, (struct sockaddr *)&ss, &length)) {
 		exit_cleanup(RERR_SOCKETIO);
 	}
-
-	getnameinfo(&ss, length,
+	getnameinfo((struct sockaddr *)&ss, length,
 		addr_buf, sizeof(addr_buf), NULL, 0, NI_NUMERICHOST);
 	return addr_buf;
 }
@@ -579,7 +585,7 @@
  **/
 char *client_name(int fd)
 {
-	struct sockaddr ss;
+	struct sockaddr_storage ss;
 	int     length = sizeof(ss);
 	static char name_buf[100];
 	static char port_buf[100];
@@ -602,7 +608,7 @@
 	}
 
 #ifdef INET6
-        if (ss.sa_family == AF_INET6 && 
+        if (ss.ss_family == AF_INET6 && 
 	    IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&ss)->sin6_addr)) {
 		struct sockaddr_in6 sin6;
 		struct sockaddr_in *sin;
@@ -646,7 +652,7 @@
 
 	/* XXX sin6_flowinfo and other fields */
 	for (res = res0; res; res = res->ai_next) {
-		if (res->ai_family != ss.sa_family)
+		if (res->ai_family != ss.ss_family)
 			continue;
 		if (res->ai_addrlen != length)
 			continue;



Reply to: