.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * NET An implementation of the SOCKET network access protocol. |
---|
3 | 4 | * This is the master header file for the Linux NET layer, |
---|
.. | .. |
---|
9 | 10 | * Authors: Orest Zborowski, <obz@Kodak.COM> |
---|
10 | 11 | * Ross Biro |
---|
11 | 12 | * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> |
---|
12 | | - * |
---|
13 | | - * This program is free software; you can redistribute it and/or |
---|
14 | | - * modify it under the terms of the GNU General Public License |
---|
15 | | - * as published by the Free Software Foundation; either version |
---|
16 | | - * 2 of the License, or (at your option) any later version. |
---|
17 | 13 | */ |
---|
18 | 14 | #ifndef _LINUX_NET_H |
---|
19 | 15 | #define _LINUX_NET_H |
---|
.. | .. |
---|
25 | 21 | #include <linux/rcupdate.h> |
---|
26 | 22 | #include <linux/once.h> |
---|
27 | 23 | #include <linux/fs.h> |
---|
| 24 | +#include <linux/mm.h> |
---|
| 25 | +#include <linux/sockptr.h> |
---|
28 | 26 | #include <linux/android_kabi.h> |
---|
29 | 27 | |
---|
30 | 28 | #include <uapi/linux/net.h> |
---|
.. | .. |
---|
121 | 119 | |
---|
122 | 120 | unsigned long flags; |
---|
123 | 121 | |
---|
124 | | - struct socket_wq *wq; |
---|
125 | | - |
---|
126 | 122 | struct file *file; |
---|
127 | 123 | struct sock *sk; |
---|
128 | 124 | const struct proto_ops *ops; |
---|
| 125 | + |
---|
| 126 | + struct socket_wq wq; |
---|
129 | 127 | }; |
---|
130 | 128 | |
---|
131 | 129 | struct vm_area_struct; |
---|
.. | .. |
---|
139 | 137 | |
---|
140 | 138 | struct proto_ops { |
---|
141 | 139 | int family; |
---|
| 140 | + unsigned int flags; // ANDROID - removed in 5.10.162, but remains to |
---|
| 141 | + // preserve ABI. It is not used anywhere. |
---|
142 | 142 | struct module *owner; |
---|
143 | 143 | int (*release) (struct socket *sock); |
---|
144 | 144 | int (*bind) (struct socket *sock, |
---|
.. | .. |
---|
162 | 162 | int (*compat_ioctl) (struct socket *sock, unsigned int cmd, |
---|
163 | 163 | unsigned long arg); |
---|
164 | 164 | #endif |
---|
| 165 | + int (*gettstamp) (struct socket *sock, void __user *userstamp, |
---|
| 166 | + bool timeval, bool time32); |
---|
165 | 167 | int (*listen) (struct socket *sock, int len); |
---|
166 | 168 | int (*shutdown) (struct socket *sock, int flags); |
---|
167 | 169 | int (*setsockopt)(struct socket *sock, int level, |
---|
168 | | - int optname, char __user *optval, unsigned int optlen); |
---|
| 170 | + int optname, sockptr_t optval, |
---|
| 171 | + unsigned int optlen); |
---|
169 | 172 | int (*getsockopt)(struct socket *sock, int level, |
---|
170 | 173 | int optname, char __user *optval, int __user *optlen); |
---|
171 | | -#ifdef CONFIG_COMPAT |
---|
172 | | - int (*compat_setsockopt)(struct socket *sock, int level, |
---|
173 | | - int optname, char __user *optval, unsigned int optlen); |
---|
174 | | - int (*compat_getsockopt)(struct socket *sock, int level, |
---|
175 | | - int optname, char __user *optval, int __user *optlen); |
---|
176 | | -#endif |
---|
| 174 | + void (*show_fdinfo)(struct seq_file *m, struct socket *sock); |
---|
177 | 175 | int (*sendmsg) (struct socket *sock, struct msghdr *m, |
---|
178 | 176 | size_t total_len); |
---|
179 | 177 | /* Notes for implementing recvmsg: |
---|
.. | .. |
---|
271 | 269 | net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__) |
---|
272 | 270 | #define net_info_ratelimited(fmt, ...) \ |
---|
273 | 271 | net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__) |
---|
274 | | -#if defined(CONFIG_DYNAMIC_DEBUG) |
---|
| 272 | +#if defined(CONFIG_DYNAMIC_DEBUG) || \ |
---|
| 273 | + (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) |
---|
275 | 274 | #define net_dbg_ratelimited(fmt, ...) \ |
---|
276 | 275 | do { \ |
---|
277 | 276 | DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ |
---|
278 | | - if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \ |
---|
| 277 | + if (DYNAMIC_DEBUG_BRANCH(descriptor) && \ |
---|
279 | 278 | net_ratelimit()) \ |
---|
280 | 279 | __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \ |
---|
281 | 280 | ##__VA_ARGS__); \ |
---|
.. | .. |
---|
296 | 295 | #define net_get_random_once_wait(buf, nbytes) \ |
---|
297 | 296 | get_random_once_wait((buf), (nbytes)) |
---|
298 | 297 | |
---|
| 298 | +/* |
---|
| 299 | + * E.g. XFS meta- & log-data is in slab pages, or bcache meta |
---|
| 300 | + * data pages, or other high order pages allocated by |
---|
| 301 | + * __get_free_pages() without __GFP_COMP, which have a page_count |
---|
| 302 | + * of 0 and/or have PageSlab() set. We cannot use send_page for |
---|
| 303 | + * those, as that does get_page(); put_page(); and would cause |
---|
| 304 | + * either a VM_BUG directly, or __page_cache_release a page that |
---|
| 305 | + * would actually still be referenced by someone, leading to some |
---|
| 306 | + * obscure delayed Oops somewhere else. |
---|
| 307 | + */ |
---|
| 308 | +static inline bool sendpage_ok(struct page *page) |
---|
| 309 | +{ |
---|
| 310 | + return !PageSlab(page) && page_count(page) >= 1; |
---|
| 311 | +} |
---|
| 312 | + |
---|
299 | 313 | int kernel_sendmsg(struct socket *sock, struct msghdr *msg, struct kvec *vec, |
---|
300 | 314 | size_t num, size_t len); |
---|
301 | 315 | int kernel_sendmsg_locked(struct sock *sk, struct msghdr *msg, |
---|
.. | .. |
---|
310 | 324 | int flags); |
---|
311 | 325 | int kernel_getsockname(struct socket *sock, struct sockaddr *addr); |
---|
312 | 326 | int kernel_getpeername(struct socket *sock, struct sockaddr *addr); |
---|
313 | | -int kernel_getsockopt(struct socket *sock, int level, int optname, char *optval, |
---|
314 | | - int *optlen); |
---|
315 | | -int kernel_setsockopt(struct socket *sock, int level, int optname, char *optval, |
---|
316 | | - unsigned int optlen); |
---|
317 | 327 | int kernel_sendpage(struct socket *sock, struct page *page, int offset, |
---|
318 | 328 | size_t size, int flags); |
---|
319 | 329 | int kernel_sendpage_locked(struct sock *sk, struct page *page, int offset, |
---|