diff options
author | Ben Magistro <koncept1@gmail.com> | 2021-08-24 13:06:35 +0000 |
---|---|---|
committer | Ben Magistro <koncept1@gmail.com> | 2021-09-17 00:58:11 +0000 |
commit | 1e02b8666c6f2ce9beff085eabc7f73cc421de91 (patch) | |
tree | 0e02c557f1ecce79c02553ec8163888001a172ee | |
parent | 6fddbfcd39d8cfb96ef7a22bbd786c16b9d29e54 (diff) |
l4p/tcp: Add ability to adjust/offset tcp timestamps when proxying
Signed-off-by: Ben Magistro <koncept1@gmail.com>
Change-Id: Icb65a2a2bf2f0b647fb8927c9c4adb88b9eb2131
Signed-off-by: Ben Magistro <koncept1@gmail.com>
-rw-r--r-- | lib/libtle_l4p/tcp_rxtx.c | 21 | ||||
-rw-r--r-- | lib/libtle_l4p/tcp_stream.c | 2 | ||||
-rw-r--r-- | lib/libtle_l4p/tcp_stream.h | 2 |
3 files changed, 20 insertions, 5 deletions
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); diff --git a/lib/libtle_l4p/tcp_stream.c b/lib/libtle_l4p/tcp_stream.c index 59d94a4..f41ff3c 100644 --- a/lib/libtle_l4p/tcp_stream.c +++ b/lib/libtle_l4p/tcp_stream.c @@ -382,6 +382,8 @@ tcp_stream_fill_cfg(struct tle_tcp_stream *s, const struct tle_ctx_param *cprm, s->tcb.snd.rto_tw = (cprm->timewait == TLE_TCP_TIMEWAIT_DEFAULT) ? TCP_RTO_2MSL : cprm->timewait; + s->ts_offset = 0; + s->s.udata = scfg->udata; } diff --git a/lib/libtle_l4p/tcp_stream.h b/lib/libtle_l4p/tcp_stream.h index 9b22b38..a33e557 100644 --- a/lib/libtle_l4p/tcp_stream.h +++ b/lib/libtle_l4p/tcp_stream.h @@ -82,6 +82,8 @@ struct tle_tcp_stream { struct stbl_entry *ste; /* entry in streams table. */ struct tcb tcb; + int32_t ts_offset; /* TS.VAL offset from TSC calculated */ + struct { void *handle; } timer; |