aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs/gb_proxy.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-08-16 12:11:46 +0200
committerHarald Welte <laforge@gnumonks.org>2018-08-17 14:13:24 +0000
commit67f1d1edf49258f37b021357b00c25c79d973ae8 (patch)
treee5eeb04591705b209af4a5dcb0e93144187f8e01 /src/gprs/gb_proxy.c
parent36abeadc7ba6ff15a3e01230195309f87f788f33 (diff)
gbproxy: Add VTY parameter: link stored-msgs-max-length
It was discovered in some prod setups that some TLLIs can maintain quite long queues of msgb in case its IMSI is not acquired and the tlli is not pruned due to link-list max-{age,length} being set to 0. As a result, the osmo-gpbroxy steadly increases the list size of maintained TLLIs, and some TLLI was found without IMSI catching already 1211 msgb. Let's allow setting a maxiumum length for the queue storing those msgb in a per TLLI base. If the limit is reached, oldest msgb are removed before adding a new one. Depends: libosmocore Change-Id I33b501e89a8f29e4aa121696bcbb13d4b83db40f Related: SYS#4297 Change-Id: I4473be8604f80302df03ffdd5a13280dc072f824
Diffstat (limited to 'src/gprs/gb_proxy.c')
-rw-r--r--src/gprs/gb_proxy.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/gprs/gb_proxy.c b/src/gprs/gb_proxy.c
index f834ed3e6..8bb67895e 100644
--- a/src/gprs/gb_proxy.c
+++ b/src/gprs/gb_proxy.c
@@ -338,7 +338,8 @@ static int gbproxy_flush_stored_messages(struct gbproxy_peer *peer,
msgb_nsei(msg));
/* Patch and flush stored messages towards the SGSN */
- while ((stored_msg = msgb_dequeue(&link_info->stored_msgs))) {
+ while ((stored_msg = msgb_dequeue_count(&link_info->stored_msgs,
+ &link_info->stored_msgs_len))) {
struct gprs_gb_parse_context tmp_parse_ctx = {0};
tmp_parse_ctx.to_bss = 0;
tmp_parse_ctx.peer_nsei = msgb_nsei(stored_msg);
@@ -492,6 +493,24 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer,
/* The message cannot be processed since the IMSI is still missing */
+ /* If queue is getting too large, drop oldest msgb before adding new one */
+ if (peer->cfg->stored_msgs_max_len > 0) {
+ int exceeded_max_len = link_info->stored_msgs_len
+ + 1 - peer->cfg->stored_msgs_max_len;
+
+ for (; exceeded_max_len > 0; exceeded_max_len--) {
+ struct msgb *msgb_drop;
+ msgb_drop = msgb_dequeue_count(&link_info->stored_msgs,
+ &link_info->stored_msgs_len);
+ LOGP(DLLC, LOGL_INFO,
+ "NSEI=%d(BSS) Dropping stored msgb from list "
+ "(!acq imsi, length %d, max_len exceeded)\n",
+ msgb_nsei(msgb_drop), link_info->stored_msgs_len);
+
+ msgb_free(msgb_drop);
+ }
+ }
+
/* Enqueue unpatched messages */
LOGP(DLLC, LOGL_INFO,
"NSEI=%d(BSS) IMSI acquisition in progress, "
@@ -500,7 +519,8 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer,
parse_ctx->llc_msg_name ? parse_ctx->llc_msg_name : "BSSGP");
stored_msg = bssgp_msgb_copy(msg, "process_bssgp_ul");
- msgb_enqueue(&link_info->stored_msgs, stored_msg);
+ msgb_enqueue_count(&link_info->stored_msgs, stored_msg,
+ &link_info->stored_msgs_len);
if (!link_info->imsi_acq_pending) {
LOGP(DLLC, LOGL_INFO,