| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: linux_socket.c,v 1.151 2020/10/24 09:01:56 mgorny Exp $ */ | | 1 | /* $NetBSD: linux_socket.c,v 1.152 2020/11/03 22:08:44 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Frank van der Linden and Eric Haszlakiewicz. | | 8 | * by Frank van der Linden and Eric Haszlakiewicz. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -25,27 +25,27 @@ | | | @@ -25,27 +25,27 @@ |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * Functions in multiarch: | | 33 | * Functions in multiarch: |
34 | * linux_sys_socketcall : linux_socketcall.c | | 34 | * linux_sys_socketcall : linux_socketcall.c |
35 | */ | | 35 | */ |
36 | | | 36 | |
37 | #include <sys/cdefs.h> | | 37 | #include <sys/cdefs.h> |
38 | __KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.151 2020/10/24 09:01:56 mgorny Exp $"); | | 38 | __KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.152 2020/11/03 22:08:44 christos Exp $"); |
39 | | | 39 | |
40 | #if defined(_KERNEL_OPT) | | 40 | #if defined(_KERNEL_OPT) |
41 | #include "opt_inet.h" | | 41 | #include "opt_inet.h" |
42 | #endif /* defined(_KERNEL_OPT) */ | | 42 | #endif /* defined(_KERNEL_OPT) */ |
43 | | | 43 | |
44 | #include <sys/param.h> | | 44 | #include <sys/param.h> |
45 | #include <sys/kernel.h> | | 45 | #include <sys/kernel.h> |
46 | #include <sys/systm.h> | | 46 | #include <sys/systm.h> |
47 | #include <sys/buf.h> | | 47 | #include <sys/buf.h> |
48 | #include <sys/ioctl.h> | | 48 | #include <sys/ioctl.h> |
49 | #include <sys/tty.h> | | 49 | #include <sys/tty.h> |
50 | #include <sys/file.h> | | 50 | #include <sys/file.h> |
51 | #include <sys/filedesc.h> | | 51 | #include <sys/filedesc.h> |
| @@ -851,59 +851,90 @@ linux_to_bsd_sopt_level(int llevel) | | | @@ -851,59 +851,90 @@ linux_to_bsd_sopt_level(int llevel) |
851 | | | 851 | |
852 | /* | | 852 | /* |
853 | * Convert Linux socket level socket option numbers to NetBSD values. | | 853 | * Convert Linux socket level socket option numbers to NetBSD values. |
854 | */ | | 854 | */ |
855 | int | | 855 | int |
856 | linux_to_bsd_so_sockopt(int lopt) | | 856 | linux_to_bsd_so_sockopt(int lopt) |
857 | { | | 857 | { |
858 | | | 858 | |
859 | switch (lopt) { | | 859 | switch (lopt) { |
860 | case LINUX_SO_DEBUG: | | 860 | case LINUX_SO_DEBUG: |
861 | return SO_DEBUG; | | 861 | return SO_DEBUG; |
862 | case LINUX_SO_REUSEADDR: | | 862 | case LINUX_SO_REUSEADDR: |
863 | /* | | 863 | /* |
864 | * Linux does not implement SO_REUSEPORT, but allows reuse of a | | 864 | * Linux does not implement SO_REUSEPORT, but allows reuse of |
865 | * host:port pair through SO_REUSEADDR even if the address is not a | | 865 | * a host:port pair through SO_REUSEADDR even if the address |
866 | * multicast-address. Effectively, this means that we should use | | 866 | * is not a multicast-address. Effectively, this means that we |
867 | * SO_REUSEPORT to allow Linux applications to not exit with | | 867 | * should use SO_REUSEPORT to allow Linux applications to not |
868 | * EADDRINUSE | | 868 | * exit with EADDRINUSE |
869 | */ | | 869 | */ |
870 | return SO_REUSEPORT; | | 870 | return SO_REUSEPORT; |
871 | case LINUX_SO_TYPE: | | 871 | case LINUX_SO_TYPE: |
872 | return SO_TYPE; | | 872 | return SO_TYPE; |
873 | case LINUX_SO_ERROR: | | 873 | case LINUX_SO_ERROR: |
874 | return SO_ERROR; | | 874 | return SO_ERROR; |
875 | case LINUX_SO_DONTROUTE: | | 875 | case LINUX_SO_DONTROUTE: |
876 | return SO_DONTROUTE; | | 876 | return SO_DONTROUTE; |
877 | case LINUX_SO_BROADCAST: | | 877 | case LINUX_SO_BROADCAST: |
878 | return SO_BROADCAST; | | 878 | return SO_BROADCAST; |
879 | case LINUX_SO_SNDBUF: | | 879 | case LINUX_SO_SNDBUF: |
880 | return SO_SNDBUF; | | 880 | return SO_SNDBUF; |
881 | case LINUX_SO_RCVBUF: | | 881 | case LINUX_SO_RCVBUF: |
882 | return SO_RCVBUF; | | 882 | return SO_RCVBUF; |
883 | case LINUX_SO_SNDLOWAT: | | | |
884 | return SO_SNDLOWAT; | | | |
885 | case LINUX_SO_RCVLOWAT: | | | |
886 | return SO_RCVLOWAT; | | | |
887 | case LINUX_SO_KEEPALIVE: | | 883 | case LINUX_SO_KEEPALIVE: |
888 | return SO_KEEPALIVE; | | 884 | return SO_KEEPALIVE; |
889 | case LINUX_SO_OOBINLINE: | | 885 | case LINUX_SO_OOBINLINE: |
890 | return SO_OOBINLINE; | | 886 | return SO_OOBINLINE; |
| | | 887 | case LINUX_SO_NO_CHECK: |
| | | 888 | case LINUX_SO_PRIORITY: |
| | | 889 | return -1; |
891 | case LINUX_SO_LINGER: | | 890 | case LINUX_SO_LINGER: |
892 | return SO_LINGER; | | 891 | return SO_LINGER; |
| | | 892 | case LINUX_SO_BSDCOMPAT: |
| | | 893 | case LINUX_SO_PASSCRED: |
| | | 894 | case LINUX_SO_PEERCRED: |
| | | 895 | return -1; |
| | | 896 | case LINUX_SO_RCVLOWAT: |
| | | 897 | return SO_RCVLOWAT; |
| | | 898 | case LINUX_SO_SNDLOWAT: |
| | | 899 | return SO_SNDLOWAT; |
| | | 900 | case LINUX_SO_RCVTIMEO: |
| | | 901 | return SO_RCVTIMEO; |
| | | 902 | case LINUX_SO_SNDTIMEO: |
| | | 903 | return SO_SNDTIMEO; |
| | | 904 | case LINUX_SO_SECURITY_AUTHENTICATION: |
| | | 905 | case LINUX_SO_SECURITY_ENCRYPTION_TRANSPORT: |
| | | 906 | case LINUX_SO_SECURITY_ENCRYPTION_NETWORK: |
| | | 907 | case LINUX_SO_BINDTODEVICE: |
| | | 908 | case LINUX_SO_ATTACH_FILTER: |
| | | 909 | case LINUX_SO_DETACH_FILTER: |
| | | 910 | case LINUX_SO_PEERNAME: |
| | | 911 | return -1; |
| | | 912 | case LINUX_SO_TIMESTAMP: |
| | | 913 | return SO_TIMESTAMP; |
893 | case LINUX_SO_ACCEPTCONN: | | 914 | case LINUX_SO_ACCEPTCONN: |
894 | return SO_ACCEPTCONN; | | 915 | case LINUX_SO_PEERSEC: |
895 | case LINUX_SO_PRIORITY: | | 916 | case LINUX_SO_SNDBUFFORCE: |
896 | case LINUX_SO_NO_CHECK: | | 917 | case LINUX_SO_RCVBUFFORCE: |
| | | 918 | case LINUX_SO_PASSSEC: |
| | | 919 | case LINUX_SO_TIMESTAMPNS: |
| | | 920 | case LINUX_SO_MARK: |
| | | 921 | case LINUX_SO_TIMESTAMPING: |
| | | 922 | case LINUX_SO_PROTOCOL: |
| | | 923 | case LINUX_SO_DOMAIN: |
| | | 924 | case LINUX_SO_RXQ_OVFL: |
| | | 925 | case LINUX_SO_WIFI_STATUS: |
| | | 926 | case LINUX_SO_PEEK_OFF: |
| | | 927 | case LINUX_SO_NOFCS: |
897 | default: | | 928 | default: |
898 | return -1; | | 929 | return -1; |
899 | } | | 930 | } |
900 | } | | 931 | } |
901 | | | 932 | |
902 | /* | | 933 | /* |
903 | * Convert Linux IP level socket option number to NetBSD values. | | 934 | * Convert Linux IP level socket option number to NetBSD values. |
904 | */ | | 935 | */ |
905 | int | | 936 | int |
906 | linux_to_bsd_ip_sockopt(int lopt) | | 937 | linux_to_bsd_ip_sockopt(int lopt) |
907 | { | | 938 | { |
908 | | | 939 | |
909 | switch (lopt) { | | 940 | switch (lopt) { |