gbproxy: Add new VTY-managed timer: link-list clean-stale-timer
This timer allows periodically cleaning up stale links in link-list of
each gbproxy_peer. Previous to this patch, this kind of cleanup
(gbproxy_remove_stale_link_infos) was being done only as a consequence
of external events being triggered, such as a message from that peer
being received.
It was found in a production network agreggating several BSS that some
of them were offline for a longtime but gbproxy was still caching big
amounts of really old link_info for the NSEI assigned to those BSS,
because since they were probably turned off abruptely, no new messages
were received from it which would trigger the cleanup.
As a consequence, it has been observed that a timer to periodically
clean up old entries (link-list max-age) is requird in case w don't
receive messages from that NSEI periodically.
Related: SYS#4431
Change-Id: Ic777016f6d4f0e30fb736484774ca46878f17b7a
diff --git a/src/gprs/gb_proxy_peer.c b/src/gprs/gb_proxy_peer.c
index f2cdd93..8e28fc4 100644
--- a/src/gprs/gb_proxy_peer.c
+++ b/src/gprs/gb_proxy_peer.c
@@ -167,6 +167,19 @@
return NULL;
}
+static void clean_stale_timer_cb(void *data)
+{
+ time_t now;
+ struct timespec ts = {0,};
+ struct gbproxy_peer *peer = (struct gbproxy_peer *) data;
+
+ osmo_clock_gettime(CLOCK_MONOTONIC, &ts);
+ now = ts.tv_sec;
+ gbproxy_remove_stale_link_infos(peer, now);
+ if (peer->cfg->clean_stale_timer_freq != 0)
+ osmo_timer_schedule(&peer->clean_stale_timer,
+ peer->cfg->clean_stale_timer_freq, 0);
+}
struct gbproxy_peer *gbproxy_peer_alloc(struct gbproxy_config *cfg, uint16_t bvci)
{
@@ -188,13 +201,18 @@
INIT_LLIST_HEAD(&peer->patch_state.logical_links);
+ osmo_timer_setup(&peer->clean_stale_timer, clean_stale_timer_cb, peer);
+ if (peer->cfg->clean_stale_timer_freq != 0)
+ osmo_timer_schedule(&peer->clean_stale_timer,
+ peer->cfg->clean_stale_timer_freq, 0);
+
return peer;
}
void gbproxy_peer_free(struct gbproxy_peer *peer)
{
llist_del(&peer->list);
-
+ osmo_timer_del(&peer->clean_stale_timer);
gbproxy_delete_link_infos(peer);
rate_ctr_group_free(peer->ctrg);
@@ -220,4 +238,3 @@
return counter;
}
-