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.h86
1 files changed, 44 insertions, 42 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index d49db0113a06..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{
@@ -1132,35 +1139,27 @@ static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp)
1132/* MD5 Signature */ 1139/* MD5 Signature */
1133struct crypto_hash; 1140struct crypto_hash;
1134 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
1135/* - key database */ 1149/* - key database */
1136struct tcp_md5sig_key { 1150struct tcp_md5sig_key {
1137 u8 *key; 1151 struct hlist_node node;
1138 u8 keylen; 1152 u8 keylen;
1139}; 1153 u8 family; /* AF_INET or AF_INET6 */
1140 1154 union tcp_md5_addr addr;
1141struct tcp4_md5sig_key { 1155 u8 key[TCP_MD5SIG_MAXKEYLEN];
1142 struct tcp_md5sig_key base; 1156 struct rcu_head rcu;
1143 __be32 addr;
1144};
1145
1146struct tcp6_md5sig_key {
1147 struct tcp_md5sig_key base;
1148#if 0
1149 u32 scope_id; /* XXX */
1150#endif
1151 struct in6_addr addr;
1152}; 1157};
1153 1158
1154/* - sock block */ 1159/* - sock block */
1155struct tcp_md5sig_info { 1160struct tcp_md5sig_info {
1156 struct tcp4_md5sig_key *keys4; 1161 struct hlist_head head;
1157#if IS_ENABLED(CONFIG_IPV6) 1162 struct rcu_head rcu;
1158 struct tcp6_md5sig_key *keys6;
1159 u32 entries6;
1160 u32 alloced6;
1161#endif
1162 u32 entries4;
1163 u32 alloced4;
1164}; 1163};
1165 1164
1166/* - pseudo header */ 1165/* - pseudo header */
@@ -1197,19 +1196,25 @@ extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key,
1197 const struct sock *sk, 1196 const struct sock *sk,
1198 const struct request_sock *req, 1197 const struct request_sock *req,
1199 const struct sk_buff *skb); 1198 const struct sk_buff *skb);
1200extern 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,
1201 struct sock *addr_sk); 1200 int family, const u8 *newkey,
1202extern int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, u8 *newkey, 1201 u8 newkeylen, gfp_t gfp);
1203 u8 newkeylen); 1202extern int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr,
1204extern 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);
1205 1206
1206#ifdef CONFIG_TCP_MD5SIG 1207#ifdef CONFIG_TCP_MD5SIG
1207#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_keylen ? \ 1208extern struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
1208 &(struct tcp_md5sig_key) { \ 1209 const union tcp_md5_addr *addr, int family);
1209 .key = (twsk)->tw_md5_key, \ 1210#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_key)
1210 .keylen = (twsk)->tw_md5_keylen, \
1211 } : NULL)
1212#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}
1213#define tcp_twsk_md5_key(twsk) NULL 1218#define tcp_twsk_md5_key(twsk) NULL
1214#endif 1219#endif
1215 1220
@@ -1358,8 +1363,9 @@ static inline void tcp_push_pending_frames(struct sock *sk)
1358 } 1363 }
1359} 1364}
1360 1365
1361/* 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
1362 * 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.
1363 */ 1369 */
1364static inline u32 tcp_highest_sack_seq(struct tcp_sock *tp) 1370static inline u32 tcp_highest_sack_seq(struct tcp_sock *tp)
1365{ 1371{
@@ -1464,10 +1470,6 @@ struct tcp_sock_af_ops {
1464 const struct sock *sk, 1470 const struct sock *sk,
1465 const struct request_sock *req, 1471 const struct request_sock *req,
1466 const struct sk_buff *skb); 1472 const struct sk_buff *skb);
1467 int (*md5_add) (struct sock *sk,
1468 struct sock *addr_sk,
1469 u8 *newkey,
1470 u8 len);
1471 int (*md5_parse) (struct sock *sk, 1473 int (*md5_parse) (struct sock *sk,
1472 char __user *optval, 1474 char __user *optval,
1473 int optlen); 1475 int optlen);