Change in osmo-sgsn[master]: VTY: Don't display 'PDP Address: invalid' for IPv4v6

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

keith gerrit-no-reply at lists.osmocom.org
Wed Oct 6 14:26:02 UTC 2021


keith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/25649 )

Change subject: VTY: Don't display 'PDP Address: invalid' for IPv4v6
......................................................................

VTY: Don't display 'PDP Address: invalid' for IPv4v6

We were not handling the case of PDP_TYPE_N_IETF_IPv4v6
in gprs_pdpaddr2str() and showed "invalid" for these addresses.

Depends: libosmocore Change-Id: I1f82f9d8fc13dcc4474760329bd74ae9685b9031
Change-Id: Id36b7520677e4a0af40d05dc503b26d1b0b74a26
---
M include/osmocom/sgsn/gprs_sgsn.h
M src/sgsn/sgsn_ctrl.c
M src/sgsn/sgsn_vty.c
3 files changed, 24 insertions(+), 6 deletions(-)

Approvals:
  pespin: Looks good to me, but someone else must approve
  dexter: Looks good to me, but someone else must approve
  keith: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/sgsn/gprs_sgsn.h b/include/osmocom/sgsn/gprs_sgsn.h
index c176494..dcda5c3 100644
--- a/include/osmocom/sgsn/gprs_sgsn.h
+++ b/include/osmocom/sgsn/gprs_sgsn.h
@@ -417,7 +417,7 @@
 struct sgsn_instance *sgsn_instance_alloc(void *talloc_ctx);
 void sgsn_inst_init(struct sgsn_instance *sgsn);
 
-char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len);
+char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len, bool return_ipv6);
 
 /*
  * ctrl interface related work
diff --git a/src/sgsn/sgsn_ctrl.c b/src/sgsn/sgsn_ctrl.c
index ad91d25..69034e2 100644
--- a/src/sgsn/sgsn_ctrl.c
+++ b/src/sgsn/sgsn_ctrl.c
@@ -43,7 +43,7 @@
 
 		llist_for_each_entry(pdp, &mm->pdp_list, list)
 			addr = gprs_pdpaddr2str(pdp->lib->eua.v,
-						pdp->lib->eua.l);
+						pdp->lib->eua.l, false);
 
 		cmd->reply = talloc_asprintf_append(
 					cmd->reply,
diff --git a/src/sgsn/sgsn_vty.c b/src/sgsn/sgsn_vty.c
index e0e2677..6327d1a 100644
--- a/src/sgsn/sgsn_vty.c
+++ b/src/sgsn/sgsn_vty.c
@@ -135,7 +135,7 @@
 	return osmo_tdef_vty_set_cmd(vty, g_cfg->T_defs, argv);
 }
 
-char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len)
+char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len, bool return_ipv6)
 {
 	static char str[INET6_ADDRSTRLEN + 10];
 
@@ -148,15 +148,28 @@
 		case PDP_TYPE_N_IETF_IPv4:
 			if (len < 2 + 4)
 				break;
-			strcpy(str, "IPv4 ");
+			osmo_strlcpy(str, "IPv4 ", sizeof(str));
 			inet_ntop(AF_INET, pdpa+2, str+5, sizeof(str)-5);
 			return str;
 		case PDP_TYPE_N_IETF_IPv6:
 			if (len < 2 + 8)
 				break;
-			strcpy(str, "IPv6 ");
+			osmo_strlcpy(str, "IPv6 ", sizeof(str));
 			inet_ntop(AF_INET6, pdpa+2, str+5, sizeof(str)-5);
 			return str;
+		case PDP_TYPE_N_IETF_IPv4v6:
+			if (len < 2 + 20)
+				break;
+			if (return_ipv6) {
+				/* The IPv6 token, (rightmost four fields) is a duplicate of
+				 * the site prefix + subnetID (leftmost fields) in pdpa here */
+				osmo_strlcpy(str, "IPv6 ", sizeof(str));
+				inet_ntop(AF_INET6, pdpa+6, str+5, sizeof(str)-5);
+				return str;
+			}
+			osmo_strlcpy(str, "IPv4 ", sizeof(str));
+			inet_ntop(AF_INET, pdpa+2, str+5, sizeof(str)-5);
+			return str;
 		default:
 			break;
 		}
@@ -552,8 +565,13 @@
 			osmo_apn_to_str(apnbuf, pdp->lib->apn_use.v, pdp->lib->apn_use.l),
 			VTY_NEWLINE);
 		vty_out(vty, "%s  PDP Address: %s%s", pfx,
-			gprs_pdpaddr2str(pdp->lib->eua.v, pdp->lib->eua.l),
+			gprs_pdpaddr2str(pdp->lib->eua.v, pdp->lib->eua.l, false),
 			VTY_NEWLINE);
+		if (pdp->lib->eua.v[1] == PDP_TYPE_N_IETF_IPv4v6) {
+			vty_out(vty, "%s  PDP Address: %s%s", pfx,
+				gprs_pdpaddr2str(pdp->lib->eua.v, pdp->lib->eua.l, true),
+				VTY_NEWLINE);
+		}
 		vty_out(vty, "%s  GTPv%d Local Control(%s / TEIC: 0x%08x) ", pfx, pdp->lib->version,
 			sgsn_gtp_ntoa(&pdp->lib->gsnlc), pdp->lib->teic_own);
 		vty_out(vty, "Data(%s / TEID: 0x%08x)%s",

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

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: Id36b7520677e4a0af40d05dc503b26d1b0b74a26
Gerrit-Change-Number: 25649
Gerrit-PatchSet: 5
Gerrit-Owner: keith <keith at rhizomatica.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: keith <keith at rhizomatica.org>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211006/c591595e/attachment.htm>


More information about the gerrit-log mailing list