Module Name: src
Committed By: njoly
Date: Mon Jan 27 19:19:15 UTC 2014
Modified Files:
src/sys/compat/linux/common: linux_socket.c linux_socket.h
Log Message:
Add basic IPV6 level socket options support (IPV6_V6ONLY).
To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.21 -r1.22 src/sys/compat/linux/common/linux_socket.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.116 src/sys/compat/linux/common/linux_socket.c:1.117
--- src/sys/compat/linux/common/linux_socket.c:1.116 Mon Jan 27 13:23:33 2014
+++ src/sys/compat/linux/common/linux_socket.c Mon Jan 27 19:19:15 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_socket.c,v 1.116 2014/01/27 13:23:33 njoly Exp $ */
+/* $NetBSD: linux_socket.c,v 1.117 2014/01/27 19:19:15 njoly Exp $ */
/*-
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.116 2014/01/27 13:23:33 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.117 2014/01/27 19:19:15 njoly Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -114,6 +114,7 @@ static int bsd_to_linux_domain(int);
int linux_to_bsd_sopt_level(int);
int linux_to_bsd_so_sockopt(int);
int linux_to_bsd_ip_sockopt(int);
+int linux_to_bsd_ipv6_sockopt(int);
int linux_to_bsd_tcp_sockopt(int);
int linux_to_bsd_udp_sockopt(int);
int linux_getifname(struct lwp *, register_t *, void *);
@@ -833,6 +834,10 @@ linux_to_bsd_sopt_level(int llevel)
return SOL_SOCKET;
case LINUX_SOL_IP:
return IPPROTO_IP;
+#ifdef INET6
+ case LINUX_SOL_IPV6:
+ return IPPROTO_IPV6;
+#endif
case LINUX_SOL_TCP:
return IPPROTO_TCP;
case LINUX_SOL_UDP:
@@ -922,6 +927,23 @@ linux_to_bsd_ip_sockopt(int lopt)
}
/*
+ * Convert Linux IPV6 level socket option number to NetBSD values.
+ */
+#ifdef INET6
+int
+linux_to_bsd_ipv6_sockopt(int lopt)
+{
+
+ switch (lopt) {
+ case LINUX_IPV6_V6ONLY:
+ return IPV6_V6ONLY;
+ default:
+ return -1;
+ }
+}
+#endif
+
+/*
* Convert Linux TCP level socket option number to NetBSD values.
*/
int
@@ -1000,6 +1022,11 @@ linux_sys_setsockopt(struct lwp *l, cons
case IPPROTO_IP:
name = linux_to_bsd_ip_sockopt(SCARG(uap, optname));
break;
+#ifdef INET6
+ case IPPROTO_IPV6:
+ name = linux_to_bsd_ipv6_sockopt(SCARG(uap, optname));
+ break;
+#endif
case IPPROTO_TCP:
name = linux_to_bsd_tcp_sockopt(SCARG(uap, optname));
break;
@@ -1045,6 +1072,11 @@ linux_sys_getsockopt(struct lwp *l, cons
case IPPROTO_IP:
name = linux_to_bsd_ip_sockopt(SCARG(uap, optname));
break;
+#ifdef INET6
+ case IPPROTO_IPV6:
+ name = linux_to_bsd_ipv6_sockopt(SCARG(uap, optname));
+ break;
+#endif
case IPPROTO_TCP:
name = linux_to_bsd_tcp_sockopt(SCARG(uap, optname));
break;
Index: src/sys/compat/linux/common/linux_socket.h
diff -u src/sys/compat/linux/common/linux_socket.h:1.21 src/sys/compat/linux/common/linux_socket.h:1.22
--- src/sys/compat/linux/common/linux_socket.h:1.21 Thu Jun 30 20:09:39 2011
+++ src/sys/compat/linux/common/linux_socket.h Mon Jan 27 19:19:15 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_socket.h,v 1.21 2011/06/30 20:09:39 wiz Exp $ */
+/* $NetBSD: linux_socket.h,v 1.22 2014/01/27 19:19:15 njoly Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -78,8 +78,8 @@
#define LINUX_SOL_IP 0
#define LINUX_SOL_TCP 6
#define LINUX_SOL_UDP 17
-/* Unused for now: */
#define LINUX_SOL_IPV6 41
+/* Unused for now: */
#define LINUX_SOL_ICMPV6 58
#define LINUX_SOL_RAW 255
#define LINUX_SOL_IPX 256
@@ -111,6 +111,12 @@
#define LINUX_IP_DROP_MEMBERSHIP 36
/*
+ * Options for [gs]etsockopt(2), IPV6 level.
+ */
+
+#define LINUX_IPV6_V6ONLY 26
+
+/*
* Options for [gs]etsockopt(2), TCP level.
*/