hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/net.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * NET An implementation of the SOCKET network access protocol.
34 * This is the master header file for the Linux NET layer,
....@@ -9,11 +10,6 @@
910 * Authors: Orest Zborowski, <obz@Kodak.COM>
1011 * Ross Biro
1112 * 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.
1713 */
1814 #ifndef _LINUX_NET_H
1915 #define _LINUX_NET_H
....@@ -25,6 +21,8 @@
2521 #include <linux/rcupdate.h>
2622 #include <linux/once.h>
2723 #include <linux/fs.h>
24
+#include <linux/mm.h>
25
+#include <linux/sockptr.h>
2826 #include <linux/android_kabi.h>
2927
3028 #include <uapi/linux/net.h>
....@@ -121,11 +119,11 @@
121119
122120 unsigned long flags;
123121
124
- struct socket_wq *wq;
125
-
126122 struct file *file;
127123 struct sock *sk;
128124 const struct proto_ops *ops;
125
+
126
+ struct socket_wq wq;
129127 };
130128
131129 struct vm_area_struct;
....@@ -139,6 +137,8 @@
139137
140138 struct proto_ops {
141139 int family;
140
+ unsigned int flags; // ANDROID - removed in 5.10.162, but remains to
141
+ // preserve ABI. It is not used anywhere.
142142 struct module *owner;
143143 int (*release) (struct socket *sock);
144144 int (*bind) (struct socket *sock,
....@@ -162,18 +162,16 @@
162162 int (*compat_ioctl) (struct socket *sock, unsigned int cmd,
163163 unsigned long arg);
164164 #endif
165
+ int (*gettstamp) (struct socket *sock, void __user *userstamp,
166
+ bool timeval, bool time32);
165167 int (*listen) (struct socket *sock, int len);
166168 int (*shutdown) (struct socket *sock, int flags);
167169 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);
169172 int (*getsockopt)(struct socket *sock, int level,
170173 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);
177175 int (*sendmsg) (struct socket *sock, struct msghdr *m,
178176 size_t total_len);
179177 /* Notes for implementing recvmsg:
....@@ -271,11 +269,12 @@
271269 net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__)
272270 #define net_info_ratelimited(fmt, ...) \
273271 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))
275274 #define net_dbg_ratelimited(fmt, ...) \
276275 do { \
277276 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
278
- if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
277
+ if (DYNAMIC_DEBUG_BRANCH(descriptor) && \
279278 net_ratelimit()) \
280279 __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
281280 ##__VA_ARGS__); \
....@@ -296,6 +295,21 @@
296295 #define net_get_random_once_wait(buf, nbytes) \
297296 get_random_once_wait((buf), (nbytes))
298297
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
+
299313 int kernel_sendmsg(struct socket *sock, struct msghdr *msg, struct kvec *vec,
300314 size_t num, size_t len);
301315 int kernel_sendmsg_locked(struct sock *sk, struct msghdr *msg,
....@@ -310,10 +324,6 @@
310324 int flags);
311325 int kernel_getsockname(struct socket *sock, struct sockaddr *addr);
312326 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);
317327 int kernel_sendpage(struct socket *sock, struct page *page, int offset,
318328 size_t size, int flags);
319329 int kernel_sendpage_locked(struct sock *sk, struct page *page, int offset,