Date: Sun, 22 May 2016 19:08:29 +0000 (UTC) From: Dmitry Chagin <dchagin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300431 - head/sys/compat/linux Message-ID: <201605221908.u4MJ8Ti7092560@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dchagin Date: Sun May 22 19:08:29 2016 New Revision: 300431 URL: https://svnweb.freebsd.org/changeset/base/300431 Log: Convert proto family in both directions. The linux and native values for local and inet are identical, but for inet6 values differ. PR: 155040 Reported by: Simon Walton MFC after: 2 week Modified: head/sys/compat/linux/linux_socket.c Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Sun May 22 19:06:38 2016 (r300430) +++ head/sys/compat/linux/linux_socket.c Sun May 22 19:08:29 2016 (r300431) @@ -462,12 +462,16 @@ bsd_to_linux_sockaddr(struct sockaddr *a { struct sockaddr sa; size_t sa_len = sizeof(struct sockaddr); - int error; + int error, bdom; if ((error = copyin(arg, &sa, sa_len))) return (error); - *(u_short *)&sa = sa.sa_family; + bdom = bsd_to_linux_domain(sa.sa_family); + if (bdom == -1) + return (EAFNOSUPPORT); + + *(u_short *)&sa = bdom; return (copyout(&sa, arg, sa_len)); } @@ -476,12 +480,16 @@ linux_to_bsd_sockaddr(struct sockaddr *a { struct sockaddr sa; size_t sa_len = sizeof(struct sockaddr); - int error; + int error, bdom; if ((error = copyin(arg, &sa, sa_len))) return (error); - sa.sa_family = *(sa_family_t *)&sa; + bdom = linux_to_bsd_domain(*(sa_family_t *)&sa); + if (bdom == -1) + return (EAFNOSUPPORT); + + sa.sa_family = bdom; sa.sa_len = len; return (copyout(&sa, arg, sa_len)); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605221908.u4MJ8Ti7092560>