Split the COMPAT_50 socket-timeout stuff out of kern/uipc_socket.c and into its own source file, which is now included in the compat_50 module. (Not sure how this got missed during the original [pgoyette-compat] work)diff -r1.2 -r1.3 src/sys/compat/common/compat_50_mod.c
(pgoyette)
--- src/sys/compat/common/compat_50_mod.c 2019/01/27 02:08:39 1.2
+++ src/sys/compat/common/compat_50_mod.c 2019/04/15 02:07:11 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: compat_50_mod.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $ */ | 1 | /* $NetBSD: compat_50_mod.c,v 1.3 2019/04/15 02:07:11 pgoyette Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2018 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2018 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software developed for The NetBSD Foundation | 7 | * This code is derived from software developed for The NetBSD Foundation | |
8 | * by Paul Goyette | 8 | * by Paul Goyette | |
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. | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
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 | * Linkage for the compat module: spaghetti. | 33 | * Linkage for the compat module: spaghetti. | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.3 2019/04/15 02:07:11 pgoyette Exp $"); | |
38 | 38 | |||
39 | #if defined(_KERNEL_OPT) | 39 | #if defined(_KERNEL_OPT) | |
40 | #include "opt_compat_netbsd.h" | 40 | #include "opt_compat_netbsd.h" | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <sys/systm.h> | 43 | #include <sys/systm.h> | |
44 | #include <sys/module.h> | 44 | #include <sys/module.h> | |
45 | #include <sys/sysctl.h> | 45 | #include <sys/sysctl.h> | |
46 | #include <sys/syscall.h> | 46 | #include <sys/syscall.h> | |
47 | #include <sys/syscallvar.h> | 47 | #include <sys/syscallvar.h> | |
48 | #include <sys/syscallargs.h> | 48 | #include <sys/syscallargs.h> | |
49 | 49 | |||
50 | #include <compat/sys/clockctl.h> | 50 | #include <compat/sys/clockctl.h> | |
@@ -77,46 +77,48 @@ compat_50_init(void) | @@ -77,46 +77,48 @@ compat_50_init(void) | |||
77 | error = vfs_syscalls_50_init(); | 77 | error = vfs_syscalls_50_init(); | |
78 | if (error != 0) | 78 | if (error != 0) | |
79 | goto err3; | 79 | goto err3; | |
80 | 80 | |||
81 | uvm_50_init(); | 81 | uvm_50_init(); | |
82 | uipc_syscalls_50_init(); | 82 | uipc_syscalls_50_init(); | |
83 | clockctl_50_init(); | 83 | clockctl_50_init(); | |
84 | if_spppsubr_50_init(); | 84 | if_spppsubr_50_init(); | |
85 | puffs_50_init(); | 85 | puffs_50_init(); | |
86 | wsevent_50_init(); | 86 | wsevent_50_init(); | |
87 | vnd_50_init(); | 87 | vnd_50_init(); | |
88 | rndpseudo_50_init(); | 88 | rndpseudo_50_init(); | |
89 | rtsock_50_init(); | 89 | rtsock_50_init(); | |
90 | kern_uipc_socket_50_init(); | |||
90 | 91 | |||
91 | return error; | 92 | return error; | |
92 | 93 | |||
93 | /* If an error occured, undo all previous set-up before returning */ | 94 | /* If an error occured, undo all previous set-up before returning */ | |
94 | 95 | |||
95 | err3: | 96 | err3: | |
96 | kern_select_50_fini(); | 97 | kern_select_50_fini(); | |
97 | err2: | 98 | err2: | |
98 | kern_time_50_fini(); | 99 | kern_time_50_fini(); | |
99 | err1: | 100 | err1: | |
100 | kern_50_fini(); | 101 | kern_50_fini(); | |
101 | 102 | |||
102 | return error; | 103 | return error; | |
103 | } | 104 | } | |
104 | 105 | |||
105 | int | 106 | int | |
106 | compat_50_fini(void) | 107 | compat_50_fini(void) | |
107 | { | 108 | { | |
108 | int error = 0; | 109 | int error = 0; | |
109 | 110 | |||
111 | kern_uipc_socket_50_fini(); | |||
110 | rtsock_50_fini(); | 112 | rtsock_50_fini(); | |
111 | rndpseudo_50_fini(); | 113 | rndpseudo_50_fini(); | |
112 | vnd_50_fini(); | 114 | vnd_50_fini(); | |
113 | wsevent_50_fini(); | 115 | wsevent_50_fini(); | |
114 | puffs_50_fini(); | 116 | puffs_50_fini(); | |
115 | if_spppsubr_50_fini(); | 117 | if_spppsubr_50_fini(); | |
116 | clockctl_50_fini(); | 118 | clockctl_50_fini(); | |
117 | uipc_syscalls_50_fini(); | 119 | uipc_syscalls_50_fini(); | |
118 | uvm_50_fini(); | 120 | uvm_50_fini(); | |
119 | 121 | |||
120 | error = vfs_syscalls_50_fini(); | 122 | error = vfs_syscalls_50_fini(); | |
121 | if (error != 0) | 123 | if (error != 0) | |
122 | goto err1; | 124 | goto err1; | |
@@ -142,26 +144,27 @@ compat_50_fini(void) | @@ -142,26 +144,27 @@ compat_50_fini(void) | |||
142 | kern_select_50_init(); | 144 | kern_select_50_init(); | |
143 | err2: | 145 | err2: | |
144 | vfs_syscalls_50_init(); | 146 | vfs_syscalls_50_init(); | |
145 | err1: | 147 | err1: | |
146 | uvm_50_init(); | 148 | uvm_50_init(); | |
147 | uipc_syscalls_50_init(); | 149 | uipc_syscalls_50_init(); | |
148 | clockctl_50_init(); | 150 | clockctl_50_init(); | |
149 | if_spppsubr_50_init(); | 151 | if_spppsubr_50_init(); | |
150 | puffs_50_init(); | 152 | puffs_50_init(); | |
151 | wsevent_50_init(); | 153 | wsevent_50_init(); | |
152 | vnd_50_init(); | 154 | vnd_50_init(); | |
153 | rndpseudo_50_init(); | 155 | rndpseudo_50_init(); | |
154 | rtsock_50_init(); | 156 | rtsock_50_init(); | |
157 | kern_uipc_socket_50_init(); | |||
155 | 158 | |||
156 | return error; | 159 | return error; | |
157 | } | 160 | } | |
158 | 161 | |||
159 | MODULE(MODULE_CLASS_EXEC, compat_50, "compat_60"); | 162 | MODULE(MODULE_CLASS_EXEC, compat_50, "compat_60"); | |
160 | 163 | |||
161 | static int | 164 | static int | |
162 | compat_50_modcmd(modcmd_t cmd, void *arg) | 165 | compat_50_modcmd(modcmd_t cmd, void *arg) | |
163 | { | 166 | { | |
164 | 167 | |||
165 | switch (cmd) { | 168 | switch (cmd) { | |
166 | case MODULE_CMD_INIT: | 169 | case MODULE_CMD_INIT: | |
167 | return compat_50_init(); | 170 | return compat_50_init(); |
--- src/sys/compat/common/files.common 2019/01/27 02:08:39 1.2
+++ src/sys/compat/common/files.common 2019/04/15 02:07:11 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: files.common,v 1.2 2019/01/27 02:08:39 pgoyette Exp $ | 1 | # $NetBSD: files.common,v 1.3 2019/04/15 02:07:11 pgoyette Exp $ | |
2 | 2 | |||
3 | # | 3 | # | |
4 | # Generic utility files, used by various compat options. | 4 | # Generic utility files, used by various compat options. | |
5 | # | 5 | # | |
6 | define compat_netbsd_util | 6 | define compat_netbsd_util | |
7 | file compat/common/compat_exec.c compat_utils | 7 | file compat/common/compat_exec.c compat_utils | |
8 | file compat/common/compat_util.c compat_utils | 8 | file compat/common/compat_util.c compat_utils | |
9 | 9 | |||
10 | # | 10 | # | |
11 | # Sources for syscall and ioctl compatibility across the versions. | 11 | # Sources for syscall and ioctl compatibility across the versions. | |
12 | # | 12 | # | |
13 | 13 | |||
14 | # Compatibility code for 4.3BSD | 14 | # Compatibility code for 4.3BSD | |
@@ -75,26 +75,27 @@ file compat/common/sysmon_power_40.c co | @@ -75,26 +75,27 @@ file compat/common/sysmon_power_40.c co | |||
75 | # Compatibility code for NetBSD 5.0 | 75 | # Compatibility code for NetBSD 5.0 | |
76 | file compat/common/compat_50_mod.c compat_50 | 76 | file compat/common/compat_50_mod.c compat_50 | |
77 | file compat/common/kern_50.c compat_50 | 77 | file compat/common/kern_50.c compat_50 | |
78 | file compat/common/kern_time_50.c compat_50 | 78 | file compat/common/kern_time_50.c compat_50 | |
79 | file compat/common/kern_select_50.c compat_50 | 79 | file compat/common/kern_select_50.c compat_50 | |
80 | file compat/common/rndpseudo_50.c compat_50 | 80 | file compat/common/rndpseudo_50.c compat_50 | |
81 | file compat/common/rtsock_50.c compat_50 | 81 | file compat/common/rtsock_50.c compat_50 | |
82 | file compat/common/vfs_syscalls_50.c compat_50 | 82 | file compat/common/vfs_syscalls_50.c compat_50 | |
83 | file compat/common/uipc_syscalls_50.c compat_50 | 83 | file compat/common/uipc_syscalls_50.c compat_50 | |
84 | file compat/common/vnd_50.c compat_50 | 84 | file compat/common/vnd_50.c compat_50 | |
85 | file compat/common/clockctl_50.c compat_50 | 85 | file compat/common/clockctl_50.c compat_50 | |
86 | file compat/common/if_spppsubr50.c compat_50 | 86 | file compat/common/if_spppsubr50.c compat_50 | |
87 | file compat/common/uvm_50.c compat_50 | 87 | file compat/common/uvm_50.c compat_50 | |
88 | file compat/common/kern_uipc_socket_50.c compat_50 | |||
88 | 89 | |||
89 | # Compatibility code for NetBSD 6.0 | 90 | # Compatibility code for NetBSD 6.0 | |
90 | file compat/common/compat_60_mod.c compat_60 | 91 | file compat/common/compat_60_mod.c compat_60 | |
91 | file compat/common/kern_sa_60.c compat_60 | 92 | file compat/common/kern_sa_60.c compat_60 | |
92 | file compat/common/tty_60.c compat_60 | 93 | file compat/common/tty_60.c compat_60 | |
93 | file compat/common/kern_time_60.c compat_60 | 94 | file compat/common/kern_time_60.c compat_60 | |
94 | file compat/common/kern_cpu_60.c compat_60 | 95 | file compat/common/kern_cpu_60.c compat_60 | |
95 | file compat/common/ccd_60.c compat_60 | 96 | file compat/common/ccd_60.c compat_60 | |
96 | 97 | |||
97 | # Compatibility code for NetBSD 7.0 | 98 | # Compatibility code for NetBSD 7.0 | |
98 | file compat/common/compat_70_mod.c compat_70 | 99 | file compat/common/compat_70_mod.c compat_70 | |
99 | file compat/common/rtsock_70.c compat_70 | 100 | file compat/common/rtsock_70.c compat_70 | |
100 | file compat/common/uipc_usrreq_70.c compat_70 | 101 | file compat/common/uipc_usrreq_70.c compat_70 |
--- src/sys/compat/common/compat_mod.h 2019/01/28 15:46:49 1.3
+++ src/sys/compat/common/compat_mod.h 2019/04/15 02:07:11 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: compat_mod.h,v 1.3 2019/01/28 15:46:49 christos Exp $ */ | 1 | /* $NetBSD: compat_mod.h,v 1.4 2019/04/15 02:07:11 pgoyette Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2013 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 Christos Zoulas. | 8 | * by Christos Zoulas. | |
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. | |
@@ -66,26 +66,28 @@ int kern_select_50_init(void); | @@ -66,26 +66,28 @@ int kern_select_50_init(void); | |||
66 | int kern_select_50_fini(void); | 66 | int kern_select_50_fini(void); | |
67 | void uvm_50_init(void); | 67 | void uvm_50_init(void); | |
68 | void uvm_50_fini(void); | 68 | void uvm_50_fini(void); | |
69 | int vfs_syscalls_50_init(void); | 69 | int vfs_syscalls_50_init(void); | |
70 | int vfs_syscalls_50_fini(void); | 70 | int vfs_syscalls_50_fini(void); | |
71 | void uipc_syscalls_50_init(void); | 71 | void uipc_syscalls_50_init(void); | |
72 | void uipc_syscalls_50_fini(void); | 72 | void uipc_syscalls_50_fini(void); | |
73 | void vnd_50_init(void); | 73 | void vnd_50_init(void); | |
74 | void vnd_50_fini(void); | 74 | void vnd_50_fini(void); | |
75 | void rndpseudo_50_init(void); | 75 | void rndpseudo_50_init(void); | |
76 | void rndpseudo_50_fini(void); | 76 | void rndpseudo_50_fini(void); | |
77 | void rtsock_50_init(void); | 77 | void rtsock_50_init(void); | |
78 | void rtsock_50_fini(void); | 78 | void rtsock_50_fini(void); | |
79 | void kern_uipc_socket_50_init(void); | |||
80 | void kern_uipc_socket_50_fini(void); | |||
79 | #endif | 81 | #endif | |
80 | 82 | |||
81 | #ifdef COMPAT_40 | 83 | #ifdef COMPAT_40 | |
82 | int compat_40_init(void); | 84 | int compat_40_init(void); | |
83 | int compat_40_fini(void); | 85 | int compat_40_fini(void); | |
84 | void uipc_syscalls_40_init(void); | 86 | void uipc_syscalls_40_init(void); | |
85 | void uipc_syscalls_40_fini(void); | 87 | void uipc_syscalls_40_fini(void); | |
86 | int vfs_syscalls_40_init(void); | 88 | int vfs_syscalls_40_init(void); | |
87 | int vfs_syscalls_40_fini(void); | 89 | int vfs_syscalls_40_fini(void); | |
88 | void sysmon_power_40_init(void); | 90 | void sysmon_power_40_init(void); | |
89 | void sysmon_power_40_fini(void); | 91 | void sysmon_power_40_fini(void); | |
90 | #endif | 92 | #endif | |
91 | 93 |
/* $NetBSD: kern_uipc_socket_50.c,v 1.1 2019/04/15 02:07:11 pgoyette Exp $ */
/*
* Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe of Wasabi Systems, Inc, and by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 2004 The FreeBSD Foundation
* Copyright (c) 2004 Robert Watson
* Copyright (c) 1982, 1986, 1988, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)uipc_socket.c 8.6 (Berkeley) 5/2/95
*/
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Utah $Hdr: vn.c 1.13 94/04/02$
*
* @(#)vn.c 8.9 (Berkeley) 5/14/95
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_uipc_socket_50.c,v 1.1 2019/04/15 02:07:11 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
#endif
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/file.h>
#include <sys/compat_stub.h>
#include <sys/socketvar.h>
#include <compat/sys/time.h>
#include <compat/sys/socket.h>
#include <compat/common/compat_mod.h>
static int
uipc_socket_50_getopt1(int opt, struct socket *so, struct sockopt *sopt,
struct timeval *tv)
{
int optval, error;
struct timeval50 otv;
switch (opt) {
case SO_OSNDTIMEO:
case SO_ORCVTIMEO:
optval = (opt == SO_OSNDTIMEO ?
so->so_snd.sb_timeo : so->so_rcv.sb_timeo);
otv.tv_sec = optval / hz;
otv.tv_usec = (optval % hz) * tick;
error = sockopt_set(sopt, &otv, sizeof(otv));
break;
case SO_OTIMESTAMP:
error = sockopt_setint(sopt, (so->so_options & opt) ? 1 : 0);
break;
default:
error = EPASSTHROUGH;
}
return error;
}
static int
uipc_socket_50_setopt1(int opt, struct socket *so, const struct sockopt *sopt,
struct timeval *tv)
{
int optval, error;
struct timeval50 otv;
switch (opt) {
case SO_OSNDTIMEO:
case SO_ORCVTIMEO:
error = sockopt_get(sopt, &otv, sizeof(otv));
if (error) {
solock(so);
break;
}
timeval50_to_timeval(&otv, tv);
opt = opt == SO_OSNDTIMEO ? SO_SNDTIMEO : SO_RCVTIMEO;
/*
* Processing will continue as for SO_SNDTIMEO
* and SO_RCVTIMEO, using the new-format tv
*/
break;
case SO_OTIMESTAMP:
error = sockopt_getint(sopt, &optval);
solock(so);
if (error)
break;
if (optval)
so->so_options |= opt;
else
so->so_options &= ~opt;
break;
default:
error = EPASSTHROUGH;
}
return error;
}
static int
uipc_socket_50_sbts(int opt, struct mbuf **mp)
{
struct timeval50 tv50;
struct timeval tv;
microtime(&tv);
if (opt & SO_OTIMESTAMP) {
timeval_to_timeval50(&tv, &tv50);
*mp = sbcreatecontrol(&tv50, sizeof(tv50), SCM_OTIMESTAMP,
SOL_SOCKET);
if (*mp)
mp = &(*mp)->m_next;
return 0;
} else
return EPASSTHROUGH;
}
void
kern_uipc_socket_50_init(void)
{
MODULE_HOOK_SET(uipc_socket_50_setopt1_hook, "sockop_50",
uipc_socket_50_setopt1);
MODULE_HOOK_SET(uipc_socket_50_getopt1_hook, "sockop_50",
uipc_socket_50_getopt1);
MODULE_HOOK_SET(uipc_socket_50_sbts_hook, "sbts_50",
uipc_socket_50_sbts);
}
void
kern_uipc_socket_50_fini(void)
{
MODULE_HOOK_UNSET(uipc_socket_50_setopt1_hook);
MODULE_HOOK_UNSET(uipc_socket_50_getopt1_hook);
MODULE_HOOK_UNSET(uipc_socket_50_sbts_hook);
}
--- src/sys/kern/compat_stub.c 2019/02/05 23:28:02 1.8
+++ src/sys/kern/compat_stub.c 2019/04/15 02:07:11 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: compat_stub.c,v 1.8 2019/02/05 23:28:02 christos Exp $ */ | 1 | /* $NetBSD: compat_stub.c,v 1.9 2019/04/15 02:07:11 pgoyette Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2018 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2018 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 Paul Goyette | 8 | * by Paul Goyette | |
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. | |
@@ -163,31 +163,38 @@ struct if_cvtcmd_43_hook_t if_cvtcmd_43_ | @@ -163,31 +163,38 @@ struct if_cvtcmd_43_hook_t if_cvtcmd_43_ | |||
163 | struct if_ifioctl_43_hook_t if_ifioctl_43_hook; | 163 | struct if_ifioctl_43_hook_t if_ifioctl_43_hook; | |
164 | 164 | |||
165 | /* | 165 | /* | |
166 | * if43_cvtcmd_20 compatability | 166 | * if43_cvtcmd_20 compatability | |
167 | */ | 167 | */ | |
168 | struct if43_cvtcmd_20_hook_t if43_cvtcmd_20_hook; | 168 | struct if43_cvtcmd_20_hook_t if43_cvtcmd_20_hook; | |
169 | 169 | |||
170 | /* | 170 | /* | |
171 | * tty 43 ioctl compatibility | 171 | * tty 43 ioctl compatibility | |
172 | */ | 172 | */ | |
173 | struct tty_ttioctl_43_hook_t tty_ttioctl_43_hook; | 173 | struct tty_ttioctl_43_hook_t tty_ttioctl_43_hook; | |
174 | 174 | |||
175 | /* | 175 | /* | |
176 | * uipc_syscalls_40 compatability | 176 | * uipc_syscalls_40 compatibility | |
177 | */ | 177 | */ | |
178 | struct uipc_syscalls_40_hook_t uipc_syscalls_40_hook; | 178 | struct uipc_syscalls_40_hook_t uipc_syscalls_40_hook; | |
179 | 179 | |||
180 | /* | 180 | /* | |
181 | * uipc_socket_50 compatibility | |||
182 | */ | |||
183 | struct uipc_socket_50_setopt1_hook_t uipc_socket_50_setopt1_hook; | |||
184 | struct uipc_socket_50_getopt1_hook_t uipc_socket_50_getopt1_hook; | |||
185 | struct uipc_socket_50_sbts_hook_t uipc_socket_50_sbts_hook; | |||
186 | ||||
187 | /* | |||
181 | * uipc_syscalls_50 compatability | 188 | * uipc_syscalls_50 compatability | |
182 | */ | 189 | */ | |
183 | struct uipc_syscalls_50_hook_t uipc_syscalls_50_hook; | 190 | struct uipc_syscalls_50_hook_t uipc_syscalls_50_hook; | |
184 | 191 | |||
185 | /* | 192 | /* | |
186 | * rtsock 14 compatability | 193 | * rtsock 14 compatability | |
187 | */ | 194 | */ | |
188 | struct rtsock_oifmsg_14_hook_t rtsock_oifmsg_14_hook; | 195 | struct rtsock_oifmsg_14_hook_t rtsock_oifmsg_14_hook; | |
189 | struct rtsock_iflist_14_hook_t rtsock_iflist_14_hook; | 196 | struct rtsock_iflist_14_hook_t rtsock_iflist_14_hook; | |
190 | 197 | |||
191 | /* | 198 | /* | |
192 | * rtsock 50 compatability | 199 | * rtsock 50 compatability | |
193 | */ | 200 | */ |
--- src/sys/kern/uipc_socket.c 2019/04/14 09:09:55 1.274
+++ src/sys/kern/uipc_socket.c 2019/04/15 02:07:11 1.275
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: uipc_socket.c,v 1.274 2019/04/14 09:09:55 maxv Exp $ */ | 1 | /* $NetBSD: uipc_socket.c,v 1.275 2019/04/15 02:07:11 pgoyette Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2002, 2007, 2008, 2009 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 Jason R. Thorpe of Wasabi Systems, Inc, and by Andrew Doran. | 8 | * by Jason R. Thorpe of Wasabi Systems, Inc, and by Andrew Doran. | |
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. | |
@@ -61,27 +61,27 @@ | @@ -61,27 +61,27 @@ | |||
61 | * | 61 | * | |
62 | * @(#)uipc_socket.c 8.6 (Berkeley) 5/2/95 | 62 | * @(#)uipc_socket.c 8.6 (Berkeley) 5/2/95 | |
63 | */ | 63 | */ | |
64 | 64 | |||
65 | /* | 65 | /* | |
66 | * Socket operation routines. | 66 | * Socket operation routines. | |
67 | * | 67 | * | |
68 | * These routines are called by the routines in sys_socket.c or from a | 68 | * These routines are called by the routines in sys_socket.c or from a | |
69 | * system process, and implement the semantics of socket operations by | 69 | * system process, and implement the semantics of socket operations by | |
70 | * switching out to the protocol specific routines. | 70 | * switching out to the protocol specific routines. | |
71 | */ | 71 | */ | |
72 | 72 | |||
73 | #include <sys/cdefs.h> | 73 | #include <sys/cdefs.h> | |
74 | __KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.274 2019/04/14 09:09:55 maxv Exp $"); | 74 | __KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.275 2019/04/15 02:07:11 pgoyette Exp $"); | |
75 | 75 | |||
76 | #ifdef _KERNEL_OPT | 76 | #ifdef _KERNEL_OPT | |
77 | #include "opt_compat_netbsd.h" | 77 | #include "opt_compat_netbsd.h" | |
78 | #include "opt_sock_counters.h" | 78 | #include "opt_sock_counters.h" | |
79 | #include "opt_sosend_loan.h" | 79 | #include "opt_sosend_loan.h" | |
80 | #include "opt_mbuftrace.h" | 80 | #include "opt_mbuftrace.h" | |
81 | #include "opt_somaxkva.h" | 81 | #include "opt_somaxkva.h" | |
82 | #include "opt_multiprocessor.h" /* XXX */ | 82 | #include "opt_multiprocessor.h" /* XXX */ | |
83 | #include "opt_sctp.h" | 83 | #include "opt_sctp.h" | |
84 | #endif | 84 | #endif | |
85 | 85 | |||
86 | #include <sys/param.h> | 86 | #include <sys/param.h> | |
87 | #include <sys/systm.h> | 87 | #include <sys/systm.h> | |
@@ -94,31 +94,30 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_socket. | @@ -94,31 +94,30 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_socket. | |||
94 | #include <sys/kernel.h> | 94 | #include <sys/kernel.h> | |
95 | #include <sys/protosw.h> | 95 | #include <sys/protosw.h> | |
96 | #include <sys/socket.h> | 96 | #include <sys/socket.h> | |
97 | #include <sys/socketvar.h> | 97 | #include <sys/socketvar.h> | |
98 | #include <sys/signalvar.h> | 98 | #include <sys/signalvar.h> | |
99 | #include <sys/resourcevar.h> | 99 | #include <sys/resourcevar.h> | |
100 | #include <sys/uidinfo.h> | 100 | #include <sys/uidinfo.h> | |
101 | #include <sys/event.h> | 101 | #include <sys/event.h> | |
102 | #include <sys/poll.h> | 102 | #include <sys/poll.h> | |
103 | #include <sys/kauth.h> | 103 | #include <sys/kauth.h> | |
104 | #include <sys/mutex.h> | 104 | #include <sys/mutex.h> | |
105 | #include <sys/condvar.h> | 105 | #include <sys/condvar.h> | |
106 | #include <sys/kthread.h> | 106 | #include <sys/kthread.h> | |
107 | #include <sys/compat_stub.h> | |||
107 | 108 | |||
108 | #ifdef COMPAT_50 | |||
109 | #include <compat/sys/time.h> | 109 | #include <compat/sys/time.h> | |
110 | #include <compat/sys/socket.h> | 110 | #include <compat/sys/socket.h> | |
111 | #endif | |||
112 | 111 | |||
113 | #include <uvm/uvm_extern.h> | 112 | #include <uvm/uvm_extern.h> | |
114 | #include <uvm/uvm_loan.h> | 113 | #include <uvm/uvm_loan.h> | |
115 | #include <uvm/uvm_page.h> | 114 | #include <uvm/uvm_page.h> | |
116 | 115 | |||
117 | MALLOC_DEFINE(M_SONAME, "soname", "socket name"); | 116 | MALLOC_DEFINE(M_SONAME, "soname", "socket name"); | |
118 | 117 | |||
119 | extern const struct fileops socketops; | 118 | extern const struct fileops socketops; | |
120 | 119 | |||
121 | static int sooptions; | 120 | static int sooptions; | |
122 | extern int somaxconn; /* patchable (XXX sysctl) */ | 121 | extern int somaxconn; /* patchable (XXX sysctl) */ | |
123 | int somaxconn = SOMAXCONN; | 122 | int somaxconn = SOMAXCONN; | |
124 | kmutex_t *softnet_lock; | 123 | kmutex_t *softnet_lock; | |
@@ -1697,32 +1696,43 @@ sorflush(struct socket *so) | @@ -1697,32 +1696,43 @@ sorflush(struct socket *so) | |||
1697 | sounlock(so); | 1696 | sounlock(so); | |
1698 | (*pr->pr_domain->dom_dispose)(asb.sb_mb); | 1697 | (*pr->pr_domain->dom_dispose)(asb.sb_mb); | |
1699 | solock(so); | 1698 | solock(so); | |
1700 | } | 1699 | } | |
1701 | sbrelease(&asb, so); | 1700 | sbrelease(&asb, so); | |
1702 | } | 1701 | } | |
1703 | 1702 | |||
1704 | /* | 1703 | /* | |
1705 | * internal set SOL_SOCKET options | 1704 | * internal set SOL_SOCKET options | |
1706 | */ | 1705 | */ | |
1707 | static int | 1706 | static int | |
1708 | sosetopt1(struct socket *so, const struct sockopt *sopt) | 1707 | sosetopt1(struct socket *so, const struct sockopt *sopt) | |
1709 | { | 1708 | { | |
1710 | int error = EINVAL, opt; | 1709 | int error, opt; | |
1711 | int optval = 0; /* XXX: gcc */ | 1710 | int optval = 0; /* XXX: gcc */ | |
1712 | struct linger l; | 1711 | struct linger l; | |
1713 | struct timeval tv; | 1712 | struct timeval tv; | |
1714 | 1713 | |||
1715 | switch ((opt = sopt->sopt_name)) { | 1714 | opt = sopt->sopt_name; | |
1715 | ||||
1716 | MODULE_HOOK_CALL(uipc_socket_50_setopt1_hook, (opt, so, sopt, &tv), | |||
1717 | enosys(), error); | |||
1718 | if (error == EPASSTHROUGH) | |||
1719 | error = EINVAL; | |||
1720 | else if (error && error != ENOSYS) { | |||
1721 | KASSERT(solocked(so)); | |||
1722 | return error; | |||
1723 | } | |||
1724 | ||||
1725 | switch (opt) { | |||
1716 | 1726 | |||
1717 | case SO_ACCEPTFILTER: | 1727 | case SO_ACCEPTFILTER: | |
1718 | error = accept_filt_setopt(so, sopt); | 1728 | error = accept_filt_setopt(so, sopt); | |
1719 | KASSERT(solocked(so)); | 1729 | KASSERT(solocked(so)); | |
1720 | break; | 1730 | break; | |
1721 | 1731 | |||
1722 | case SO_LINGER: | 1732 | case SO_LINGER: | |
1723 | error = sockopt_get(sopt, &l, sizeof(l)); | 1733 | error = sockopt_get(sopt, &l, sizeof(l)); | |
1724 | solock(so); | 1734 | solock(so); | |
1725 | if (error) | 1735 | if (error) | |
1726 | break; | 1736 | break; | |
1727 | if (l.l_linger < 0 || l.l_linger > USHRT_MAX || | 1737 | if (l.l_linger < 0 || l.l_linger > USHRT_MAX || | |
1728 | l.l_linger > (INT_MAX / hz)) { | 1738 | l.l_linger > (INT_MAX / hz)) { | |
@@ -1737,29 +1747,26 @@ sosetopt1(struct socket *so, const struc | @@ -1737,29 +1747,26 @@ sosetopt1(struct socket *so, const struc | |||
1737 | break; | 1747 | break; | |
1738 | 1748 | |||
1739 | case SO_DEBUG: | 1749 | case SO_DEBUG: | |
1740 | case SO_KEEPALIVE: | 1750 | case SO_KEEPALIVE: | |
1741 | case SO_DONTROUTE: | 1751 | case SO_DONTROUTE: | |
1742 | case SO_USELOOPBACK: | 1752 | case SO_USELOOPBACK: | |
1743 | case SO_BROADCAST: | 1753 | case SO_BROADCAST: | |
1744 | case SO_REUSEADDR: | 1754 | case SO_REUSEADDR: | |
1745 | case SO_REUSEPORT: | 1755 | case SO_REUSEPORT: | |
1746 | case SO_OOBINLINE: | 1756 | case SO_OOBINLINE: | |
1747 | case SO_TIMESTAMP: | 1757 | case SO_TIMESTAMP: | |
1748 | case SO_NOSIGPIPE: | 1758 | case SO_NOSIGPIPE: | |
1749 | case SO_RERROR: | 1759 | case SO_RERROR: | |
1750 | #ifdef SO_OTIMESTAMP | |||
1751 | case SO_OTIMESTAMP: | |||
1752 | #endif | |||
1753 | error = sockopt_getint(sopt, &optval); | 1760 | error = sockopt_getint(sopt, &optval); | |
1754 | solock(so); | 1761 | solock(so); | |
1755 | if (error) | 1762 | if (error) | |
1756 | break; | 1763 | break; | |
1757 | if (optval) | 1764 | if (optval) | |
1758 | so->so_options |= opt; | 1765 | so->so_options |= opt; | |
1759 | else | 1766 | else | |
1760 | so->so_options &= ~opt; | 1767 | so->so_options &= ~opt; | |
1761 | break; | 1768 | break; | |
1762 | 1769 | |||
1763 | case SO_SNDBUF: | 1770 | case SO_SNDBUF: | |
1764 | case SO_RCVBUF: | 1771 | case SO_RCVBUF: | |
1765 | case SO_SNDLOWAT: | 1772 | case SO_SNDLOWAT: | |
@@ -1805,45 +1812,35 @@ sosetopt1(struct socket *so, const struc | @@ -1805,45 +1812,35 @@ sosetopt1(struct socket *so, const struc | |||
1805 | 1812 | |||
1806 | so->so_snd.sb_lowat = optval; | 1813 | so->so_snd.sb_lowat = optval; | |
1807 | break; | 1814 | break; | |
1808 | 1815 | |||
1809 | case SO_RCVLOWAT: | 1816 | case SO_RCVLOWAT: | |
1810 | if (optval > so->so_rcv.sb_hiwat) | 1817 | if (optval > so->so_rcv.sb_hiwat) | |
1811 | optval = so->so_rcv.sb_hiwat; | 1818 | optval = so->so_rcv.sb_hiwat; | |
1812 | 1819 | |||
1813 | so->so_rcv.sb_lowat = optval; | 1820 | so->so_rcv.sb_lowat = optval; | |
1814 | break; | 1821 | break; | |
1815 | } | 1822 | } | |
1816 | break; | 1823 | break; | |
1817 | 1824 | |||
1818 | #ifdef COMPAT_50 | |||
1819 | case SO_OSNDTIMEO: | 1825 | case SO_OSNDTIMEO: | |
1820 | case SO_ORCVTIMEO: { | 1826 | case SO_ORCVTIMEO: | |
1821 | struct timeval50 otv; | 1827 | if (error == ENOSYS) { | |
1822 | error = sockopt_get(sopt, &otv, sizeof(otv)); | 1828 | error = EINVAL; | |
1823 | if (error) { | |||
1824 | solock(so); | 1829 | solock(so); | |
1825 | break; | 1830 | break; | |
1826 | } | 1831 | } | |
1827 | timeval50_to_timeval(&otv, &tv); | 1832 | /* FALLTHROUGH */ | |
1828 | opt = opt == SO_OSNDTIMEO ? SO_SNDTIMEO : SO_RCVTIMEO; | |||
1829 | error = 0; | |||
1830 | /*FALLTHROUGH*/ | |||
1831 | } | |||
1832 | #endif /* COMPAT_50 */ | |||
1833 | ||||
1834 | /*FALLTHROUGH*/ | |||
1835 | case SO_SNDTIMEO: | 1833 | case SO_SNDTIMEO: | |
1836 | /*FALLTHROUGH*/ | |||
1837 | case SO_RCVTIMEO: | 1834 | case SO_RCVTIMEO: | |
1838 | if (error) | 1835 | if (error) | |
1839 | error = sockopt_get(sopt, &tv, sizeof(tv)); | 1836 | error = sockopt_get(sopt, &tv, sizeof(tv)); | |
1840 | solock(so); | 1837 | solock(so); | |
1841 | if (error) | 1838 | if (error) | |
1842 | break; | 1839 | break; | |
1843 | 1840 | |||
1844 | if (tv.tv_sec < 0 || tv.tv_usec < 0 || tv.tv_usec >= 1000000) { | 1841 | if (tv.tv_sec < 0 || tv.tv_usec < 0 || tv.tv_usec >= 1000000) { | |
1845 | error = EDOM; | 1842 | error = EDOM; | |
1846 | break; | 1843 | break; | |
1847 | } | 1844 | } | |
1848 | if (tv.tv_sec > (INT_MAX - tv.tv_usec / tick) / hz) { | 1845 | if (tv.tv_sec > (INT_MAX - tv.tv_usec / tick) / hz) { | |
1849 | error = EDOM; | 1846 | error = EDOM; | |
@@ -1945,29 +1942,26 @@ sogetopt1(struct socket *so, struct sock | @@ -1945,29 +1942,26 @@ sogetopt1(struct socket *so, struct sock | |||
1945 | break; | 1942 | break; | |
1946 | 1943 | |||
1947 | case SO_USELOOPBACK: | 1944 | case SO_USELOOPBACK: | |
1948 | case SO_DONTROUTE: | 1945 | case SO_DONTROUTE: | |
1949 | case SO_DEBUG: | 1946 | case SO_DEBUG: | |
1950 | case SO_KEEPALIVE: | 1947 | case SO_KEEPALIVE: | |
1951 | case SO_REUSEADDR: | 1948 | case SO_REUSEADDR: | |
1952 | case SO_REUSEPORT: | 1949 | case SO_REUSEPORT: | |
1953 | case SO_BROADCAST: | 1950 | case SO_BROADCAST: | |
1954 | case SO_OOBINLINE: | 1951 | case SO_OOBINLINE: | |
1955 | case SO_TIMESTAMP: | 1952 | case SO_TIMESTAMP: | |
1956 | case SO_NOSIGPIPE: | 1953 | case SO_NOSIGPIPE: | |
1957 | case SO_RERROR: | 1954 | case SO_RERROR: | |
1958 | #ifdef SO_OTIMESTAMP | |||
1959 | case SO_OTIMESTAMP: | |||
1960 | #endif | |||
1961 | case SO_ACCEPTCONN: | 1955 | case SO_ACCEPTCONN: | |
1962 | error = sockopt_setint(sopt, (so->so_options & opt) ? 1 : 0); | 1956 | error = sockopt_setint(sopt, (so->so_options & opt) ? 1 : 0); | |
1963 | break; | 1957 | break; | |
1964 | 1958 | |||
1965 | case SO_TYPE: | 1959 | case SO_TYPE: | |
1966 | error = sockopt_setint(sopt, so->so_type); | 1960 | error = sockopt_setint(sopt, so->so_type); | |
1967 | break; | 1961 | break; | |
1968 | 1962 | |||
1969 | case SO_ERROR: | 1963 | case SO_ERROR: | |
1970 | if (so->so_error == 0) { | 1964 | if (so->so_error == 0) { | |
1971 | so->so_error = so->so_rerror; | 1965 | so->so_error = so->so_rerror; | |
1972 | so->so_rerror = 0; | 1966 | so->so_rerror = 0; | |
1973 | } | 1967 | } | |
@@ -1981,59 +1975,46 @@ sogetopt1(struct socket *so, struct sock | @@ -1981,59 +1975,46 @@ sogetopt1(struct socket *so, struct sock | |||
1981 | 1975 | |||
1982 | case SO_RCVBUF: | 1976 | case SO_RCVBUF: | |
1983 | error = sockopt_setint(sopt, so->so_rcv.sb_hiwat); | 1977 | error = sockopt_setint(sopt, so->so_rcv.sb_hiwat); | |
1984 | break; | 1978 | break; | |
1985 | 1979 | |||
1986 | case SO_SNDLOWAT: | 1980 | case SO_SNDLOWAT: | |
1987 | error = sockopt_setint(sopt, so->so_snd.sb_lowat); | 1981 | error = sockopt_setint(sopt, so->so_snd.sb_lowat); | |
1988 | break; | 1982 | break; | |
1989 | 1983 | |||
1990 | case SO_RCVLOWAT: | 1984 | case SO_RCVLOWAT: | |
1991 | error = sockopt_setint(sopt, so->so_rcv.sb_lowat); | 1985 | error = sockopt_setint(sopt, so->so_rcv.sb_lowat); | |
1992 | break; | 1986 | break; | |
1993 | 1987 | |||
1994 | #ifdef COMPAT_50 | |||
1995 | case SO_OSNDTIMEO: | |||
1996 | case SO_ORCVTIMEO: { | |||
1997 | struct timeval50 otv; | |||
1998 | ||||
1999 | optval = (opt == SO_OSNDTIMEO ? | |||
2000 | so->so_snd.sb_timeo : so->so_rcv.sb_timeo); | |||
2001 | ||||
2002 | otv.tv_sec = optval / hz; | |||
2003 | otv.tv_usec = (optval % hz) * tick; | |||
2004 | ||||
2005 | error = sockopt_set(sopt, &otv, sizeof(otv)); | |||
2006 | break; | |||
2007 | } | |||
2008 | #endif /* COMPAT_50 */ | |||
2009 | ||||
2010 | case SO_SNDTIMEO: | 1988 | case SO_SNDTIMEO: | |
2011 | case SO_RCVTIMEO: | 1989 | case SO_RCVTIMEO: | |
2012 | optval = (opt == SO_SNDTIMEO ? | 1990 | optval = (opt == SO_SNDTIMEO ? | |
2013 | so->so_snd.sb_timeo : so->so_rcv.sb_timeo); | 1991 | so->so_snd.sb_timeo : so->so_rcv.sb_timeo); | |
2014 | 1992 | |||
2015 | tv.tv_sec = optval / hz; | 1993 | tv.tv_sec = optval / hz; | |
2016 | tv.tv_usec = (optval % hz) * tick; | 1994 | tv.tv_usec = (optval % hz) * tick; | |
2017 | 1995 | |||
2018 | error = sockopt_set(sopt, &tv, sizeof(tv)); | 1996 | error = sockopt_set(sopt, &tv, sizeof(tv)); | |
2019 | break; | 1997 | break; | |
2020 | 1998 | |||
2021 | case SO_OVERFLOWED: | 1999 | case SO_OVERFLOWED: | |
2022 | error = sockopt_setint(sopt, so->so_rcv.sb_overflowed); | 2000 | error = sockopt_setint(sopt, so->so_rcv.sb_overflowed); | |
2023 | break; | 2001 | break; | |
2024 | 2002 | |||
2025 | default: | 2003 | default: | |
2026 | error = ENOPROTOOPT; | 2004 | MODULE_HOOK_CALL(uipc_socket_50_getopt1_hook, | |
2005 | (opt, so, sopt, &tv), enosys(), error); | |||
2006 | if (error) | |||
2007 | error = ENOPROTOOPT; | |||
2027 | break; | 2008 | break; | |
2028 | } | 2009 | } | |
2029 | 2010 | |||
2030 | return error; | 2011 | return error; | |
2031 | } | 2012 | } | |
2032 | 2013 | |||
2033 | int | 2014 | int | |
2034 | sogetopt(struct socket *so, struct sockopt *sopt) | 2015 | sogetopt(struct socket *so, struct sockopt *sopt) | |
2035 | { | 2016 | { | |
2036 | int error; | 2017 | int error; | |
2037 | 2018 | |||
2038 | solock(so); | 2019 | solock(so); | |
2039 | if (sopt->sopt_level != SOL_SOCKET) { | 2020 | if (sopt->sopt_level != SOL_SOCKET) { | |
@@ -2431,39 +2412,33 @@ sopoll(struct socket *so, int events) | @@ -2431,39 +2412,33 @@ sopoll(struct socket *so, int events) | |||
2431 | selrecord(curlwp, &so->so_snd.sb_sel); | 2412 | selrecord(curlwp, &so->so_snd.sb_sel); | |
2432 | so->so_snd.sb_flags |= SB_NOTIFY; | 2413 | so->so_snd.sb_flags |= SB_NOTIFY; | |
2433 | } | 2414 | } | |
2434 | } | 2415 | } | |
2435 | sounlock(so); | 2416 | sounlock(so); | |
2436 | 2417 | |||
2437 | return revents; | 2418 | return revents; | |
2438 | } | 2419 | } | |
2439 | 2420 | |||
2440 | struct mbuf ** | 2421 | struct mbuf ** | |
2441 | sbsavetimestamp(int opt, struct mbuf **mp) | 2422 | sbsavetimestamp(int opt, struct mbuf **mp) | |
2442 | { | 2423 | { | |
2443 | struct timeval tv; | 2424 | struct timeval tv; | |
2425 | int error; | |||
2426 | ||||
2444 | microtime(&tv); | 2427 | microtime(&tv); | |
2445 | 2428 | |||
2446 | #ifdef SO_OTIMESTAMP | 2429 | MODULE_HOOK_CALL(uipc_socket_50_sbts_hook, (opt, mp), enosys(), error); | |
2447 | if (opt & SO_OTIMESTAMP) { | 2430 | if (error == 0) | |
2448 | struct timeval50 tv50; | 2431 | return mp; | |
2449 | ||||
2450 | timeval_to_timeval50(&tv, &tv50); | |||
2451 | *mp = sbcreatecontrol(&tv50, sizeof(tv50), | |||
2452 | SCM_OTIMESTAMP, SOL_SOCKET); | |||
2453 | if (*mp) | |||
2454 | mp = &(*mp)->m_next; | |||
2455 | } else | |||
2456 | #endif | |||
2457 | 2432 | |||
2458 | if (opt & SO_TIMESTAMP) { | 2433 | if (opt & SO_TIMESTAMP) { | |
2459 | *mp = sbcreatecontrol(&tv, sizeof(tv), | 2434 | *mp = sbcreatecontrol(&tv, sizeof(tv), | |
2460 | SCM_TIMESTAMP, SOL_SOCKET); | 2435 | SCM_TIMESTAMP, SOL_SOCKET); | |
2461 | if (*mp) | 2436 | if (*mp) | |
2462 | mp = &(*mp)->m_next; | 2437 | mp = &(*mp)->m_next; | |
2463 | } | 2438 | } | |
2464 | return mp; | 2439 | return mp; | |
2465 | } | 2440 | } | |
2466 | 2441 | |||
2467 | 2442 | |||
2468 | #include <sys/sysctl.h> | 2443 | #include <sys/sysctl.h> | |
2469 | 2444 |
--- src/sys/modules/compat_50/Makefile 2019/02/17 04:05:45 1.3
+++ src/sys/modules/compat_50/Makefile 2019/04/15 02:07:11 1.4
@@ -1,27 +1,28 @@ | @@ -1,27 +1,28 @@ | |||
1 | # $NetBSD: Makefile,v 1.3 2019/02/17 04:05:45 rin Exp $ | 1 | # $NetBSD: Makefile,v 1.4 2019/04/15 02:07:11 pgoyette Exp $ | |
2 | 2 | |||
3 | .include "../Makefile.inc" | 3 | .include "../Makefile.inc" | |
4 | 4 | |||
5 | .PATH: ${S}/compat/common | 5 | .PATH: ${S}/compat/common | |
6 | 6 | |||
7 | KMOD= compat_50 | 7 | KMOD= compat_50 | |
8 | 8 | |||
9 | CPPFLAGS+= -DCOMPAT_50 -DCOMPAT_60 -DCOMPAT_70 -DCOMPAT_80 | 9 | CPPFLAGS+= -DCOMPAT_50 -DCOMPAT_60 -DCOMPAT_70 -DCOMPAT_80 | |
10 | 10 | |||
11 | SRCS+= compat_50_mod.c | 11 | SRCS+= compat_50_mod.c | |
12 | SRCS+= kern_50.c kern_time_50.c kern_select_50.c | 12 | SRCS+= kern_50.c kern_time_50.c kern_select_50.c | |
13 | SRCS+= vfs_syscalls_50.c uipc_syscalls_50.c uvm_50.c | 13 | SRCS+= vfs_syscalls_50.c uipc_syscalls_50.c uvm_50.c | |
14 | SRCS+= rndpseudo_50.c clockctl_50.c if_spppsubr50.c | 14 | SRCS+= rndpseudo_50.c clockctl_50.c if_spppsubr50.c | |
15 | SRCS+= kern_uipc_socket_50.c | |||
15 | 16 | |||
16 | CPPFLAGS+= -DINET -DINET6 | 17 | CPPFLAGS+= -DINET -DINET6 | |
17 | # XXX someday we'll need to add | 18 | # XXX someday we'll need to add | |
18 | #CPPFLAGS+= -DSCTP -DNET_MPSAFE | 19 | #CPPFLAGS+= -DSCTP -DNET_MPSAFE | |
19 | 20 | |||
20 | SRCS+= rtsock_50.c | 21 | SRCS+= rtsock_50.c | |
21 | 22 | |||
22 | .PATH: ${S}/fs/puffs | 23 | .PATH: ${S}/fs/puffs | |
23 | 24 | |||
24 | SRCS+= puffs_compat.c | 25 | SRCS+= puffs_compat.c | |
25 | 26 | |||
26 | .PATH: ${S}/dev/wscons | 27 | .PATH: ${S}/dev/wscons | |
27 | 28 |
--- src/sys/sys/compat_stub.h 2019/02/05 23:28:02 1.11
+++ src/sys/sys/compat_stub.h 2019/04/15 02:07:11 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: compat_stub.h,v 1.11 2019/02/05 23:28:02 christos Exp $ */ | 1 | /* $NetBSD: compat_stub.h,v 1.12 2019/04/15 02:07:11 pgoyette Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2018 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2018 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 Paul Goyette | 8 | * by Paul Goyette | |
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. | |
@@ -211,26 +211,39 @@ MODULE_HOOK(if43_cvtcmd_20_hook, int, (u | @@ -211,26 +211,39 @@ MODULE_HOOK(if43_cvtcmd_20_hook, int, (u | |||
211 | */ | 211 | */ | |
212 | struct tty; | 212 | struct tty; | |
213 | 213 | |||
214 | MODULE_HOOK(tty_ttioctl_43_hook, int, | 214 | MODULE_HOOK(tty_ttioctl_43_hook, int, | |
215 | (struct tty *, u_long, void *, int, struct lwp *)); | 215 | (struct tty *, u_long, void *, int, struct lwp *)); | |
216 | 216 | |||
217 | /* | 217 | /* | |
218 | * uipc_syscalls_40 compatibility | 218 | * uipc_syscalls_40 compatibility | |
219 | */ | 219 | */ | |
220 | 220 | |||
221 | MODULE_HOOK(uipc_syscalls_40_hook, int, (u_long, void *)); | 221 | MODULE_HOOK(uipc_syscalls_40_hook, int, (u_long, void *)); | |
222 | 222 | |||
223 | /* | 223 | /* | |
224 | * uipc_socket_50 compatibility | |||
225 | */ | |||
226 | struct sockopt; | |||
227 | struct timeval; | |||
228 | struct mbuf; | |||
229 | ||||
230 | MODULE_HOOK(uipc_socket_50_setopt1_hook, int, | |||
231 | (int, struct socket *, const struct sockopt *, struct timeval *)); | |||
232 | MODULE_HOOK(uipc_socket_50_getopt1_hook, int, | |||
233 | (int, struct socket *, struct sockopt *, struct timeval *)); | |||
234 | MODULE_HOOK(uipc_socket_50_sbts_hook, int, (int, struct mbuf **)); | |||
235 | ||||
236 | /* | |||
224 | * uipc_syscalls_50 compatibility | 237 | * uipc_syscalls_50 compatibility | |
225 | */ | 238 | */ | |
226 | 239 | |||
227 | MODULE_HOOK(uipc_syscalls_50_hook, int, (struct lwp *, u_long, void *)); | 240 | MODULE_HOOK(uipc_syscalls_50_hook, int, (struct lwp *, u_long, void *)); | |
228 | 241 | |||
229 | /* | 242 | /* | |
230 | * rtsock 14 compatibility | 243 | * rtsock 14 compatibility | |
231 | */ | 244 | */ | |
232 | struct ifnet; | 245 | struct ifnet; | |
233 | struct rt_walkarg; | 246 | struct rt_walkarg; | |
234 | struct rt_addrinfo; | 247 | struct rt_addrinfo; | |
235 | MODULE_HOOK(rtsock_oifmsg_14_hook, void, (struct ifnet *)); | 248 | MODULE_HOOK(rtsock_oifmsg_14_hook, void, (struct ifnet *)); | |
236 | MODULE_HOOK(rtsock_iflist_14_hook, int, | 249 | MODULE_HOOK(rtsock_iflist_14_hook, int, | |
@@ -301,27 +314,26 @@ MODULE_HOOK(tty_ttioctl_60_hook, int, | @@ -301,27 +314,26 @@ MODULE_HOOK(tty_ttioctl_60_hook, int, | |||
301 | (struct tty *, u_long, void *, int, struct lwp *)); | 314 | (struct tty *, u_long, void *, int, struct lwp *)); | |
302 | MODULE_HOOK(tty_ptmioctl_60_hook, int, | 315 | MODULE_HOOK(tty_ptmioctl_60_hook, int, | |
303 | (dev_t, u_long, void *, int, struct lwp *)); | 316 | (dev_t, u_long, void *, int, struct lwp *)); | |
304 | 317 | |||
305 | /* | 318 | /* | |
306 | * Hook for compat_10 openat | 319 | * Hook for compat_10 openat | |
307 | */ | 320 | */ | |
308 | struct pathbuf; | 321 | struct pathbuf; | |
309 | MODULE_HOOK(vfs_openat_10_hook, int, (struct pathbuf **)); | 322 | MODULE_HOOK(vfs_openat_10_hook, int, (struct pathbuf **)); | |
310 | 323 | |||
311 | /* | 324 | /* | |
312 | * Hook for compat_70_unp_addsockcred | 325 | * Hook for compat_70_unp_addsockcred | |
313 | */ | 326 | */ | |
314 | struct mbuf; | |||
315 | MODULE_HOOK(uipc_unp_70_hook, struct mbuf *, | 327 | MODULE_HOOK(uipc_unp_70_hook, struct mbuf *, | |
316 | (struct lwp *, struct mbuf *)); | 328 | (struct lwp *, struct mbuf *)); | |
317 | 329 | |||
318 | /* | 330 | /* | |
319 | * Hook for sysvipc50 sysctl | 331 | * Hook for sysvipc50 sysctl | |
320 | */ | 332 | */ | |
321 | #include <sys/sysctl.h> | 333 | #include <sys/sysctl.h> | |
322 | MODULE_HOOK(sysvipc_sysctl_50_hook, int, (SYSCTLFN_PROTO)); | 334 | MODULE_HOOK(sysvipc_sysctl_50_hook, int, (SYSCTLFN_PROTO)); | |
323 | 335 | |||
324 | /* | 336 | /* | |
325 | * Hook for 32-bit machine name | 337 | * Hook for 32-bit machine name | |
326 | * | 338 | * | |
327 | * This probably would be better placed in compat/netbsd32/netbsd32_mod.c | 339 | * This probably would be better placed in compat/netbsd32/netbsd32_mod.c |