<p>Pau Espin Pedrol has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/14286">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gtp: Document free pdp ctx in non-teardown scenario<br><br>Code modified actually behaves the same, since gtp_freepdp() also calls<br>delete cb, and this way it's more consistent with rest of the code base.<br><br>Change-Id: Ia47ac792111fe1e9aa68222b32b5da823642206b<br>---<br>M gtp/gtp.c<br>1 file changed, 39 insertions(+), 14 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/86/14286/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/gtp/gtp.c b/gtp/gtp.c</span><br><span>index c57ecff..87aa9f9 100644</span><br><span>--- a/gtp/gtp.c</span><br><span>+++ b/gtp/gtp.c</span><br><span>@@ -2397,13 +2397,26 @@</span><br><span> if (teardown) { /* Remove all contexts */</span><br><span> gtp_freepdp_teardown(gsn, linked_pdp);</span><br><span> } else {</span><br><span style="color: hsl(0, 100%, 40%);">- if (gsn->cb_delete_context)</span><br><span style="color: hsl(0, 100%, 40%);">- gsn->cb_delete_context(pdp);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* If we end up here (no teardown) it means we still</span><br><span style="color: hsl(120, 100%, 40%);">+ have at least another pdp context active for this</span><br><span style="color: hsl(120, 100%, 40%);">+ PDN connection (since last DeleteReq should come</span><br><span style="color: hsl(120, 100%, 40%);">+ with teardown enabled). If the ctx to delete is a</span><br><span style="color: hsl(120, 100%, 40%);">+ secondary ctx, simply free it. If it's the primary</span><br><span style="color: hsl(120, 100%, 40%);">+ ctx, mark it as nodata but don't free it since we</span><br><span style="color: hsl(120, 100%, 40%);">+ need it to hold data linked together and we'll</span><br><span style="color: hsl(120, 100%, 40%);">+ require it later to tear down the entire tree. Still,</span><br><span style="color: hsl(120, 100%, 40%);">+ we announce its deletion through cb_delete_context</span><br><span style="color: hsl(120, 100%, 40%);">+ because we don't want user to release its related</span><br><span style="color: hsl(120, 100%, 40%);">+ data and not use it anymore.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span> if (pdp == linked_pdp) {</span><br><span style="color: hsl(0, 100%, 40%);">- linked_pdp->secondary_tei[pdp->nsapi & 0xf0] = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- linked_pdp->nodata = 1;</span><br><span style="color: hsl(0, 100%, 40%);">- } else</span><br><span style="color: hsl(0, 100%, 40%);">- pdp_freepdp(pdp);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (gsn->cb_delete_context)</span><br><span style="color: hsl(120, 100%, 40%);">+ gsn->cb_delete_context(pdp);</span><br><span style="color: hsl(120, 100%, 40%);">+ pdp->secondary_tei[pdp->nsapi & 0xf0] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ pdp->nodata = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ gtp_freepdp(gsn, pdp);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span> return 0;</span><br><span>@@ -2473,15 +2486,27 @@</span><br><span> if (cause == GTPCAUSE_ACC_REQ) {</span><br><span> if ((teardown) || (version == 0)) { /* Remove all contexts */</span><br><span> gtp_freepdp_teardown(gsn, linked_pdp);</span><br><span style="color: hsl(0, 100%, 40%);">- } else { /* Remove only current context */</span><br><span style="color: hsl(0, 100%, 40%);">- if (gsn->cb_delete_context)</span><br><span style="color: hsl(0, 100%, 40%);">- gsn->cb_delete_context(pdp);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* If we end up here (no teardown) it means we still</span><br><span style="color: hsl(120, 100%, 40%);">+ have at least another pdp context active for this</span><br><span style="color: hsl(120, 100%, 40%);">+ PDN connection (since last DeleteReq should come</span><br><span style="color: hsl(120, 100%, 40%);">+ with teardown enabled). If the ctx to delete is a</span><br><span style="color: hsl(120, 100%, 40%);">+ secondary ctx, simply free it. If it's the primary</span><br><span style="color: hsl(120, 100%, 40%);">+ ctx, mark it as nodata but don't free it since we</span><br><span style="color: hsl(120, 100%, 40%);">+ need it to hold data linked together and we'll</span><br><span style="color: hsl(120, 100%, 40%);">+ require it later to tear down the entire tree. Still,</span><br><span style="color: hsl(120, 100%, 40%);">+ we announce its deletion through cb_delete_context</span><br><span style="color: hsl(120, 100%, 40%);">+ because we don't want user to release its related</span><br><span style="color: hsl(120, 100%, 40%);">+ data and not use it anymore.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span> if (pdp == linked_pdp) {</span><br><span style="color: hsl(0, 100%, 40%);">- linked_pdp->secondary_tei[pdp->nsapi & 0xf0] =</span><br><span style="color: hsl(0, 100%, 40%);">- 0;</span><br><span style="color: hsl(0, 100%, 40%);">- linked_pdp->nodata = 1;</span><br><span style="color: hsl(0, 100%, 40%);">- } else</span><br><span style="color: hsl(0, 100%, 40%);">- pdp_freepdp(pdp);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (gsn->cb_delete_context)</span><br><span style="color: hsl(120, 100%, 40%);">+ gsn->cb_delete_context(pdp);</span><br><span style="color: hsl(120, 100%, 40%);">+ pdp->secondary_tei[pdp->nsapi & 0xf0] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ pdp->nodata = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ gtp_freepdp(gsn, pdp);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> }</span><br><span> /* if (cause == GTPCAUSE_ACC_REQ) */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/14286">change 14286</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/14286"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: osmo-ggsn </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ia47ac792111fe1e9aa68222b32b5da823642206b </div>
<div style="display:none"> Gerrit-Change-Number: 14286 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Pau Espin Pedrol <pespin@sysmocom.de> </div>