Review at  https://gerrit.osmocom.org/5524

gtphub: make rate_ctr unique

* compute unique rate counter index when allocating new gtphub tunnel
* propagate rate counter allocation error to upper layers
* log and gracefully handle tunnel allocation error

Change-Id: I0e07f95c36de369bcd0691b8d0fd47c844abe5da
Related: OS#2757
---
M src/gprs/gtphub.c
1 file changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/24/5524/1

diff --git a/src/gprs/gtphub.c b/src/gprs/gtphub.c
index 7e3e663..a06e561 100644
--- a/src/gprs/gtphub.c
+++ b/src/gprs/gtphub.c
@@ -1121,8 +1121,9 @@
                struct gtphub_tunnel_endpoint *te = 
&tun->endpoint[side_idx][plane_idx];
                te->counters_io = rate_ctr_group_alloc(osmo_gtphub_ctx,
                                                       &gtphub_ctrg_io_desc,
-                                                      0);
-               OSMO_ASSERT(te->counters_io);
+                                                      side_idx + (plane_idx + 
1) * 2);
+               if (!te->counters_io)
+                       return NULL;
        }
 
        tun->expiry_entry.del_cb = gtphub_tunnel_del_cb;
@@ -1486,7 +1487,13 @@
                }
 
                /* A new tunnel. */
-               p->tun = tun = gtphub_tunnel_new();
+               tun = gtphub_tunnel_new();
+               if (!tun) {
+                       LOG(LOGL_ERROR, "Failed to allocate new tunnel %s <-> 
%s\n",
+                           gtphub_port_str(from_ctrl), 
gtphub_port_str(to_ctrl));
+                       return -1;
+               }
+               p->tun = tun;
 
                /* Create TEI mapping */
                tun->tei_repl = nr_pool_next(&hub->tei_pool);

-- 
To view, visit https://gerrit.osmocom.org/5524
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0e07f95c36de369bcd0691b8d0fd47c844abe5da
Gerrit-PatchSet: 1
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Owner: Max <[email protected]>

Reply via email to