|
36 | 36 | #include <net/inet_hashtables.h>
|
37 | 37 | #include <net/checksum.h>
|
38 | 38 | #include <net/request_sock.h>
|
| 39 | +#include <net/sock_reuseport.h> |
39 | 40 | #include <net/sock.h>
|
40 | 41 | #include <net/snmp.h>
|
41 | 42 | #include <net/ip.h>
|
@@ -473,19 +474,44 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb);
|
473 | 474 | */
|
474 | 475 | static inline void tcp_synq_overflow(const struct sock *sk)
|
475 | 476 | {
|
476 |
| - unsigned int last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp; |
| 477 | + unsigned int last_overflow; |
477 | 478 | unsigned int now = jiffies;
|
478 | 479 |
|
| 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; |
479 | 493 | if (time_after32(now, last_overflow + HZ))
|
480 | 494 | tcp_sk(sk)->rx_opt.ts_recent_stamp = now;
|
481 | 495 | }
|
482 | 496 |
|
483 | 497 | /* syncookies: no recent synqueue overflow on this listening socket? */
|
484 | 498 | static inline bool tcp_synq_no_recent_overflow(const struct sock *sk)
|
485 | 499 | {
|
486 |
| - unsigned int last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp; |
| 500 | + unsigned int last_overflow; |
487 | 501 | unsigned int now = jiffies;
|
488 | 502 |
|
| 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; |
489 | 515 | return time_after32(now, last_overflow + TCP_SYNCOOKIE_VALID);
|
490 | 516 | }
|
491 | 517 |
|
|
0 commit comments