lists.arthurdejong.org
RSS feed

cvsd commit: MODIFIED: . ...

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

cvsd commit: MODIFIED: . ...



User: arthur
Date: 10/08/29 15:27:01

Modified:    . cvsd.c
Log:
use IPV6_V6ONLY on IPv6 sockets to ensure that they only handle IPv6 traffic


Revision  Changes    Path
1.120     +12 -0     cvsd/cvsd.c

Index: cvsd.c
===================================================================
RCS file: /home/arthur/devel/repos/cvsd/cvsd.c,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -b -r1.119 -r1.120
--- cvsd.c      26 Aug 2010 18:59:41 -0000      1.119
+++ cvsd.c      29 Aug 2010 13:27:01 -0000      1.120
@@ -425,6 +425,18 @@
       exit(1);
     }
 
+    /* force IPv6 sockets to not handle IPv4 traffic */
+#ifdef IPV6_V6ONLY
+    flag=1;
+    if 
((addr->ai_family==AF_INET6)&&(setsockopt(sock,IPPROTO_IPV6,IPV6_V6ONLY,&flag,sizeof(int))!=0))
+    {
+      log_log(LOG_ERR,"setsockopt(IPV6_V6ONLY) failed: %s",strerror(errno));
+      if (close(sock))
+        log_log(LOG_WARNING,"problem closing socket: %s",strerror(errno));
+      exit(1);
+    }
+#endif /* IPV6_V6ONLY */
+
 #ifdef TODO
     /* close the socket fast (SO_LINGER) */
     struct linger {


--
To unsubscribe send an email to
cvsd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/cvsd-commits