aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r--include/net/tcp.h88
1 files changed, 46 insertions, 42 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 0118ea999f67..f75a04d752cb 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -22,6 +22,7 @@
22 22
23#include <linux/list.h> 23#include <linux/list.h>
24#include <linux/tcp.h> 24#include <linux/tcp.h>
25#include <linux/bug.h>
25#include <linux/slab.h> 26#include <linux/slab.h>
26#include <linux/cache.h> 27#include <linux/cache.h>
27#include <linux/percpu.h> 28#include <linux/percpu.h>
@@ -273,6 +274,14 @@ static inline int between(__u32 seq1, __u32 seq2, __u32 seq3)
273 return seq3 - seq2 >= seq1 - seq2; 274 return seq3 - seq2 >= seq1 - seq2;
274} 275}
275 276
277static inline bool tcp_out_of_memory(struct sock *sk)
278{
279 if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF &&
280 sk_memory_allocated(sk) > sk_prot_mem_limits(sk, 2))
281 return true;
282 return false;
283}
284
276static inline bool tcp_too_many_orphans(struct sock *sk, int shift) 285static inline bool tcp_too_many_orphans(struct sock *sk, int shift)
277{ 286{
278 struct percpu_counter *ocp = sk->sk_prot->orphan_count; 287 struct percpu_counter *ocp = sk->sk_prot->orphan_count;
@@ -283,13 +292,11 @@ static inline bool tcp_too_many_orphans(struct sock *sk, int shift)
283 if (orphans << shift > sysctl_tcp_max_orphans) 292 if (orphans << shift > sysctl_tcp_max_orphans)
284 return true; 293 return true;
285 } 294 }
286
287 if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF &&
288 sk_memory_allocated(sk) > sk_prot_mem_limits(sk, 2))
289 return true;
290 return false; 295 return false;
291} 296}
292 297
298extern bool tcp_check_oom(struct sock *sk, int shift);
299
293/* syncookies: remember time of last synqueue overflow */ 300/* syncookies: remember time of last synqueue overflow */
294static inline void tcp_synq_overflow(struct sock *sk) 301static inline void tcp_synq_overflow(struct sock *sk)
295{ 302{
@@ -311,6 +318,8 @@ extern struct proto tcp_prot;
311#define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val) 318#define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val)
312#define TCP_ADD_STATS(net, field, val) SNMP_ADD_STATS((net)->mib.tcp_statistics, field, val) 319#define TCP_ADD_STATS(net, field, val) SNMP_ADD_STATS((net)->mib.tcp_statistics, field, val)
313 320
321extern void tcp_init_mem(struct net *net);
322
314extern void tcp_v4_err(struct sk_buff *skb, u32); 323extern void tcp_v4_err(struct sk_buff *skb, u32);
315 324
316extern void tcp_shutdown (struct sock *sk, int how); 325extern void tcp_shutdown (struct sock *sk, int how);
@@ -1130,35 +1139,27 @@ static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp)
1130/* MD5 Signature */ 1139/* MD5 Signature */
1131struct crypto_hash; 1140struct crypto_hash;
1132 1141
1142union tcp_md5_addr {
1143 struct in_addr a4;
1144#if IS_ENABLED(CONFIG_IPV6)
1145 struct in6_addr a6;
1146#endif
1147};
1148
1133/* - key database */ 1149/* - key database */
1134struct tcp_md5sig_key { 1150struct tcp_md5sig_key {
1135 u8 *key; 1151 struct hlist_node node;
1136 u8 keylen; 1152 u8 keylen;
1137}; 1153 u8 family; /* AF_INET or AF_INET6 */
1138 1154 union tcp_md5_addr addr;
1139struct tcp4_md5sig_key { 1155 u8 key[TCP_MD5SIG_MAXKEYLEN];
1140 struct tcp_md5sig_key base; 1156 struct rcu_head rcu;
1141 __be32 addr;
1142};
1143
1144struct tcp6_md5sig_key {
1145 struct tcp_md5sig_key base;
1146#if 0
1147 u32 scope_id; /* XXX */
1148#endif
1149 struct in6_addr addr;
1150}; 1157};
1151 1158
1152/* - sock block */ 1159/* - sock block */
1153struct tcp_md5sig_info { 1160struct tcp_md5sig_info {
1154 struct tcp4_md5sig_key *keys4; 1161 struct hlist_head head;
1155#if IS_ENABLED(CONFIG_IPV6) 1162 struct rcu_head rcu;
1156 struct tcp6_md5sig_key *keys6;
1157 u32 entries6;
1158 u32 alloced6;
1159#endif
1160 u32 entries4;
1161 u32 alloced4;
1162}; 1163};
1163 1164
1164/* - pseudo header */ 1165/* - pseudo header */
@@ -1195,19 +1196,25 @@ extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key,
1195 const struct sock *sk, 1196 const struct sock *sk,
1196 const struct request_sock *req, 1197 const struct request_sock *req,
1197 const struct sk_buff *skb); 1198 const struct sk_buff *skb);
1198extern struct tcp_md5sig_key * tcp_v4_md5_lookup(struct sock *sk, 1199extern int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
1199 struct sock *addr_sk); 1200 int family, const u8 *newkey,
1200extern int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, u8 *newkey, 1201 u8 newkeylen, gfp_t gfp);
1201 u8 newkeylen); 1202extern int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr,
1202extern int tcp_v4_md5_do_del(struct sock *sk, __be32 addr); 1203 int family);
1204extern struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk,
1205 struct sock *addr_sk);
1203 1206
1204#ifdef CONFIG_TCP_MD5SIG 1207#ifdef CONFIG_TCP_MD5SIG
1205#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_keylen ? \ 1208extern struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
1206 &(struct tcp_md5sig_key) { \ 1209 const union tcp_md5_addr *addr, int family);
1207 .key = (twsk)->tw_md5_key, \ 1210#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_key)
1208 .keylen = (twsk)->tw_md5_keylen, \
1209 } : NULL)
1210#else 1211#else
1212static inline struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
1213 const union tcp_md5_addr *addr,
1214 int family)
1215{
1216 return NULL;
1217}
1211#define tcp_twsk_md5_key(twsk) NULL 1218#define tcp_twsk_md5_key(twsk) NULL
1212#endif 1219#endif
1213 1220
@@ -1356,8 +1363,9 @@ static inline void tcp_push_pending_frames(struct sock *sk)
1356 } 1363 }
1357} 1364}
1358 1365
1359/* Start sequence of the highest skb with SACKed bit, valid only if 1366/* Start sequence of the skb just after the highest skb with SACKed
1360 * sacked > 0 or when the caller has ensured validity by itself. 1367 * bit, valid only if sacked_out > 0 or when the caller has ensured
1368 * validity by itself.
1361 */ 1369 */
1362static inline u32 tcp_highest_sack_seq(struct tcp_sock *tp) 1370static inline u32 tcp_highest_sack_seq(struct tcp_sock *tp)
1363{ 1371{
@@ -1462,10 +1470,6 @@ struct tcp_sock_af_ops {
1462 const struct sock *sk, 1470 const struct sock *sk,
1463 const struct request_sock *req, 1471 const struct request_sock *req,
1464 const struct sk_buff *skb); 1472 const struct sk_buff *skb);
1465 int (*md5_add) (struct sock *sk,
1466 struct sock *addr_sk,
1467 u8 *newkey,
1468 u8 len);
1469 int (*md5_parse) (struct sock *sk, 1473 int (*md5_parse) (struct sock *sk,
1470 char __user *optval, 1474 char __user *optval,
1471 int optlen); 1475 int optlen);