diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-08-17 13:13:27 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2018-08-17 14:13:47 +0000 |
commit | 82f13612ce63b863d22bc28eaf3dcc25c364fb6c (patch) | |
tree | b7aa36532abc0758928ec6b637b479a4e3f54c48 /src/gprs/gb_proxy_peer.c | |
parent | 67f1d1edf49258f37b021357b00c25c79d973ae8 (diff) |
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
Diffstat (limited to 'src/gprs/gb_proxy_peer.c')
-rw-r--r-- | src/gprs/gb_proxy_peer.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/gprs/gb_proxy_peer.c b/src/gprs/gb_proxy_peer.c index f2cdd9388..8e28fc4bc 100644 --- a/src/gprs/gb_proxy_peer.c +++ b/src/gprs/gb_proxy_peer.c @@ -167,6 +167,19 @@ struct gbproxy_peer *gbproxy_peer_by_bssgp_tlv(struct gbproxy_config *cfg, 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 @@ struct gbproxy_peer *gbproxy_peer_alloc(struct gbproxy_config *cfg, uint16_t bvc 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 @@ int gbproxy_cleanup_peers(struct gbproxy_config *cfg, uint16_t nsei, uint16_t bv return counter; } - |