Author: jhb
Date: Thu Oct 29 00:03:19 2020
New Revision: 367122
URL: https://svnweb.freebsd.org/changeset/base/367122

Log:
  Save the current TCP pacing rate in t_pacing_rate.
  
  Reviewed by:  gallatin, gnn
  Sponsored by: Netflix
  Differential Revision:        https://reviews.freebsd.org/D26875

Modified:
  head/sys/netinet/tcp_ratelimit.c
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_var.h

Modified: head/sys/netinet/tcp_ratelimit.c
==============================================================================
--- head/sys/netinet/tcp_ratelimit.c    Wed Oct 28 23:10:54 2020        
(r367121)
+++ head/sys/netinet/tcp_ratelimit.c    Thu Oct 29 00:03:19 2020        
(r367122)
@@ -1220,6 +1220,8 @@ tcp_set_pacing_rate(struct tcpcb *tp, struct ifnet *if
 {
        const struct tcp_hwrate_limit_table *rte;
 
+       INP_WLOCK_ASSERT(tp->t_inpcb);
+
        if (tp->t_inpcb->inp_snd_tag == NULL) {
                /*
                 * We are setting up a rate for the first time.
@@ -1250,6 +1252,7 @@ tcp_set_pacing_rate(struct tcpcb *tp, struct ifnet *if
                        *error = EINVAL;
                rte = NULL;
        }
+       tp->t_pacing_rate = rte->rate;
        *error = 0;
        return (rte);
 }
@@ -1264,6 +1267,8 @@ tcp_chg_pacing_rate(const struct tcp_hwrate_limit_tabl
        int is_indirect = 0;
        int err;
 
+       INP_WLOCK_ASSERT(tp->t_inpcb);
+
        if ((tp->t_inpcb->inp_snd_tag == NULL) ||
            (crte == NULL)) {
                /* Wrong interface */
@@ -1330,6 +1335,7 @@ re_rate:
        }
        if (error)
                *error = 0;
+       tp->t_pacing_rate = nrte->rate;
        return (nrte);
 }
 
@@ -1340,6 +1346,9 @@ tcp_rel_pacing_rate(const struct tcp_hwrate_limit_tabl
        struct tcp_rate_set *rs;
        uint64_t pre;
 
+       INP_WLOCK_ASSERT(tp->t_inpcb);
+
+       tp->t_pacing_rate = -1;
        crs = crte->ptbl;
        /*
         * Now we must break the const

Modified: head/sys/netinet/tcp_subr.c
==============================================================================
--- head/sys/netinet/tcp_subr.c Wed Oct 28 23:10:54 2020        (r367121)
+++ head/sys/netinet/tcp_subr.c Thu Oct 29 00:03:19 2020        (r367122)
@@ -1783,6 +1783,7 @@ tcp_newtcpcb(struct inpcb *inp)
        /* Initialize the per-TCPCB log data. */
        tcp_log_tcpcbinit(tp);
 #endif
+       tp->t_pacing_rate = -1;
        if (tp->t_fb->tfb_tcp_fb_init) {
                if ((*tp->t_fb->tfb_tcp_fb_init)(tp)) {
                        refcount_release(&tp->t_fb->tfb_refcnt);

Modified: head/sys/netinet/tcp_var.h
==============================================================================
--- head/sys/netinet/tcp_var.h  Wed Oct 28 23:10:54 2020        (r367121)
+++ head/sys/netinet/tcp_var.h  Thu Oct 29 00:03:19 2020        (r367122)
@@ -246,6 +246,7 @@ struct tcpcb {
        int     t_dupacks;              /* consecutive dup acks recd */
        int     t_lognum;               /* Number of log entries */
        int     t_loglimit;             /* Maximum number of log entries */
+       int64_t t_pacing_rate;          /* bytes / sec, -1 => unlimited */
        struct tcp_log_stailq t_logs;   /* Log buffer */
        struct tcp_log_id_node *t_lin;
        struct tcp_log_id_bucket *t_lib;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to