libgtp: announce pdp ctx deletion upon CreatePdpCtx being rejected

The libgtp application  may have already allocated related resources
associated to the pdp context, so we need to signal its deletion in
order to let the application free the resources.

This should fix the duplication of pdp contexts seen in osmo-ggsn when
"show pdp-context" related VTY commands are used.
It was spotted due to some MS requesting a v4v6 context on a
v4-only APN, where first v4 address was allocated, and then upon v6
allocation create_context_ind() called
gtp_create_context_resp(GTPCAUSE_MISSING_APN) but the first address was
not freed. Upon receiving the callback, osmo-ggsn should now free the
related resources.

Related: OS#4154
Change-Id: I6c6215a4ce478afabc78ffaf5ffb0cf829e41226
This commit is contained in:
Pau Espin 2019-08-21 15:24:29 +02:00
parent 623c5b36e9
commit d950134c53
2 changed files with 3 additions and 4 deletions

View File

@ -386,7 +386,7 @@ static int delete_context(struct pdp_t *pdp)
LOGPPDP(LOGL_ERROR, pdp, "Cannot find/free IP Pool member\n");
}
if (apn->cfg.gtpu_mode == APN_GTPU_MODE_KERNEL_GTP) {
if (apn && apn->cfg.gtpu_mode == APN_GTPU_MODE_KERNEL_GTP) {
if (gtp_kernel_tunnel_del(pdp, apn->tun.cfg.dev_name)) {
LOGPPDP(LOGL_ERROR, pdp, "Cannot delete tunnel from kernel:%s\n",
strerror(errno));

View File

@ -1301,9 +1301,8 @@ int gtp_create_context_resp(struct gsn_t *gsn, struct pdp_t *pdp, int cause)
/* Now send off a reply to the peer */
gtp_create_pdp_resp(gsn, pdp->version, pdp, cause);
if (cause != GTPCAUSE_ACC_REQ) {
pdp_freepdp(pdp);
}
if (cause != GTPCAUSE_ACC_REQ)
gtp_freepdp(gsn, pdp);
return 0;
}