octoi: Reset FIFO/RIFO when entering ACCEPTED state

For both OCTOI client + server FSM, whenever we enter the ACCEPTED
state (we disconnect), let's reset the RIFO/FIFO state.  This makes
sure no left-over frames from some earlier connection are present,
and also ensures our initial frame number expectations are correct.

Change-Id: I9e721b5dbf22728cb2361ed121d12def7016dcc2
This commit is contained in:
Harald Welte 2022-04-19 19:11:20 +02:00
parent accfded547
commit 99161f1423
4 changed files with 19 additions and 5 deletions

View File

@ -288,11 +288,7 @@ struct e1oip_line *e1oip_line_alloc(struct octoi_peer *peer)
iline->cfg.batching_factor = 32;
iline->cfg.prefill_frame_count = 400; /* 50ms */
frame_fifo_init(&iline->e1o.fifo, iline->cfg.batching_factor, fifo_threshold_cb, iline);
memset(&iline->e1o.last_frame, 0xff, sizeof(iline->e1o.last_frame));
frame_rifo_init(&iline->e1t.rifo);
memset(&iline->e1t.last_frame, 0xff, sizeof(iline->e1o.last_frame));
e1oip_line_reset(iline);
iline->peer = peer;
peer->iline = iline;
@ -300,6 +296,17 @@ struct e1oip_line *e1oip_line_alloc(struct octoi_peer *peer)
return iline;
}
void e1oip_line_reset(struct e1oip_line *iline)
{
frame_fifo_init(&iline->e1o.fifo, iline->cfg.batching_factor, fifo_threshold_cb, iline);
memset(&iline->e1o.last_frame, 0xff, sizeof(iline->e1o.last_frame));
iline->e1o.next_seq = 0;
frame_rifo_init(&iline->e1t.rifo);
memset(&iline->e1t.last_frame, 0xff, sizeof(iline->e1t.last_frame));
iline->e1t.next_fn32 = 0;
}
void e1oip_line_destroy(struct e1oip_line *iline)
{
if (!iline)

View File

@ -60,6 +60,7 @@ struct e1oip_line {
struct e1oip_line *e1oip_line_alloc(struct octoi_peer *peer);
void e1oip_line_set_name(struct e1oip_line *line, const char *name);
void e1oip_line_reset(struct e1oip_line *iline);
void e1oip_line_destroy(struct e1oip_line *iline);
int e1oip_rcvmsg_tdm_data(struct e1oip_line *iline, struct msgb *msg);

View File

@ -115,6 +115,9 @@ static void clnt_st_accepted_onenter(struct osmo_fsm_inst *fi, uint32_t prev_sta
{
struct clnt_state *st = fi->priv;
/* reset RIFO/FIFO etc. */
e1oip_line_reset(st->peer->iline);
st->peer->tdm_permitted = true;
osmo_timer_schedule(&st->rx_alive_timer, 3, 0);
}

View File

@ -169,6 +169,9 @@ static void srv_st_accepted_onenter(struct osmo_fsm_inst *fi, uint32_t prev_stat
{
struct srv_state *st = fi->priv;
/* reset RIFO/FIFO etc. */
e1oip_line_reset(st->peer->iline);
st->peer->tdm_permitted = true;
osmo_timer_schedule(&st->rx_alive_timer, 3, 0);
}