Change in ...osmo-ggsn[master]: gtp-kernel.c: Fix wrong use of in46a_from_eua, print IPv6 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/.

laforge gerrit-no-reply at lists.osmocom.org
Thu Aug 29 05:28:06 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-ggsn/+/15251 )

Change subject: gtp-kernel.c: Fix wrong use of in46a_from_eua, print IPv6 euas
......................................................................

gtp-kernel.c: Fix wrong use of in46a_from_eua, print IPv6 euas

in46a_from_eua() API documentation clearly states an array of 2 items
should be passed as pointer, but show_one_pdp() was passing only one,
which would end up in out-of-bounds writes on v4v6 EUAs.

Let's better use ippool to print allocated ip addresses instead of
parsing EUAs we sent some point in the past.

Change-Id: I7e164f40f50de43027bcd4464aa879450d2fb10e
---
M lib/gtp-kernel.c
1 file changed, 13 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  osmith: Looks good to me, approved
  laforge: Looks good to me, but someone else must approve



diff --git a/lib/gtp-kernel.c b/lib/gtp-kernel.c
index 48811bc..f6df408 100644
--- a/lib/gtp-kernel.c
+++ b/lib/gtp-kernel.c
@@ -26,6 +26,8 @@
 
 #include "../lib/tun.h"
 #include "../lib/syserr.h"
+#include "../lib/util.h"
+#include "../lib/ippool.h"
 #include "../gtp/pdp.h"
 #include "../gtp/gtp.h"
 
@@ -37,16 +39,23 @@
 
 static void pdp_debug(const char *prefix, const char *devname, struct pdp_t *pdp)
 {
-	struct in46_addr ia46;
+	char buf4[INET_ADDRSTRLEN], buf6[INET6_ADDRSTRLEN];
+	struct ippoolm_t *peer;
 	struct in_addr ia;
 
-	in46a_from_eua(&pdp->eua, &ia46);
+	buf4[0] = '\0';
+	if ((peer = pdp_get_peer_ipv(pdp, false)))
+		in46a_ntop(&peer->addr, buf4, sizeof(buf4));
+	buf6[0] = '\0';
+	if ((peer = pdp_get_peer_ipv(pdp, true)))
+		in46a_ntop(&peer->addr, buf6, sizeof(buf6));
+
 	gsna2in_addr(&ia, &pdp->gsnrc);
 
-	LOGPDPX(DGGSN, LOGL_DEBUG, pdp, "%s %s v%u TEID %"PRIx64" EUA=%s SGSN=%s\n", prefix,
+	LOGPDPX(DGGSN, LOGL_DEBUG, pdp, "%s %s v%u TEID %"PRIx64" EUA=(%s,%s) SGSN=%s\n", prefix,
 		devname, pdp->version,
 		pdp->version == 0 ? pdp_gettid(pdp->imsi, pdp->nsapi) : pdp->teid_gn,
-		in46a_ntoa(&ia46), inet_ntoa(ia));
+		buf4, buf6, inet_ntoa(ia));
 }
 
 static struct {

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

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I7e164f40f50de43027bcd4464aa879450d2fb10e
Gerrit-Change-Number: 15251
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190829/f2ae5906/attachment.htm>


More information about the gerrit-log mailing list