Change in osmo-ggsn[master]: osmo-ggsn: add VTY command to show PDP context by IPv4

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon May 13 12:46:43 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/14010 )

Change subject: osmo-ggsn: add VTY command to show PDP context by IPv4
......................................................................

osmo-ggsn: add VTY command to show PDP context by IPv4

Change-Id: Iad60de34c562803a1a1fc024287d1a60e071afab
---
M ggsn/ggsn_vty.c
1 file changed, 42 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved



diff --git a/ggsn/ggsn_vty.c b/ggsn/ggsn_vty.c
index f55bd9b..594c0e9 100644
--- a/ggsn/ggsn_vty.c
+++ b/ggsn/ggsn_vty.c
@@ -781,6 +781,47 @@
 		return CMD_SUCCESS;
 }
 
+DEFUN(show_pdpctx_ip, show_pdpctx_ip_cmd,
+	"show pdp-context ggsn NAME ipv4 A.B.C.D",
+	SHOW_STR "Display information on PDP Context\n"
+	GGSN_STR "GGSN Name\n" "IPv4 address type\n" "IP address\n")
+{
+	struct ggsn_ctx *ggsn;
+	struct apn_ctx *apn;
+	unsigned int i;
+
+	ggsn = ggsn_find(argv[0]);
+	if (!ggsn) {
+		vty_out(vty, "%% No such GGSN '%s'%s", argv[0], VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	/* Iterate over all APNs of a given GGSN */
+	llist_for_each_entry(apn, &ggsn->apn_list, list) {
+		struct ippool_t *pool = apn->v4.pool;
+
+		/* In some rare cases, if GGSN fails to init TUN/TAP interfaces
+		 * (e.g. due to insufficient permissions), it will continue to
+		 * work in such broken state, and pool would be NULL. */
+		if (!pool)
+			continue;
+
+		/* Iterate over all IPv4 pool members */
+		for (i = 0; i < pool->listsize; i++) {
+			struct ippoolm_t *member = &pool->member[i];
+			if (member->inuse == 0)
+				continue;
+			if (strcmp(argv[1], in46a_ntoa(&member->addr)) == 0) {
+				show_one_pdp(vty, member->peer);
+				return CMD_SUCCESS;
+			}
+		}
+	}
+
+	vty_out(vty, "%% No PDP context found for IP '%s'%s", argv[1], VTY_NEWLINE);
+	return CMD_WARNING;
+}
+
 /* show all (active) PDP contexts within a pool */
 static void ippool_show_pdp_contexts(struct vty *vty, struct ippool_t *pool)
 {
@@ -898,6 +939,7 @@
 	install_element_ve(&show_pdpctx_apn_cmd);
 	install_element_ve(&show_deprecated_pdpctx_apn_cmd);
 	install_element_ve(&show_pdpctx_imsi_cmd);
+	install_element_ve(&show_pdpctx_ip_cmd);
 	install_element_ve(&show_ggsn_cmd);
 
 	install_element(CONFIG_NODE, &cfg_ggsn_cmd);

-- 
To view, visit https://gerrit.osmocom.org/14010
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iad60de34c562803a1a1fc024287d1a60e071afab
Gerrit-Change-Number: 14010
Gerrit-PatchSet: 2
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190513/52680fdc/attachment.htm>


More information about the gerrit-log mailing list