Change in osmo-ggsn[master]: osmo-ggsn: fix VTY command for getting PDP contexts by APN

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


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

Change subject: osmo-ggsn: fix VTY command for getting PDP contexts by APN
......................................................................

osmo-ggsn: fix VTY command for getting PDP contexts by APN

Change-Id: I0a7f4b245c4664afdae83c660358acb1a5f88ce5
---
M ggsn/ggsn_vty.c
1 file changed, 38 insertions(+), 12 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 53f4ebf..f55bd9b 100644
--- a/ggsn/ggsn_vty.c
+++ b/ggsn/ggsn_vty.c
@@ -805,9 +805,9 @@
 }
 
 DEFUN(show_pdpctx, show_pdpctx_cmd,
-	"show pdp-context ggsn NAME [apn APN]",
+	"show pdp-context ggsn NAME",
 	SHOW_STR "Show PDP Context Information\n"
-	GGSN_STR "GGSN Name\n") // FIXME
+	GGSN_STR "GGSN Name\n")
 {
 	struct ggsn_ctx *ggsn;
 	struct apn_ctx *apn;
@@ -817,21 +817,45 @@
 		vty_out(vty, "%% No such GGSN '%s'%s", argv[0], VTY_NEWLINE);
 		return CMD_WARNING;
 	}
-	if (argc < 2) {
-		llist_for_each_entry(apn, &ggsn->apn_list, list)
-			apn_show_pdp_contexts(vty, apn);
-	} else {
-		apn = ggsn_find_apn(ggsn, argv[1]);
-		if (!apn) {
-			vty_out(vty, "%% No such APN '%s'%s", argv[1], VTY_NEWLINE);
-			return CMD_WARNING;
-		}
+
+	llist_for_each_entry(apn, &ggsn->apn_list, list)
 		apn_show_pdp_contexts(vty, apn);
-	}
 
 	return CMD_SUCCESS;
 }
 
+DEFUN(show_pdpctx_apn, show_pdpctx_apn_cmd,
+	"show pdp-context ggsn NAME apn APN",
+	SHOW_STR "Show PDP Context Information\n"
+	GGSN_STR "GGSN Name\n" "Filter by APN\n" "APN name\n")
+{
+	struct ggsn_ctx *ggsn;
+	struct apn_ctx *apn;
+
+	ggsn = ggsn_find(argv[0]);
+	if (!ggsn) {
+		vty_out(vty, "%% No such GGSN '%s'%s", argv[0], VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	apn = ggsn_find_apn(ggsn, argv[1]);
+	if (!apn) {
+		vty_out(vty, "%% No such APN '%s'%s", argv[1], VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	apn_show_pdp_contexts(vty, apn);
+	return CMD_SUCCESS;
+}
+
+/* Backwards compatibility: the VTY parser is (mis)interpreting
+ * "[apn APN]" as two separate elements: "[apn" and "APN]",
+ * but the first part somehow turns into command "ap". */
+ALIAS_DEPRECATED(show_pdpctx_apn, show_deprecated_pdpctx_apn_cmd,
+		 "show pdp-context ggsn NAME ap APN",
+		 SHOW_STR "Show PDP Context Information\n"
+		 GGSN_STR "GGSN Name\n" "Filter by APN\n" "APN name\n");
+
 static void show_apn(struct vty *vty, struct apn_ctx *apn)
 {
 	vty_out(vty, " APN: %s%s", apn->cfg.name, VTY_NEWLINE);
@@ -871,6 +895,8 @@
 int ggsn_vty_init(void)
 {
 	install_element_ve(&show_pdpctx_cmd);
+	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_ggsn_cmd);
 

-- 
To view, visit https://gerrit.osmocom.org/14009
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: I0a7f4b245c4664afdae83c660358acb1a5f88ce5
Gerrit-Change-Number: 14009
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/84ce2451/attachment.html>


More information about the gerrit-log mailing list