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.h62
1 files changed, 54 insertions, 8 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index cd3ecda9386a..770917d0caa7 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -36,6 +36,7 @@
36#include <net/inet_hashtables.h> 36#include <net/inet_hashtables.h>
37#include <net/checksum.h> 37#include <net/checksum.h>
38#include <net/request_sock.h> 38#include <net/request_sock.h>
39#include <net/sock_reuseport.h>
39#include <net/sock.h> 40#include <net/sock.h>
40#include <net/snmp.h> 41#include <net/snmp.h>
41#include <net/ip.h> 42#include <net/ip.h>
@@ -473,19 +474,45 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb);
473 */ 474 */
474static inline void tcp_synq_overflow(const struct sock *sk) 475static inline void tcp_synq_overflow(const struct sock *sk)
475{ 476{
476 unsigned long last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp; 477 unsigned int last_overflow;
477 unsigned long now = jiffies; 478 unsigned int now = jiffies;
478 479
479 if (time_after(now, last_overflow + HZ)) 480 if (sk->sk_reuseport) {
481 struct sock_reuseport *reuse;
482
483 reuse = rcu_dereference(sk->sk_reuseport_cb);
484 if (likely(reuse)) {
485 last_overflow = READ_ONCE(reuse->synq_overflow_ts);
486 if (time_after32(now, last_overflow + HZ))
487 WRITE_ONCE(reuse->synq_overflow_ts, now);
488 return;
489 }
490 }
491
492 last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp;
493 if (time_after32(now, last_overflow + HZ))
480 tcp_sk(sk)->rx_opt.ts_recent_stamp = now; 494 tcp_sk(sk)->rx_opt.ts_recent_stamp = now;
481} 495}
482 496
483/* syncookies: no recent synqueue overflow on this listening socket? */ 497/* syncookies: no recent synqueue overflow on this listening socket? */
484static inline bool tcp_synq_no_recent_overflow(const struct sock *sk) 498static inline bool tcp_synq_no_recent_overflow(const struct sock *sk)
485{ 499{
486 unsigned long last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp; 500 unsigned int last_overflow;
501 unsigned int now = jiffies;
487 502
488 return time_after(jiffies, last_overflow + TCP_SYNCOOKIE_VALID); 503 if (sk->sk_reuseport) {
504 struct sock_reuseport *reuse;
505
506 reuse = rcu_dereference(sk->sk_reuseport_cb);
507 if (likely(reuse)) {
508 last_overflow = READ_ONCE(reuse->synq_overflow_ts);
509 return time_after32(now, last_overflow +
510 TCP_SYNCOOKIE_VALID);
511 }
512 }
513
514 last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp;
515 return time_after32(now, last_overflow + TCP_SYNCOOKIE_VALID);
489} 516}
490 517
491static inline u32 tcp_cookie_time(void) 518static inline u32 tcp_cookie_time(void)
@@ -963,6 +990,8 @@ struct rate_sample {
963 u32 prior_delivered; /* tp->delivered at "prior_mstamp" */ 990 u32 prior_delivered; /* tp->delivered at "prior_mstamp" */
964 s32 delivered; /* number of packets delivered over interval */ 991 s32 delivered; /* number of packets delivered over interval */
965 long interval_us; /* time for tp->delivered to incr "delivered" */ 992 long interval_us; /* time for tp->delivered to incr "delivered" */
993 u32 snd_interval_us; /* snd interval for delivered packets */
994 u32 rcv_interval_us; /* rcv interval for delivered packets */
966 long rtt_us; /* RTT of last (S)ACKed packet (or -1) */ 995 long rtt_us; /* RTT of last (S)ACKed packet (or -1) */
967 int losses; /* number of packets marked lost upon ACK */ 996 int losses; /* number of packets marked lost upon ACK */
968 u32 acked_sacked; /* number of packets newly (S)ACKed upon ACK */ 997 u32 acked_sacked; /* number of packets newly (S)ACKed upon ACK */
@@ -1194,6 +1223,17 @@ static inline bool tcp_is_cwnd_limited(const struct sock *sk)
1194 return tp->is_cwnd_limited; 1223 return tp->is_cwnd_limited;
1195} 1224}
1196 1225
1226/* BBR congestion control needs pacing.
1227 * Same remark for SO_MAX_PACING_RATE.
1228 * sch_fq packet scheduler is efficiently handling pacing,
1229 * but is not always installed/used.
1230 * Return true if TCP stack should pace packets itself.
1231 */
1232static inline bool tcp_needs_internal_pacing(const struct sock *sk)
1233{
1234 return smp_load_acquire(&sk->sk_pacing_status) == SK_PACING_NEEDED;
1235}
1236
1197/* Something is really bad, we could not queue an additional packet, 1237/* Something is really bad, we could not queue an additional packet,
1198 * because qdisc is full or receiver sent a 0 window. 1238 * because qdisc is full or receiver sent a 0 window.
1199 * We do not want to add fuel to the fire, or abort too early, 1239 * We do not want to add fuel to the fire, or abort too early,
@@ -1371,7 +1411,8 @@ static inline bool tcp_paws_check(const struct tcp_options_received *rx_opt,
1371{ 1411{
1372 if ((s32)(rx_opt->ts_recent - rx_opt->rcv_tsval) <= paws_win) 1412 if ((s32)(rx_opt->ts_recent - rx_opt->rcv_tsval) <= paws_win)
1373 return true; 1413 return true;
1374 if (unlikely(get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS)) 1414 if (unlikely(!time_before32(ktime_get_seconds(),
1415 rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS)))
1375 return true; 1416 return true;
1376 /* 1417 /*
1377 * Some OSes send SYN and SYNACK messages with tsval=0 tsecr=0, 1418 * Some OSes send SYN and SYNACK messages with tsval=0 tsecr=0,
@@ -1401,7 +1442,8 @@ static inline bool tcp_paws_reject(const struct tcp_options_received *rx_opt,
1401 1442
1402 However, we can relax time bounds for RST segments to MSL. 1443 However, we can relax time bounds for RST segments to MSL.
1403 */ 1444 */
1404 if (rst && get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_MSL) 1445 if (rst && !time_before32(ktime_get_seconds(),
1446 rx_opt->ts_recent_stamp + TCP_PAWS_MSL))
1405 return false; 1447 return false;
1406 return true; 1448 return true;
1407} 1449}
@@ -1787,7 +1829,7 @@ void tcp_v4_destroy_sock(struct sock *sk);
1787 1829
1788struct sk_buff *tcp_gso_segment(struct sk_buff *skb, 1830struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
1789 netdev_features_t features); 1831 netdev_features_t features);
1790struct sk_buff **tcp_gro_receive(struct sk_buff **head, struct sk_buff *skb); 1832struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb);
1791int tcp_gro_complete(struct sk_buff *skb); 1833int tcp_gro_complete(struct sk_buff *skb);
1792 1834
1793void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr, __be32 daddr); 1835void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr, __be32 daddr);
@@ -2023,6 +2065,10 @@ int tcp_set_ulp_id(struct sock *sk, const int ulp);
2023void tcp_get_available_ulp(char *buf, size_t len); 2065void tcp_get_available_ulp(char *buf, size_t len);
2024void tcp_cleanup_ulp(struct sock *sk); 2066void tcp_cleanup_ulp(struct sock *sk);
2025 2067
2068#define MODULE_ALIAS_TCP_ULP(name) \
2069 __MODULE_INFO(alias, alias_userspace, name); \
2070 __MODULE_INFO(alias, alias_tcp_ulp, "tcp-ulp-" name)
2071
2026/* Call BPF_SOCK_OPS program that returns an int. If the return value 2072/* Call BPF_SOCK_OPS program that returns an int. If the return value
2027 * is < 0, then the BPF op failed (for example if the loaded BPF 2073 * is < 0, then the BPF op failed (for example if the loaded BPF
2028 * program does not support the chosen operation or there is no BPF 2074 * program does not support the chosen operation or there is no BPF