From d6168a81031a7caf72e1d2e3db7ed52b0d8fdb69 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 27 Jul 2022 14:59:30 +0200 Subject: pfcp_endpoint: fix final PFCP retrans resp_cb After the final retransmission of a sent request, still keep the message in the queue for its expiry period, so that a later response is matched to the request. The osmo_pfcp_msg.resp_cb() depends on the sent message to remain in the queue until it times out. That was not the case in an earlier stage of libosmo-pfcp development. I noticed this during ttcn3 testing, where osmo-hnbgw continuously resends PFCP Association Setup Requests, and fails to associate if ttcn3 happens to respond to the final retransmission of a request. Related: SYS#5599 Change-Id: Iaca396891921f7057015ce6e1e4528b955757809 --- src/libosmo-pfcp/pfcp_endpoint.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libosmo-pfcp/pfcp_endpoint.c b/src/libosmo-pfcp/pfcp_endpoint.c index 0ee3a9a..68d0a21 100644 --- a/src/libosmo-pfcp/pfcp_endpoint.c +++ b/src/libosmo-pfcp/pfcp_endpoint.c @@ -181,18 +181,19 @@ static bool pfcp_queue_retrans(struct osmo_pfcp_queue_entry *qe) struct osmo_pfcp_msg *m = qe->m; int rc; + /* if no more attempts remaining, drop from queue */ + if (!qe->n1_remaining) + return false; + /* re-transmit */ - if (qe->n1_remaining) - qe->n1_remaining--; - OSMO_LOG_PFCP_MSG(m, LOGL_INFO, "re-sending (%u attempts remaining)\n", qe->n1_remaining); + qe->n1_remaining--; + OSMO_LOG_PFCP_MSG(m, LOGL_INFO, "re-sending (%u attempts remaining after this)\n", qe->n1_remaining); rc = osmo_pfcp_endpoint_tx_data_no_logging(endpoint, m); - /* If encoding failed, it cannot ever succeed. Drop the queue entry. */ + /* If encoding failed, it cannot ever succeed. Drop the queue entry. (Error logging already taken care of in + * osmo_pfcp_endpoint_tx_data_no_logging().) */ if (rc) return false; - /* if no more attempts remaining, drop from queue */ - if (!qe->n1_remaining) - return false; /* re-schedule timer, keep in queue */ osmo_timer_schedule(&qe->t1, t1_ms/1000, (t1_ms % 1000) * 1000); return true; -- cgit v1.2.3