From ba9e9f63bce9a868b8b3e15adca616ac4dec9414 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 26 Nov 2015 22:19:22 +0100 Subject: gtphub: implement restart counter properly. Force passing a restart counter, by adding such arg to gtphub_start() (test suite is not affected by this). In gtphub_main.c, add -r,--restart-file and next_restart_count() to maintain the counter file. While at it, tweak the cmdline help to unify the formatting (mostly commas and a missing line break). Send gtphub's own restart counter. So far, the sender's restart counter was copied through, which would break as soon as more than one GSN would talk to the same peer with differing restart counters. Also fix the in-mem restart counter data type (one octet, not two). Sponsored-by: On-Waves ehi --- openbsc/src/gprs/gtphub.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'openbsc/src/gprs/gtphub.c') diff --git a/openbsc/src/gprs/gtphub.c b/openbsc/src/gprs/gtphub.c index ff1105b8e..db84a00c3 100644 --- a/openbsc/src/gprs/gtphub.c +++ b/openbsc/src/gprs/gtphub.c @@ -1302,7 +1302,16 @@ static void gtphub_map_restart_counter(struct gtphub *hub, struct gtphub_peer_port *from, struct gtphub_peer_port *to) { - /* TODO */ + /* Always send gtphub's own restart counter */ + if (p->rc != GTP_RC_PDU_C) + return; + + int ie_idx; + ie_idx = gtpie_getie(p->ie, GTPIE_RECOVERY, 0); + if (ie_idx < 0) + return; + + p->ie[ie_idx]->tv1.v = hton8(hub->restart_counter); } static int gtphub_unmap_header_tei(struct gtphub_peer_port **to_port_p, @@ -2164,12 +2173,15 @@ static int gtphub_make_proxy(struct gtphub *hub, return 0; } -int gtphub_start(struct gtphub *hub, struct gtphub_cfg *cfg) +int gtphub_start(struct gtphub *hub, struct gtphub_cfg *cfg, + uint8_t restart_counter) { int rc; gtphub_init(hub); + hub->restart_counter = restart_counter; + /* If a Ctrl plane proxy is configured, ares will never be used. */ if (!cfg->ggsn_proxy[GTPH_PLANE_CTRL].addr_str) { if (gtphub_ares_init(hub) != 0) { -- cgit v1.2.3