]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Add a function to compute the current PTO
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 10 Mar 2022 14:05:32 +0000 (15:05 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 11 Mar 2022 10:37:30 +0000 (11:37 +0100)
There was not such a function at this time. This is needed to implement the idle
timeout feature.

include/haproxy/quic_loss.h

index 6e4aebb93070978e6a3d2e4a814181dba114f3c2..1c0bfc7a7535753884590774a4aebad51f207b3e 100644 (file)
@@ -119,6 +119,15 @@ static inline struct quic_pktns *quic_loss_pktns(struct quic_conn *qc)
        return pktns;
 }
 
+/* Return the PTO associated to <pktns> packet number space for <qc> connection */
+static inline unsigned int quic_pto(struct quic_conn *qc)
+{
+       struct quic_loss *ql = &qc->path->loss;
+
+       return (ql->srtt >> 3) + QUIC_MAX(ql->rtt_var, QUIC_TIMER_GRANULARITY) +
+               HA_ATOMIC_LOAD(&qc->state) >= QUIC_HS_ST_COMPLETE ? qc->max_ack_delay : 0;
+}
+
 /* Returns for <qc> QUIC connection the first packet number space to
  * arm the PTO for if any or a packet number space with TICK_ETERNITY
  * as PTO value if not.