Change in ...osmo-ggsn[master]: gtp: Introduce new pdp APIs (and deprecate old ones) to support multi...

2019-06-04 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ggsn/+/14296 )

Change subject: gtp: Introduce new pdp APIs (and deprecate old ones) to support 
multiple GSN
..


Patch Set 3: Code-Review+2


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

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I653cbdc185165592d985e3efab6e3f1add97877b
Gerrit-Change-Number: 14296
Gerrit-PatchSet: 3
Gerrit-Owner: pespin 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Tue, 04 Jun 2019 18:46:45 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in ...osmo-ggsn[master]: gtp: Introduce new pdp APIs (and deprecate old ones) to support multi...

2019-06-04 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/c/osmo-ggsn/+/14296 )

Change subject: gtp: Introduce new pdp APIs (and deprecate old ones) to support 
multiple GSN
..

gtp: Introduce new pdp APIs (and deprecate old ones) to support multiple GSN

Move static global pdp storage arrays to be per GSN. This way now
several GSN per process are supported without collisions.

* pdp_init() is defined in public API but it's actually only intended
for use (and currently only used) internally in gtp_new(). So let's
document that and re-use it for backward compatibility with now
deprecated API, where only one GSN per process is supported.

* Back pointer to gsn_t (pdp->gsn) moved from gtp.c:gtp_new() to
gtp_pdp_newpdp(), since it makes more sense to have it there. This way
backpointer is always set, even in case were app calls pdp_newpdp() API
directly instead of creating them through gtp.c, like osmo-sgsn does.

* Create new versions of required APIs with a pointer to gsn_t where the
pdp ctx is to be created/found. Some APIs receiving a pointer to a pdp
ctx can be left intact because we have a backpointer to its gsn_t.

* pdp_getpdp() is nowhere used, and makes little sense now that we have
pdpa reachable in gsn->pdpa, so let's deprecate it without adding a
replacement.

* Deprecate gtp.h gtp_newpdp(), since it's nowhere used and useless
(does same as new gtp_pdp_newpdp() and doesn't allow for old_pdp to be
passed as parameter).

Fixes: OS#2873
Change-Id: I653cbdc185165592d985e3efab6e3f1add97877b
---
M TODO-RELEASE
M gtp/gtp.c
M gtp/gtp.h
M gtp/pdp.c
M gtp/pdp.h
5 files changed, 90 insertions(+), 37 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/TODO-RELEASE b/TODO-RELEASE
index d0852fc..a3d63ac 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,6 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public 
release: c:r:0.
 #library   whatdescription / commit summary line
+libgtp Several new APIs added  see I653cbdc185165592d985e3efab6e3f1add97877b
+libgtp API (non-used externally) pdp_init modified see 
I653cbdc185165592d985e3efab6e3f1add97877b
+libgtp Several pdp_* APIs marked as deprecated see 
I653cbdc185165592d985e3efab6e3f1add97877b
diff --git a/gtp/gtp.c b/gtp/gtp.c
index 2b14026..84b8844 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -131,16 +131,12 @@
{ 0, NULL }
 };

-/* gtp_new */
-/* gtp_free */
-
+/* Deprecated, use gtp_pdp_newpdp() instead */
 int gtp_newpdp(struct gsn_t *gsn, struct pdp_t **pdp,
   uint64_t imsi, uint8_t nsapi)
 {
int rc;
-   rc = pdp_newpdp(pdp, imsi, nsapi, NULL);
-   if (!rc && *pdp)
-   (*pdp)->gsn = gsn;
+   rc = gtp_pdp_newpdp(gsn, pdp, imsi, nsapi, NULL);
return rc;
 }

@@ -849,7 +845,7 @@
queue_new(&(*gsn)->queue_resp);

/* Initialise pdp table */
-   pdp_init();
+   pdp_init(*gsn);

/* Initialise call back functions */
(*gsn)->cb_create_context_ind = 0;
@@ -1681,9 +1677,7 @@
}
}

-   pdp_newpdp(, pdp->imsi, pdp->nsapi, pdp);
-   if (pdp)
-   pdp->gsn = gsn;
+   gtp_pdp_newpdp(gsn, , pdp->imsi, pdp->nsapi, pdp);

/* Callback function to validate login */
if (gsn->cb_create_context_ind != 0)
diff --git a/gtp/gtp.h b/gtp/gtp.h
index ec6aef3..c2c5122 100644
--- a/gtp/gtp.h
+++ b/gtp/gtp.h
@@ -15,6 +15,8 @@
 #include 
 #include 

+#include "pdp.h"
+
 #define GTP_MODE_GGSN 1
 #define GTP_MODE_SGSN 2

@@ -263,6 +265,9 @@
struct queue_t *queue_req;  /* Request queue */
struct queue_t *queue_resp; /* Response queue */

+   struct pdp_t pdpa[PDP_MAX]; /* PDP storage */
+   struct pdp_t *hashtid[PDP_MAX]; /* Hash table for IMSI + NSAPI */
+
/* Call back functions */
int (*cb_delete_context) (struct pdp_t *);
int (*cb_create_context_ind) (struct pdp_t *);
@@ -307,7 +312,7 @@
 extern int gtp_free(struct gsn_t *gsn);

 extern int gtp_newpdp(struct gsn_t *gsn, struct pdp_t **pdp,
- uint64_t imsi, uint8_t nsapi);
+ uint64_t imsi, uint8_t nsapi) OSMO_DEPRECATED("Use 
gtp_pdp_newpdp() instead");
 extern int gtp_freepdp(struct gsn_t *gsn, struct pdp_t *pdp);
 extern int gtp_freepdp_teardown(struct gsn_t *gsn, struct pdp_t *pdp);

diff --git a/gtp/pdp.c b/gtp/pdp.c
index a5146e9..d745916 100644
--- a/gtp/pdp.c
+++ b/gtp/pdp.c
@@ -33,13 +33,6 @@
 #include "lookupa.h"

 /* ***
- * Global variables TODO: most should be moved to gsn_t
- */
-
-static struct pdp_t pdpa[PDP_MAX]; /* PDP storage */
-static struct pdp_t *hashtid[PDP_MAX]; /* Hash 

Change in osmo-ggsn[master]: gtp: Introduce new pdp APIs (and deprecate old ones) to support multi...

2019-05-31 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/14296 )

Change subject: gtp: Introduce new pdp APIs (and deprecate old ones) to support 
multiple GSN
..


Patch Set 2: Code-Review+1


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

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I653cbdc185165592d985e3efab6e3f1add97877b
Gerrit-Change-Number: 14296
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Fri, 31 May 2019 20:46:08 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ggsn[master]: gtp: Introduce new pdp APIs (and deprecate old ones) to support multi...

2019-05-31 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded a new patch set (#2). ( 
https://gerrit.osmocom.org/14296 )

Change subject: gtp: Introduce new pdp APIs (and deprecate old ones) to support 
multiple GSN
..

gtp: Introduce new pdp APIs (and deprecate old ones) to support multiple GSN

Move static global pdp storage arrays to be per GSN. This way now
several GSN per process are supported without collisions.

* pdp_init() is defined in public API but it's actually only intended
for use (and currently only used) internally in gtp_new(). So let's
document that and re-use it for backward compatibility with now
deprecated API, where only one GSN per process is supported.

* Back pointer to gsn_t (pdp->gsn) moved from gtp.c:gtp_new() to
gtp_pdp_newpdp(), since it makes more sense to have it there. This way
backpointer is always set, even in case were app calls pdp_newpdp() API
directly instead of creating them through gtp.c, like osmo-sgsn does.

* Create new versions of required APIs with a pointer to gsn_t where the
pdp ctx is to be created/found. Some APIs receiving a pointer to a pdp
ctx can be left intact because we have a backpointer to its gsn_t.

* pdp_getpdp() is nowhere used, and makes little sense now that we have
pdpa reachable in gsn->pdpa, so let's deprecate it without adding a
replacement.

* Deprecate gtp.h gtp_newpdp(), since it's nowhere used and useless
(does same as new gtp_pdp_newpdp() and doesn't allow for old_pdp to be
passed as parameter).

Fixes: OS#2873
Change-Id: I653cbdc185165592d985e3efab6e3f1add97877b
---
M TODO-RELEASE
M gtp/gtp.c
M gtp/gtp.h
M gtp/pdp.c
M gtp/pdp.h
5 files changed, 90 insertions(+), 37 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/96/14296/2
--
To view, visit https://gerrit.osmocom.org/14296
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I653cbdc185165592d985e3efab6e3f1add97877b
Gerrit-Change-Number: 14296
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol 


Change in osmo-ggsn[master]: gtp: Introduce new pdp APIs (and deprecate old ones) to support multi...

2019-05-31 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/14296


Change subject: gtp: Introduce new pdp APIs (and deprecate old ones) to support 
multiple GSN
..

gtp: Introduce new pdp APIs (and deprecate old ones) to support multiple GSN

Move static global pdp storage arrays to be per GSN. This way now
several GSN per process are supported without collisions.

* pdp_init() is defined in public API but it's actually only intended
for use (and currently only used) internally in gtp_new(). So let's
document that and re-use it for backward compatibility with now
deprecated API, where only one GSN per process is supported.

* Back pointer to gsn_t (pdp->gsn) moved from gtp.c:gtp_new() to
gtp_pdp_newpdp(), since it makes more sense to have it there. This way
backpointer is always set, even in case were app calls pdp_newpdp() API
directly instead of creating them through gtp.c, like osmo-sgsn does.

* Create new versions of required APIs with a pointer to gsn_t where the
pdp ctx is to be created/found. Some APIs receiving a pointer to a pdp
ctx can be left intact because we have a backpointer to its gsn_t.

* pdp_getpdp() is nowhere used, and makes little sense now that we have
pdpa reachable in gsn->pdpa, so let's deprecate it without adding a
replacement.

* Deprecate gtp.h gtp_newpdp(), since it's nowhere used and useless
(does same as new gtp_pdp_newpdp() and doesn't allow for old_pdp to be
passed as parameter).

Fixes: OS#2873
Change-Id: I653cbdc185165592d985e3efab6e3f1add97877b
---
M gtp/gtp.c
M gtp/gtp.h
M gtp/pdp.c
M gtp/pdp.h
4 files changed, 87 insertions(+), 37 deletions(-)



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

diff --git a/gtp/gtp.c b/gtp/gtp.c
index 2b14026..84b8844 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -131,16 +131,12 @@
{ 0, NULL }
 };

-/* gtp_new */
-/* gtp_free */
-
+/* Deprecated, use gtp_pdp_newpdp() instead */
 int gtp_newpdp(struct gsn_t *gsn, struct pdp_t **pdp,
   uint64_t imsi, uint8_t nsapi)
 {
int rc;
-   rc = pdp_newpdp(pdp, imsi, nsapi, NULL);
-   if (!rc && *pdp)
-   (*pdp)->gsn = gsn;
+   rc = gtp_pdp_newpdp(gsn, pdp, imsi, nsapi, NULL);
return rc;
 }

@@ -849,7 +845,7 @@
queue_new(&(*gsn)->queue_resp);

/* Initialise pdp table */
-   pdp_init();
+   pdp_init(*gsn);

/* Initialise call back functions */
(*gsn)->cb_create_context_ind = 0;
@@ -1681,9 +1677,7 @@
}
}

-   pdp_newpdp(, pdp->imsi, pdp->nsapi, pdp);
-   if (pdp)
-   pdp->gsn = gsn;
+   gtp_pdp_newpdp(gsn, , pdp->imsi, pdp->nsapi, pdp);

/* Callback function to validate login */
if (gsn->cb_create_context_ind != 0)
diff --git a/gtp/gtp.h b/gtp/gtp.h
index ec6aef3..c2c5122 100644
--- a/gtp/gtp.h
+++ b/gtp/gtp.h
@@ -15,6 +15,8 @@
 #include 
 #include 

+#include "pdp.h"
+
 #define GTP_MODE_GGSN 1
 #define GTP_MODE_SGSN 2

@@ -263,6 +265,9 @@
struct queue_t *queue_req;  /* Request queue */
struct queue_t *queue_resp; /* Response queue */

+   struct pdp_t pdpa[PDP_MAX]; /* PDP storage */
+   struct pdp_t *hashtid[PDP_MAX]; /* Hash table for IMSI + NSAPI */
+
/* Call back functions */
int (*cb_delete_context) (struct pdp_t *);
int (*cb_create_context_ind) (struct pdp_t *);
@@ -307,7 +312,7 @@
 extern int gtp_free(struct gsn_t *gsn);

 extern int gtp_newpdp(struct gsn_t *gsn, struct pdp_t **pdp,
- uint64_t imsi, uint8_t nsapi);
+ uint64_t imsi, uint8_t nsapi) OSMO_DEPRECATED("Use 
gtp_pdp_newpdp() instead");
 extern int gtp_freepdp(struct gsn_t *gsn, struct pdp_t *pdp);
 extern int gtp_freepdp_teardown(struct gsn_t *gsn, struct pdp_t *pdp);

diff --git a/gtp/pdp.c b/gtp/pdp.c
index a5146e9..d745916 100644
--- a/gtp/pdp.c
+++ b/gtp/pdp.c
@@ -33,13 +33,6 @@
 #include "lookupa.h"

 /* ***
- * Global variables TODO: most should be moved to gsn_t
- */
-
-static struct pdp_t pdpa[PDP_MAX]; /* PDP storage */
-static struct pdp_t *hashtid[PDP_MAX]; /* Hash table for IMSI + NSAPI */
-
-/* ***
  * Functions related to PDP storage
  *
  * Lifecycle
@@ -111,11 +104,16 @@
  *
  */

-int pdp_init()
+static struct gsn_t *g_gsn;
+
+int pdp_init(struct gsn_t *gsn)
 {
-   memset(, 0, sizeof(pdpa));
-   memset(, 0, sizeof(hashtid));
-   /*  memset(, 0, sizeof(haship)); */
+   if(!g_gsn) {
+   g_gsn = gsn;
+   } else {
+   LOGP(DLGTP, LOGL_FATAL, "This interface is depreacted and 
doesn't support multiple GGSN!");
+   return -1;
+   }

return 0;
 }