Package: webfs / 1.21+ds1-12

55_sockopt_v6only.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Description: Predictably set socket option IPV6_V6ONLY.
 The default mode of operation for Webfs was intended to
 listen on both IPv4 and IPv6. To be certain this always
 can be done, the patch assigns the socket option a value
 IPV6_V6ONLY=0, thus overriding any system default that
 might be in effect.
 .
 Conversely, had '-6' been specified, then make sure that
 IPV6_V6ONLY=1 is used.
Author: Mats Erik Andersson <debian@gisladisker.se>
Forwarded: no
Last-Update: 2010-02-14
--- webfs-1.21+ds1/webfsd.c.debian
+++ webfs-1.21+ds1/webfsd.c
@@ -840,6 +840,20 @@ main(int argc, char *argv[])
 	    if (-1 == (slisten = socket(res->ai_family, res->ai_socktype,
 					res->ai_protocol)) && debug)
 		xperror(LOG_ERR,"socket (ipv6)",NULL);
+	    else {
+		/* Should the listener be dual-stacked? */
+		if ( v4 ) {
+		    /* Yes */
+		    int null = 0;
+		    setsockopt(slisten, IPPROTO_IPV6, IPV6_V6ONLY,
+				    &null, sizeof(null));
+		} else {
+		    /* No */
+		    int one = 1;
+		    setsockopt(slisten, IPPROTO_IPV6, IPV6_V6ONLY,
+				    &one, sizeof(one));
+		}
+	    }
 	}
     }