Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/14286


Change subject: gtp: Document free pdp ctx in non-teardown scenario
......................................................................

gtp: Document free pdp ctx in non-teardown scenario

Code modified actually behaves the same, since gtp_freepdp() also calls
delete cb, and this way it's more consistent with rest of the code base.

Change-Id: Ia47ac792111fe1e9aa68222b32b5da823642206b
---
M gtp/gtp.c
1 file changed, 39 insertions(+), 14 deletions(-)



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

diff --git a/gtp/gtp.c b/gtp/gtp.c
index c57ecff..87aa9f9 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -2397,13 +2397,26 @@
        if (teardown) {         /* Remove all contexts */
                gtp_freepdp_teardown(gsn, linked_pdp);
        } else {
-               if (gsn->cb_delete_context)
-                       gsn->cb_delete_context(pdp);
+               /* If we end up here (no teardown) it means we still
+                  have at least another pdp context active for this
+                  PDN connection (since last DeleteReq should come
+                  with teardown enabled). If the ctx to delete is a
+                  secondary ctx, simply free it. If it's the primary
+                  ctx, mark it as nodata but don't free it since we
+                  need it to hold data linked together and we'll
+                  require it later to tear down the entire tree. Still,
+                  we announce its deletion through cb_delete_context
+                  because we don't want user to release its related
+                  data and not use it anymore.
+                */
                if (pdp == linked_pdp) {
-                       linked_pdp->secondary_tei[pdp->nsapi & 0xf0] = 0;
-                       linked_pdp->nodata = 1;
-               } else
-                       pdp_freepdp(pdp);
+                       if (gsn->cb_delete_context)
+                               gsn->cb_delete_context(pdp);
+                       pdp->secondary_tei[pdp->nsapi & 0xf0] = 0;
+                       pdp->nodata = 1;
+               } else {
+                       gtp_freepdp(gsn, pdp);
+               }
        }

        return 0;
@@ -2473,15 +2486,27 @@
        if (cause == GTPCAUSE_ACC_REQ) {
                if ((teardown) || (version == 0)) {     /* Remove all contexts 
*/
                        gtp_freepdp_teardown(gsn, linked_pdp);
-               } else {        /* Remove only current context */
-                       if (gsn->cb_delete_context)
-                               gsn->cb_delete_context(pdp);
+               } else {
+                       /* If we end up here (no teardown) it means we still
+                          have at least another pdp context active for this
+                          PDN connection (since last DeleteReq should come
+                          with teardown enabled). If the ctx to delete is a
+                          secondary ctx, simply free it. If it's the primary
+                          ctx, mark it as nodata but don't free it since we
+                          need it to hold data linked together and we'll
+                          require it later to tear down the entire tree. Still,
+                          we announce its deletion through cb_delete_context
+                          because we don't want user to release its related
+                          data and not use it anymore.
+                        */
                        if (pdp == linked_pdp) {
-                               linked_pdp->secondary_tei[pdp->nsapi & 0xf0] =
-                                   0;
-                               linked_pdp->nodata = 1;
-                       } else
-                               pdp_freepdp(pdp);
+                               if (gsn->cb_delete_context)
+                                       gsn->cb_delete_context(pdp);
+                               pdp->secondary_tei[pdp->nsapi & 0xf0] = 0;
+                               pdp->nodata = 1;
+                       } else {
+                               gtp_freepdp(gsn, pdp);
+                       }
                }
        }
        /* if (cause == GTPCAUSE_ACC_REQ) */

--
To view, visit https://gerrit.osmocom.org/14286
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: Ia47ac792111fe1e9aa68222b32b5da823642206b
Gerrit-Change-Number: 14286
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <[email protected]>

Reply via email to