Page MenuHomeFreeBSD

D32938.id98357.diff
No OneTemporary

D32938.id98357.diff

Index: sys/netinet/tcp_stacks/rack.c
===================================================================
--- sys/netinet/tcp_stacks/rack.c
+++ sys/netinet/tcp_stacks/rack.c
@@ -11564,9 +11564,12 @@
return (0);
}
}
+
if ((thflags & TH_RST) ||
(tp->t_fin_is_rst && (thflags & TH_FIN)))
- return (ctf_process_rst(m, th, so, tp));
+ return (__ctf_process_rst(m, th, so, tp,
+ &rack->r_ctl.challenge_ack_ts,
+ &rack->r_ctl.challenge_ack_cnt));
/*
* RFC 1323 PAWS: If we have a timestamp reply on this segment and
* it's less than ts_recent, drop it.
@@ -11775,7 +11778,9 @@
if ((thflags & TH_RST) ||
(tp->t_fin_is_rst && (thflags & TH_FIN)))
- return (ctf_process_rst(m, th, so, tp));
+ return (__ctf_process_rst(m, th, so, tp,
+ &rack->r_ctl.challenge_ack_ts,
+ &rack->r_ctl.challenge_ack_cnt));
/*
* RFC5961 Section 4.2 Send challenge ACK for any SYN in
@@ -11875,7 +11880,9 @@
ctf_calc_rwin(so, tp);
if ((thflags & TH_RST) ||
(tp->t_fin_is_rst && (thflags & TH_FIN)))
- return (ctf_process_rst(m, th, so, tp));
+ return (__ctf_process_rst(m, th, so, tp,
+ &rack->r_ctl.challenge_ack_ts,
+ &rack->r_ctl.challenge_ack_cnt));
/*
* RFC5961 Section 4.2 Send challenge ACK for any SYN in
* synchronized state.
@@ -12004,7 +12011,9 @@
if ((thflags & TH_RST) ||
(tp->t_fin_is_rst && (thflags & TH_FIN)))
- return (ctf_process_rst(m, th, so, tp));
+ return (__ctf_process_rst(m, th, so, tp,
+ &rack->r_ctl.challenge_ack_ts,
+ &rack->r_ctl.challenge_ack_cnt));
/*
* RFC5961 Section 4.2 Send challenge ACK for any SYN in
* synchronized state.
@@ -12131,7 +12140,9 @@
if ((thflags & TH_RST) ||
(tp->t_fin_is_rst && (thflags & TH_FIN)))
- return (ctf_process_rst(m, th, so, tp));
+ return (__ctf_process_rst(m, th, so, tp,
+ &rack->r_ctl.challenge_ack_ts,
+ &rack->r_ctl.challenge_ack_cnt));
/*
* RFC5961 Section 4.2 Send challenge ACK for any SYN in
* synchronized state.
@@ -12244,7 +12255,9 @@
if ((thflags & TH_RST) ||
(tp->t_fin_is_rst && (thflags & TH_FIN)))
- return (ctf_process_rst(m, th, so, tp));
+ return (__ctf_process_rst(m, th, so, tp,
+ &rack->r_ctl.challenge_ack_ts,
+ &rack->r_ctl.challenge_ack_cnt));
/*
* RFC5961 Section 4.2 Send challenge ACK for any SYN in
* synchronized state.
@@ -12358,7 +12371,9 @@
/* Reset receive buffer auto scaling when not in bulk receive mode. */
if ((thflags & TH_RST) ||
(tp->t_fin_is_rst && (thflags & TH_FIN)))
- return (ctf_process_rst(m, th, so, tp));
+ return (__ctf_process_rst(m, th, so, tp,
+ &rack->r_ctl.challenge_ack_ts,
+ &rack->r_ctl.challenge_ack_cnt));
/*
* RFC5961 Section 4.2 Send challenge ACK for any SYN in
* synchronized state.
@@ -14566,7 +14581,8 @@
rack_check_probe_rtt(rack, us_cts);
}
rack_clear_rate_sample(rack);
- if (rack->forced_ack) {
+ if ((rack->forced_ack) &&
+ ((th->th_flags & TH_RST) == 0)) {
rack_handle_probe_response(rack, tiwin, us_cts);
}
/*
Index: sys/netinet/tcp_stacks/rack_bbr_common.h
===================================================================
--- sys/netinet/tcp_stacks/rack_bbr_common.h
+++ sys/netinet/tcp_stacks/rack_bbr_common.h
@@ -119,8 +119,9 @@
ctf_do_drop(struct mbuf *m, struct tcpcb *tp);
int
-ctf_process_rst(struct mbuf *m, struct tcphdr *th,
- struct socket *so, struct tcpcb *tp);
+__ctf_process_rst(struct mbuf *m, struct tcphdr *th,
+ struct socket *so, struct tcpcb *tp, uint32_t *ts, uint32_t *cnt);
+#define ctf_process_rst(m, t, s, p) __ctf_process_rst(m, t, s, p, NULL, NULL)
void
ctf_challenge_ack(struct mbuf *m, struct tcphdr *th,
Index: sys/netinet/tcp_stacks/rack_bbr_common.c
===================================================================
--- sys/netinet/tcp_stacks/rack_bbr_common.c
+++ sys/netinet/tcp_stacks/rack_bbr_common.c
@@ -764,7 +764,8 @@
}
int
-ctf_process_rst(struct mbuf *m, struct tcphdr *th, struct socket *so, struct tcpcb *tp)
+__ctf_process_rst(struct mbuf *m, struct tcphdr *th, struct socket *so,
+ struct tcpcb *tp, uint32_t *ts, uint32_t *cnt)
{
/*
* RFC5961 Section 3.2
@@ -811,11 +812,40 @@
dropped = 1;
ctf_do_drop(m, tp);
} else {
+ int send_challenge;
+
KMOD_TCPSTAT_INC(tcps_badrst);
- /* Send challenge ACK. */
- tcp_respond(tp, mtod(m, void *), th, m,
- tp->rcv_nxt, tp->snd_nxt, TH_ACK);
- tp->last_ack_sent = tp->rcv_nxt;
+ if ((ts != NULL) && (cnt != NULL) &&
+ (tcp_ack_war_time_window > 0) &&
+ (tcp_ack_war_cnt > 0)) {
+ /* We are possibly preventing an ack-rst war prevention */
+ uint32_t cts;
+
+ /*
+ * We use a msec tick here which gives us
+ * roughly 49 days. We don't need the
+ * precision of a microsecond timestamp which
+ * would only give us hours.
+ */
+ cts = tcp_ts_getticks();
+ if (TSTMP_LT((*ts), cts)) {
+ /* Timestamp is in the past */
+ *cnt = 0;
+ *ts = (cts + tcp_ack_war_time_window);
+ }
+ if (*cnt < tcp_ack_war_cnt) {
+ *cnt = (*cnt + 1);
+ send_challenge = 1;
+ } else
+ send_challenge = 0;
+ } else
+ send_challenge = 1;
+ if (send_challenge) {
+ /* Send challenge ACK. */
+ tcp_respond(tp, mtod(m, void *), th, m,
+ tp->rcv_nxt, tp->snd_nxt, TH_ACK);
+ tp->last_ack_sent = tp->rcv_nxt;
+ }
}
} else {
m_freem(m);

File Metadata

Mime Type
text/plain
Expires
Sat, Jul 11, 3:53 PM (8 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34965060
Default Alt Text
D32938.id98357.diff (5 KB)

Event Timeline