From 1e02b8666c6f2ce9beff085eabc7f73cc421de91 Mon Sep 17 00:00:00 2001 From: Ben Magistro Date: Tue, 24 Aug 2021 13:06:35 +0000 Subject: l4p/tcp: Add ability to adjust/offset tcp timestamps when proxying Signed-off-by: Ben Magistro Change-Id: Icb65a2a2bf2f0b647fb8927c9c4adb88b9eb2131 Signed-off-by: Ben Magistro --- lib/libtle_l4p/tcp_rxtx.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'lib/libtle_l4p/tcp_rxtx.c') diff --git a/lib/libtle_l4p/tcp_rxtx.c b/lib/libtle_l4p/tcp_rxtx.c index a3e21f5..bf79eab 100644 --- a/lib/libtle_l4p/tcp_rxtx.c +++ b/lib/libtle_l4p/tcp_rxtx.c @@ -199,6 +199,12 @@ get_ip_pid(struct tle_dev *dev, uint32_t num, uint32_t type, uint32_t st) } } +static inline uint32_t +tcp_stream_adjust_tms(const struct tle_tcp_stream *s, uint32_t tms) +{ + return tms - s->ts_offset; +} + static inline void fill_tcph(struct rte_tcp_hdr *l4h, const struct tcb *tcb, union l4_ports port, uint32_t seq, uint8_t hlen, uint8_t flags) @@ -2002,6 +2008,8 @@ tle_tcp_stream_rx_bulk(struct tle_stream *ts, struct rte_mbuf *pkt[], return 0; } + tms = tcp_stream_adjust_tms(s, tms); + /* extract packet info and check the L3/L4 csums */ for (i = 0; i != num; i++) { get_pkt_info(pkt[i], &pi[i], &si[i]); @@ -2272,12 +2280,15 @@ tcb_establish(struct tle_tcp_stream *s, const struct tle_tcp_conn_info *ci) s->tcb.snd.cwnd = initial_cwnd(s->tcb.snd.mss, s->tcb.snd.cwnd); s->tcb.snd.ssthresh = s->tcb.snd.wnd; + /* calculate and store real timestamp offset */ + if (ci->so.ts.raw != 0) { + s->ts_offset = tms - ci->so.ts.ecr; + tms -= s->ts_offset; + } + estimate_stream_rto(s, tms); } -/* - * !!! add flgs to distinguish - add or not stream into the table. - */ struct tle_stream * tle_tcp_stream_establish(struct tle_ctx *ctx, const struct tle_tcp_stream_param *prm, @@ -2802,7 +2813,7 @@ tle_tcp_process(struct tle_ctx *ctx, uint32_t num) s = rs[i]; s->timer.handle = NULL; if (tcp_stream_try_acquire(s) > 0) - rto_stream(s, tms); + rto_stream(s, tcp_stream_adjust_tms(s, tms)); tcp_stream_release(s); } @@ -2816,7 +2827,7 @@ tle_tcp_process(struct tle_ctx *ctx, uint32_t num) rte_atomic32_set(&s->tx.arm, 0); if (tcp_stream_try_acquire(s) > 0) - tx_stream(s, tms); + tx_stream(s, tcp_stream_adjust_tms(s, tms)); else txs_enqueue(s->s.ctx, s); tcp_stream_release(s); -- cgit 1.2.3-korg