Subject: Re: linux emul & net config
To: Christos Zoulas <christos@zoulas.com>
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
List: tech-net
Date: 11/29/2002 10:21:24
>Val needs to point to a userland buffer. Like:
tnx. how about this?
itojun
Index: linux_socket.c
===================================================================
RCS file: /cvsroot/syssrc/sys/compat/linux/common/linux_socket.c,v
retrieving revision 1.40
diff -u -r1.40 linux_socket.c
--- linux_socket.c 2002/11/28 23:46:15 1.40
+++ linux_socket.c 2002/11/29 01:20:45
@@ -215,13 +215,44 @@
syscallarg(int) protocol;
} */ *uap = v;
struct sys_socket_args bsa;
+ int s;
SCARG(&bsa, protocol) = SCARG(uap, protocol);
SCARG(&bsa, type) = SCARG(uap, type);
SCARG(&bsa, domain) = linux_to_bsd_domain(SCARG(uap, domain));
if (SCARG(&bsa, domain) == -1)
return EINVAL;
- return sys_socket(p, &bsa, retval);
+ s = sys_socket(p, &bsa, retval);
+
+#ifdef INET6
+ /*
+ * Linux AF_INET6 socket has IPV6_V6ONLY setsockopt set to 0 by default.
+ * XXX interaction with native sysctl net.inet6.ip6.v6only?
+ */
+ if (SCARG(&bsa, domain) == PF_INET6) {
+ struct sys_setsockopt_args bsoa;
+ struct sys_close_args bca;
+ caddr_t sg;
+ const int off = 0;
+
+ SCARG(&bsoa, s) = s;
+ SCARG(&bsoa, level) = IPPROTO_IPV6;
+ SCARG(&bsoa, name) = IPV6_V6ONLY;
+ sg = stackgap_init(p, 0);
+ SCARG(&bsoa, val) = stackgap_alloc(p, &sg, sizeof(off));
+ SCARG(&bsoa, valsize) = sizeof(off);
+ /* LINTED const cast */
+ if (copyout(&off, (void *)SCARG(&bsoa, val), sizeof(off)) ||
+ sys_setsockopt(p, &bsoa, retval)) {
+ SCARG(&bca, fd) = s;
+ sys_close(p, &bca, retval);
+ *retval = -1;
+ return (EINVAL); /*XXX*/
+ }
+ }
+#endif
+
+ return s;
}
int