Skip to content

Commit

Permalink
tcp: misc cleanup of options for rack as well as socket option logging.
Browse files Browse the repository at this point in the history
Both BBR and Rack have the ability to log socket options, which is currently disabled. Rack
has an experimental SaD (Sack Attack Detection) algorithm that should be made available. Also
there is a t_maxpeak_rate that needs to be removed (its un-used).

Reviewed by: tuexen, cc
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D39427
  • Loading branch information
Randall Stewart authored and Randall Stewart committed Apr 7, 2023
1 parent 37d97b1 commit 945f9a7
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 124 deletions.
6 changes: 6 additions & 0 deletions sys/conf/options
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ SW_WATCHDOG opt_watchdog.h
TCPHPTS opt_inet.h
TCP_REQUEST_TRK opt_global.h
TCP_ACCOUNTING opt_inet.h
#
# TCP SaD Detection is an experimental Sack attack Detection (SaD)
# algorithm that uses "normal" behaviour with SACK's to detect
# a possible attack. It is strictly experimental at this point.
#
TCP_SAD_DETECTION opt_inet.h
TURNSTILE_PROFILING
UMTX_PROFILING
UMTX_CHAINS opt_global.h
Expand Down
3 changes: 3 additions & 0 deletions sys/netinet/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ struct tcp_info {
u_int32_t __tcpi_received_e0_bytes;
u_int32_t __tcpi_received_ce_bytes;

u_int32_t tcpi_total_tlp; /* tail loss probes sent */
u_int64_t tcpi_total_tlp_bytes; /* tail loss probe bytes sent */

/* Padding to grow without breaking ABI. */
u_int32_t __tcpi_pad[19]; /* Padding. */
};
Expand Down
2 changes: 1 addition & 1 deletion sys/netinet/tcp_log_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ enum tcp_log_events {
TCP_LOG_CONNEND, /* End of connection 54 */
TCP_LOG_LRO, /* LRO entry 55 */
TCP_SACK_FILTER_RES, /* Results of SACK Filter 56 */
TCP_SAD_DETECTION, /* Sack Attack Detection 57 */
TCP_SAD_DETECT, /* Sack Attack Detection 57 */
TCP_TIMELY_WORK, /* Logs regarding Timely CC tweaks 58 */
TCP_LOG_USER_EVENT, /* User space event data 59 */
TCP_LOG_SENDFILE, /* sendfile() logging for TCP connections 60 */
Expand Down
36 changes: 1 addition & 35 deletions sys/netinet/tcp_stacks/bbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2991,13 +2991,6 @@ __bbr_get_bw(struct tcp_bbr *bbr)
bw = bbr->r_ctl.red_bw;
else
bw = get_filter_value(&bbr->r_ctl.rc_delrate);
if (bbr->rc_tp->t_peakrate_thr && (bbr->rc_use_google == 0)) {
/*
* Enforce user set rate limit, keep in mind that
* t_peakrate_thr is in B/s already
*/
bw = uqmin((uint64_t)bbr->rc_tp->t_peakrate_thr, bw);
}
if (bw == 0) {
/* We should not be at 0, go to the initial window then */
goto use_initial_window;
Expand Down Expand Up @@ -10071,9 +10064,6 @@ bbr_init(struct tcpcb *tp, void **ptr)
bbr->r_ctl.rc_initial_hptsi_bw = bbr_initial_bw_bps;
if (bbr_resends_use_tso)
bbr->rc_resends_use_tso = 1;
#ifdef NETFLIX_PEAKRATE
tp->t_peakrate_thr = tp->t_maxpeakrate;
#endif
if (tp->snd_una != tp->snd_max) {
/* Create a send map for the current outstanding data */
struct bbr_sendmap *rsm;
Expand Down Expand Up @@ -11668,20 +11658,10 @@ bbr_what_can_we_send(struct tcpcb *tp, struct tcp_bbr *bbr, uint32_t sendwin,
return (len);
}

static inline void
bbr_do_error_accounting(struct tcpcb *tp, struct tcp_bbr *bbr, struct bbr_sendmap *rsm, int32_t len, int32_t error)
{
#ifdef NETFLIX_STATS
KMOD_TCPSTAT_INC(tcps_sndpack_error);
KMOD_TCPSTAT_ADD(tcps_sndbyte_error, len);
#endif
}

static inline void
bbr_do_send_accounting(struct tcpcb *tp, struct tcp_bbr *bbr, struct bbr_sendmap *rsm, int32_t len, int32_t error)
{
if (error) {
bbr_do_error_accounting(tp, bbr, rsm, len, error);
return;
}
if (rsm) {
Expand All @@ -11690,10 +11670,8 @@ bbr_do_send_accounting(struct tcpcb *tp, struct tcp_bbr *bbr, struct bbr_sendmap
* TLP should not count in retran count, but in its
* own bin
*/
#ifdef NETFLIX_STATS
KMOD_TCPSTAT_INC(tcps_tlpresends);
KMOD_TCPSTAT_ADD(tcps_tlpresend_bytes, len);
#endif
} else {
/* Retransmit */
tp->t_sndrexmitpack++;
Expand Down Expand Up @@ -14206,9 +14184,6 @@ bbr_set_sockopt(struct inpcb *inp, struct sockopt *sopt)
case TCP_BBR_PACE_SEG_MIN:
case TCP_BBR_PACE_CROSS:
case TCP_BBR_PACE_OH:
#ifdef NETFLIX_PEAKRATE
case TCP_MAXPEAKRATE:
#endif
case TCP_BBR_TMR_PACE_OH:
case TCP_BBR_RACK_RTT_USE:
case TCP_BBR_RETRAN_WTSO:
Expand Down Expand Up @@ -14474,14 +14449,7 @@ bbr_set_sockopt(struct inpcb *inp, struct sockopt *sopt)
BBR_OPTS_INC(tcp_rack_pkt_delay);
bbr->r_ctl.rc_pkt_delay = optval;
break;
#ifdef NETFLIX_PEAKRATE
case TCP_MAXPEAKRATE:
BBR_OPTS_INC(tcp_maxpeak);
error = tcp_set_maxpeakrate(tp, optval);
if (!error)
tp->t_peakrate_thr = tp->t_maxpeakrate;
break;
#endif

case TCP_BBR_RETRAN_WTSO:
BBR_OPTS_INC(tcp_retran_wtso);
if (optval)
Expand Down Expand Up @@ -14553,9 +14521,7 @@ bbr_set_sockopt(struct inpcb *inp, struct sockopt *sopt)
return (tcp_default_ctloutput(inp, sopt));
break;
}
#ifdef NETFLIX_STATS
tcp_log_socket_option(tp, sopt->sopt_name, optval, error);
#endif
INP_WUNLOCK(inp);
return (error);
}
Expand Down
Loading

0 comments on commit 945f9a7

Please sign in to comment.