aboutsummaryrefslogtreecommitdiffstats
path: root/gtp/gtp.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-08-16 13:20:09 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-08-23 14:38:56 +0200
commit623c5b36e9453f1623bc443e04627c2c31cb2619 (patch)
tree7010a41ae11c45dfc4a3683d2b34c44aa385345f /gtp/gtp.c
parentaab47afe58124981f7391a4df43821cf2f95725f (diff)
libgtp: Remove packets in tx queue belonging pdp being freed
Doing so should avoid the crash seen in OS#3956, where a message is received in osmo-sgsn gtp iface after having received a DeleteCtxAccept message where pdp and associated cbp is freed. As a result, when new confirmation arrives, it can still be matched against an old request and be sent to upper layers providing an already freed cbp. With this patch, since all queued messages belonging to that pdp are dropped, confirmation won't find a match and be discarded in libgtp. In order to be able to drop all req messages belonging to a pdp, a new list is added to pdp_t and qmsg_t are added to that list when inserted into the per-gsn req transmit queue. This way upon pdp free time it's simply a matter of iterating over that list to remove all messages. There's no need to do same for resp queue, and it'd be actually counter-productive, because it wouldn't be possible to detect and discard duplicates anymore after pdp ctx has been freed. Related: OS#3956 Change-Id: Id86d0b241454d3ad49c64c28087fd2710fa2d17a
Diffstat (limited to 'gtp/gtp.c')
-rw-r--r--gtp/gtp.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gtp/gtp.c b/gtp/gtp.c
index 94c3245..799f8a7 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -513,6 +513,8 @@ static int gtp_req(struct gsn_t *gsn, uint8_t version, struct pdp_t *pdp,
qmsg->cbp = cbp;
qmsg->type = ntoh8(packet->gtp0.h.type);
qmsg->fd = fd;
+ if (pdp) /* echo requests are not pdp-bound */
+ llist_add(&qmsg->entry, &pdp->qmsg_list_req);
}
gsn->seq_next++; /* Count up this time */
return 0;
@@ -697,6 +699,9 @@ static int gtp_resp(uint8_t version, struct gsn_t *gsn, struct pdp_t *pdp,
qmsg->cbp = NULL;
qmsg->type = 0;
qmsg->fd = fd;
+ /* No need to add to pdp list here, because even on pdp ctx free
+ we want to leave messages in queue_resp until timeout to
+ detect duplicates */
}
return 0;
}