aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2015-12-06 16:39:23 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2015-12-07 13:37:03 +0100
commitba0525e3d8b7ca5e9d1cd3aeb342f09ba142bccb (patch)
tree6a0259eb07be8b824a8c25b9024cc98e30d6eaa3
parent28a70f20cdb5507feacac48cc4e0833f6b1e9afd (diff)
gtphub: tweak logging.
Less spaces in tunnel strings, adjust tests accordingly. Use side_idx to remove code dup in rate counter output. Sponsored-by: On-Waves ehi
-rw-r--r--openbsc/src/gprs/gtphub.c6
-rw-r--r--openbsc/src/gprs/gtphub_vty.c24
-rw-r--r--openbsc/tests/gtphub/gtphub_test.c64
3 files changed, 46 insertions, 48 deletions
diff --git a/openbsc/src/gprs/gtphub.c b/openbsc/src/gprs/gtphub.c
index 5736b896a..eb463d7ed 100644
--- a/openbsc/src/gprs/gtphub.c
+++ b/openbsc/src/gprs/gtphub.c
@@ -986,15 +986,15 @@ static const char *gtphub_tunnel_side_str(struct gtphub_tunnel *tun,
if (!u->peer) {
if (c->peer) {
- APPEND(" / (uninitialized)");
+ APPEND("/(uninitialized)");
}
} else if ((!c->peer)
|| (!gsn_addr_same(&u->peer->peer_addr->addr,
&c->peer->peer_addr->addr))) {
- APPEND(" / %s", gsn_addr_to_str(&u->peer->peer_addr->addr));
+ APPEND("/%s", gsn_addr_to_str(&u->peer->peer_addr->addr));
}
- APPEND(" (TEI C %x=%x / U %x=%x)",
+ APPEND(" (TEI C %x=%x/U %x=%x)",
c->tei_orig, c->tei_repl,
u->tei_orig, u->tei_repl);
return buf;
diff --git a/openbsc/src/gprs/gtphub_vty.c b/openbsc/src/gprs/gtphub_vty.c
index 324d155b9..0eb9261d3 100644
--- a/openbsc/src/gprs/gtphub_vty.c
+++ b/openbsc/src/gprs/gtphub_vty.c
@@ -290,17 +290,15 @@ static void show_bind_stats_all(struct vty *vty)
vty_out(vty, "- %s Plane:%s",
gtphub_plane_idx_names[plane_idx], VTY_NEWLINE);
- struct gtphub_bind *b = &g_hub->to_gsns[GTPH_SIDE_GGSN][plane_idx];
- vty_out(vty, " - to/from GGSNs: %s port %d%s",
- gsn_addr_to_str(&b->local_addr), (int)b->local_port,
- VTY_NEWLINE);
- vty_out_rate_ctr_group(vty, " ", b->counters_io);
-
- b = &g_hub->to_gsns[GTPH_SIDE_SGSN][plane_idx];
- vty_out(vty, " - to/from SGSNs: %s port %d%s",
- gsn_addr_to_str(&b->local_addr), (int)b->local_port,
- VTY_NEWLINE);
- vty_out_rate_ctr_group(vty, " ", b->counters_io);
+ int side_idx;
+ for_each_side(side_idx) {
+ struct gtphub_bind *b = &g_hub->to_gsns[side_idx][plane_idx];
+ vty_out(vty, " - to/from %ss: %s port %d%s",
+ gtphub_side_idx_names[side_idx],
+ gsn_addr_to_str(&b->local_addr), (int)b->local_port,
+ VTY_NEWLINE);
+ vty_out_rate_ctr_group(vty, " ", b->counters_io);
+ }
}
}
@@ -387,7 +385,7 @@ static void show_tunnels_all(struct vty *vty)
time_t now = gtphub_now();
vty_out(vty, "All tunnels:%s"
- "Legend: SGSN <-> GGSN, with each:%s"
+ "Legend: (expiry in minutes) SGSN <-> GGSN, with each:%s"
" <IP-Ctrl>[/<IP-User>] (<TEI-Ctrl>=<mapped>/<TEI-User>=<mapped>)%s",
VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
@@ -397,7 +395,7 @@ static void show_tunnels_all(struct vty *vty)
llist_for_each_entry(t, &g_hub->tunnels, entry) {
vty_out(vty,
"(%4dm) %s%s",
- -(int)((t->expiry_entry.expiry - now) / 60),
+ (int)((t->expiry_entry.expiry - now) / 60),
gtphub_tunnel_str(t),
VTY_NEWLINE);
count ++;
diff --git a/openbsc/tests/gtphub/gtphub_test.c b/openbsc/tests/gtphub/gtphub_test.c
index bdce99d7f..f24ace006 100644
--- a/openbsc/tests/gtphub/gtphub_test.c
+++ b/openbsc/tests/gtphub/gtphub_test.c
@@ -943,8 +943,8 @@ static int create_pdp_ctx()
LVL2_ASSERT(was_resolved_for("240010123456789", "internet"));
LVL2_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 / (uninitialized) (TEI C 0=0 / U 0=0)"
+ "192.168.42.23 (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C 0=0/U 0=0)"
" @21945\n"));
const char *gtp_resp_from_ggsn =
@@ -1007,8 +1007,8 @@ static int delete_pdp_ctx_from_sgsn(void)
gtphub_gc(hub, now);
LVL2_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ "192.168.42.23 (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3/U 567=4)"
" @21945\n"));
/* TEI Ctrl from above and next sequence after abcd. */
@@ -1022,8 +1022,8 @@ static int delete_pdp_ctx_from_sgsn(void)
/* 21945 + 31 = 21976 */
LVL2_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ "192.168.42.23 (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3/U 567=4)"
" @21976\n"));
const char *gtp_resp_from_ggsn =
@@ -1049,8 +1049,8 @@ static int delete_pdp_ctx_from_ggsn(void)
gtphub_gc(hub, now);
LVL2_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ "192.168.42.23 (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3/U 567=4)"
" @21945\n"));
/* TEI Ctrl from above and next sequence after abcd. */
@@ -1064,8 +1064,8 @@ static int delete_pdp_ctx_from_ggsn(void)
/* 21945 + 31 = 21976 */
LVL2_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ "192.168.42.23 (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3/U 567=4)"
" @21976\n"));
const char *gtp_resp_from_sgsn =
@@ -1112,8 +1112,8 @@ static void test_one_pdp_ctx(int del_from_side)
* 0x00000567 == 1383 (TEI from GGSN User)
* Mapped TEIs should be 1 and 2. */
OSMO_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ "192.168.42.23 (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3/U 567=4)"
" @21945\n"));
if (del_from_side == GTPH_SIDE_SGSN) {
@@ -1136,8 +1136,8 @@ static void test_user_data(void)
/* now == 345; now + (6 * 60 * 60) == 21600 + 345 == 21945. */
OSMO_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ "192.168.42.23 (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3/U 567=4)"
" @21945\n"));
LOG("- user data starts");
@@ -1182,8 +1182,8 @@ static void test_user_data(void)
/* Make sure the user plane messages have refreshed the TEI mapping
* timeouts: 21945 + 600 == 22545. */
OSMO_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ "192.168.42.23 (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3/U 567=4)"
" @22545\n"));
const char *u_from_sgsn =
@@ -1218,8 +1218,8 @@ static void test_user_data(void)
/* Make sure the user plane messages have refreshed the TEI mapping
* timeouts: 21945 + 600 == 22545. Both timeouts refreshed: */
OSMO_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ "192.168.42.23 (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3/U 567=4)"
" @22545\n"));
OSMO_ASSERT(clear_test_hub());
@@ -1263,8 +1263,8 @@ static void test_reused_tei(void)
OSMO_ASSERT(was_resolved_for("240010123456789", "internet"));
OSMO_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=5 / U 123=6)"
- " <-> 192.168.43.34 / (uninitialized) (TEI C 0=0 / U 0=0)"
+ "192.168.42.23 (TEI C 321=5/U 123=6)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C 0=0/U 0=0)"
" @21945\n"));
const char *gtp_resp_from_ggsn =
@@ -1337,11 +1337,11 @@ static void test_peer_restarted(void)
OSMO_ASSERT(was_resolved_for("240010123456789", "internet"));
OSMO_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C cba=5 / U abc=6)"
- " <-> 192.168.43.34 / (uninitialized) (TEI C 0=0 / U 0=0)"
+ "192.168.42.23 (TEI C cba=5/U abc=6)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C 0=0/U 0=0)"
" @21955\n"
- "(uninitialized) (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ "(uninitialized) (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3/U 567=4)"
" @21945\n"
));
@@ -1415,8 +1415,8 @@ static void test_peer_restarted_reusing_tei(void)
OSMO_ASSERT(was_resolved_for("240010123456789", "internet"));
OSMO_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=5 / U 123=6)"
- " <-> 192.168.43.34 / (uninitialized) (TEI C 0=0 / U 0=0)"
+ "192.168.42.23 (TEI C 321=5/U 123=6)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C 0=0/U 0=0)"
" @21955\n"
));
@@ -1462,8 +1462,8 @@ static void test_sgsn_behind_nat(void)
/* now == 345; now + (6 * 60 * 60) == 21600 + 345 == 21945. */
OSMO_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ "192.168.42.23 (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3/U 567=4)"
" @21945\n"));
LOG("- user data starts");
@@ -1507,8 +1507,8 @@ static void test_sgsn_behind_nat(void)
/* Make sure the user plane messages have refreshed the TEI mapping
* timeouts: 21945 + 600 == 22545. */
OSMO_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ "192.168.42.23 (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3/U 567=4)"
" @22545\n"));
const char *u_from_sgsn =
@@ -1543,8 +1543,8 @@ static void test_sgsn_behind_nat(void)
/* Make sure the user plane messages have refreshed the TEI mapping
* timeouts: 21945 + 600 == 22545. Both timeouts refreshed: */
OSMO_ASSERT(tunnels_are(
- "192.168.42.23 (TEI C 321=1 / U 123=2)"
- " <-> 192.168.43.34 (TEI C 765=3 / U 567=4)"
+ "192.168.42.23 (TEI C 321=1/U 123=2)"
+ " <-> 192.168.43.34 (TEI C 765=3/U 567=4)"
" @22545\n"));
OSMO_ASSERT(clear_test_hub());