hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/include/net/inet_sock.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * INET An implementation of the TCP/IP protocol suite for the LINUX
34 * operating system. INET is implemented using the BSD Socket
....@@ -7,11 +8,6 @@
78 *
89 * Authors: Many, reorganised here by
910 * Arnaldo Carvalho de Melo <acme@mandriva.com>
10
- *
11
- * This program is free software; you can redistribute it and/or
12
- * modify it under the terms of the GNU General Public License
13
- * as published by the Free Software Foundation; either version
14
- * 2 of the License, or (at your option) any later version.
1511 */
1612 #ifndef _INET_SOCK_H
1713 #define _INET_SOCK_H
....@@ -56,7 +52,7 @@
5652 unsigned char router_alert;
5753 unsigned char cipso;
5854 unsigned char __pad2;
59
- unsigned char __data[0];
55
+ unsigned char __data[];
6056 };
6157
6258 struct ip_options_rcu {
....@@ -111,7 +107,8 @@
111107
112108 static inline u32 inet_request_mark(const struct sock *sk, struct sk_buff *skb)
113109 {
114
- if (!sk->sk_mark && sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept)
110
+ if (!sk->sk_mark &&
111
+ READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept))
115112 return skb->mark;
116113
117114 return sk->sk_mark;
....@@ -120,14 +117,47 @@
120117 static inline int inet_request_bound_dev_if(const struct sock *sk,
121118 struct sk_buff *skb)
122119 {
120
+ int bound_dev_if = READ_ONCE(sk->sk_bound_dev_if);
123121 #ifdef CONFIG_NET_L3_MASTER_DEV
124122 struct net *net = sock_net(sk);
125123
126
- if (!sk->sk_bound_dev_if && net->ipv4.sysctl_tcp_l3mdev_accept)
124
+ if (!bound_dev_if && READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept))
127125 return l3mdev_master_ifindex_by_index(net, skb->skb_iif);
128126 #endif
129127
130
- return sk->sk_bound_dev_if;
128
+ return bound_dev_if;
129
+}
130
+
131
+static inline int inet_sk_bound_l3mdev(const struct sock *sk)
132
+{
133
+#ifdef CONFIG_NET_L3_MASTER_DEV
134
+ struct net *net = sock_net(sk);
135
+
136
+ if (!READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept))
137
+ return l3mdev_master_ifindex_by_index(net,
138
+ sk->sk_bound_dev_if);
139
+#endif
140
+
141
+ return 0;
142
+}
143
+
144
+static inline bool inet_bound_dev_eq(bool l3mdev_accept, int bound_dev_if,
145
+ int dif, int sdif)
146
+{
147
+ if (!bound_dev_if)
148
+ return !sdif || l3mdev_accept;
149
+ return bound_dev_if == dif || bound_dev_if == sdif;
150
+}
151
+
152
+static inline bool inet_sk_bound_dev_eq(struct net *net, int bound_dev_if,
153
+ int dif, int sdif)
154
+{
155
+#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
156
+ return inet_bound_dev_eq(!!READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept),
157
+ bound_dev_if, dif, sdif);
158
+#else
159
+ return inet_bound_dev_eq(true, bound_dev_if, dif, sdif);
160
+#endif
131161 }
132162
133163 struct inet_cork {
....@@ -143,6 +173,7 @@
143173 char priority;
144174 __u16 gso_size;
145175 u64 transmit_time;
176
+ u32 mark;
146177 };
147178
148179 struct inet_cork_full {
....@@ -207,6 +238,7 @@
207238 mc_all:1,
208239 nodefrag:1;
209240 __u8 bind_address_no_port:1,
241
+ recverr_rfc4884:1,
210242 defer_connect:1; /* Indicates that fastopen_connect is set
211243 * and cookie exists so we defer connect
212244 * until first data frame is written
....@@ -277,13 +309,6 @@
277309 memcpy(inet_sk(sk_to) + 1, inet_sk(sk_from) + 1,
278310 sk_from->sk_prot->obj_size - ancestor_size);
279311 }
280
-#if !(IS_ENABLED(CONFIG_IPV6))
281
-static inline void inet_sk_copy_descendant(struct sock *sk_to,
282
- const struct sock *sk_from)
283
-{
284
- __inet_sk_copy_descendant(sk_to, sk_from, sizeof(struct inet_sock));
285
-}
286
-#endif
287312
288313 int inet_sk_rebuild_header(struct sock *sk);
289314
....@@ -357,7 +382,7 @@
357382 static inline bool inet_can_nonlocal_bind(struct net *net,
358383 struct inet_sock *inet)
359384 {
360
- return net->ipv4.sysctl_ip_nonlocal_bind ||
385
+ return READ_ONCE(net->ipv4.sysctl_ip_nonlocal_bind) ||
361386 inet->freebind || inet->transparent;
362387 }
363388