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

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Mon May 13 08:34:47 UTC 2019


Vadim Yanitskiy has uploaded this change for review. ( 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(-)



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

diff --git a/ggsn/ggsn_vty.c b/ggsn/ggsn_vty.c
index 7a3bf07..8333abf 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: newchange
Gerrit-Change-Id: Iad60de34c562803a1a1fc024287d1a60e071afab
Gerrit-Change-Number: 14010
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190513/ee99698c/attachment.html>


More information about the gerrit-log mailing list