Change in ...osmo-ggsn[master]: ggsn_vty.c: Avoid printing duplicates for pdp context with v4v6 EUAs

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Tue Aug 20 12:25:32 UTC 2019


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ggsn/+/15253


Change subject: ggsn_vty.c: Avoid printing duplicates for pdp context with v4v6 EUAs
......................................................................

ggsn_vty.c: Avoid printing duplicates for pdp context with v4v6 EUAs

Fixes potential duplicates when calling following VTY cmd:
show pdp-context ggsn NAME
show pdp-context ggsn NAME apn APN

Related: OS#4154
Change-Id: I98db39a710a72a1438d71aabaf4f8227984643e3
---
M ggsn/ggsn_vty.c
1 file changed, 24 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/53/15253/1

diff --git a/ggsn/ggsn_vty.c b/ggsn/ggsn_vty.c
index b85df77..a649173 100644
--- a/ggsn/ggsn_vty.c
+++ b/ggsn/ggsn_vty.c
@@ -734,13 +734,22 @@
 	return in46a_ntoa(&in46);
 }
 
-static void show_one_pdp(struct vty *vty, struct pdp_t *pdp)
+/* Useful for v4v6 APNs, where we first iterate over v4 pool and then over v6
+   pool. param v4only can be used to avoid printing duplicates for pdp context
+   containing both IPv4 and IPv6 addresses. */
+static void show_one_pdp_v4only(struct vty *vty, struct pdp_t *pdp, bool v4only)
 {
-	struct ippoolm_t *peer;
+	struct ippoolm_t *peer4, *peer6;
 	char name_buf[256];
 	char *apn_name;
 	int rc;
 
+	peer4 = pdp_get_peer_ipv(pdp, false);
+	peer6 = pdp_get_peer_ipv(pdp, true);
+
+	if (v4only && peer6)
+		return;
+
 	/* Attempt to decode MSISDN */
 	rc = gsm48_decode_bcd_number2(name_buf, sizeof(name_buf),
 				      pdp->msisdn.v, pdp->msisdn.l, 0);
@@ -759,16 +768,21 @@
 	apn_name = osmo_apn_to_str(name_buf, pdp->apn_use.v, pdp->apn_use.l);
 	vty_out(vty, " APN in use: %s%s", apn_name ? name_buf : "(NONE)", VTY_NEWLINE);
 
-	if ((peer = pdp_get_peer_ipv(pdp, false)))
+	if (peer4)
 		vty_out(vty, " End-User Address (IPv4): %s%s",
-			in46a_ntop(&peer->addr, name_buf, sizeof(name_buf)), VTY_NEWLINE);
-	if ((peer = pdp_get_peer_ipv(pdp, true)))
+			in46a_ntop(&peer4->addr, name_buf, sizeof(name_buf)), VTY_NEWLINE);
+	if (peer6)
 		vty_out(vty, " End-User Address (IPv6): %s%s",
-			in46a_ntop(&peer->addr, name_buf, sizeof(name_buf)), VTY_NEWLINE);
+			in46a_ntop(&peer6->addr, name_buf, sizeof(name_buf)), VTY_NEWLINE);
 	vty_out(vty, " Transmit GTP Sequence Number for G-PDU: %s%s",
 		pdp->tx_gpdu_seq ? "Yes" : "No", VTY_NEWLINE);
 }
 
+static void show_one_pdp(struct vty *vty, struct pdp_t *pdp)
+{
+	show_one_pdp_v4only(vty, pdp, false);
+}
+
 DEFUN(show_pdpctx_imsi, show_pdpctx_imsi_cmd,
 	"show pdp-context ggsn NAME imsi IMSI [<0-15>]",
 	SHOW_STR "Display information on PDP Context\n"
@@ -853,7 +867,7 @@
 }
 
 /* show all (active) PDP contexts within a pool */
-static void ippool_show_pdp_contexts(struct vty *vty, struct ippool_t *pool)
+static void ippool_show_pdp_contexts(struct vty *vty, struct ippool_t *pool, bool pdp_v4only)
 {
 	unsigned int i;
 
@@ -864,15 +878,15 @@
 		struct ippoolm_t *member = &pool->member[i];
 		if (member->inuse == 0)
 			continue;
-		show_one_pdp(vty, member->peer);
+		show_one_pdp_v4only(vty, member->peer, pdp_v4only);
 	}
 }
 
 /* show all (active) PDP contexts within an APN */
 static void apn_show_pdp_contexts(struct vty *vty, struct apn_ctx *apn)
 {
-	ippool_show_pdp_contexts(vty, apn->v4.pool);
-	ippool_show_pdp_contexts(vty, apn->v6.pool);
+	ippool_show_pdp_contexts(vty, apn->v4.pool, true);
+	ippool_show_pdp_contexts(vty, apn->v6.pool, false);
 }
 
 DEFUN(show_pdpctx, show_pdpctx_cmd,

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/15253
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I98db39a710a72a1438d71aabaf4f8227984643e3
Gerrit-Change-Number: 15253
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190820/263696ac/attachment.htm>


More information about the gerrit-log mailing list