aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2015-10-12 14:59:15 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2015-10-12 15:02:09 +0200
commit078f8e4ae0a9e7a776aaf5576aa0e8b73a19f5b5 (patch)
tree0ece19ce1a6b203a483e4b16082eadc04dd3b7b6
parent746179370c89589ce9a4e959740a8f551a27d935 (diff)
gtp_duplicate(): comment, add todo.
-rw-r--r--gtp/gtp.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/gtp/gtp.c b/gtp/gtp.c
index e6a610d..de6a7b4 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -614,6 +614,15 @@ int gtp_notification(struct gsn_t *gsn, int version,
return 0;
}
+/* Look for a message in the response queue for the given peer and sequence
+ * number seq. If found, (re-)send the response message and return 0. Otherwise
+ * return nonzero. This allows catching duplicate messages.
+ * A response message stays in the response queue until it times out.
+ * So, for any number of identical requests within that timeout period, the
+ * same packet can be resent.
+ * TODO this only checks the peer and sequence number, and does not verify that
+ * the GTP request is identical to the previous one for this peer and sequence
+ * nr: a mere peer or seq glitch can cause leaks of previous responses. */
int gtp_duplicate(struct gsn_t *gsn, int version,
struct sockaddr_in *peer, uint16_t seq)
{
@@ -873,7 +882,7 @@ int gtp_echo_ind(struct gsn_t *gsn, int version, struct sockaddr_in *peer,
int fd, void *pack, unsigned len)
{
- /* Check if it was a duplicate request */
+ /* Repeat previous response in case of duplicate request */
if (!gtp_duplicate(gsn, 0, peer, get_seq(pack)))
return 0;
@@ -1258,7 +1267,7 @@ int gtp_create_pdp_ind(struct gsn_t *gsn, int version,
uint8_t linked_nsapi = 0;
struct pdp_t *linked_pdp = NULL;
- /* TODO describe what this is all about: */
+ /* Repeat previous response in case of duplicate request */
if (!gtp_duplicate(gsn, version, peer, seq))
return 0;
@@ -1955,10 +1964,9 @@ int gtp_update_pdp_ind(struct gsn_t *gsn, int version,
uint64_t imsi;
uint8_t nsapi;
- /* Is this a duplicate ? */
- if (!gtp_duplicate(gsn, version, peer, seq)) {
- return 0; /* We already sent of response once */
- }
+ /* Repeat previous response in case of duplicate request */
+ if (!gtp_duplicate(gsn, version, peer, seq))
+ return 0;
/* Decode information elements */
if (gtpie_decaps(ie, version, pack + hlen, len - hlen)) {
@@ -2432,10 +2440,9 @@ int gtp_delete_pdp_ind(struct gsn_t *gsn, int version,
int n;
int count = 0;
- /* Is this a duplicate ? */
- if (!gtp_duplicate(gsn, version, peer, seq)) {
- return 0; /* We already sent off response once */
- }
+ /* Repeat previous response in case of duplicate request */
+ if (!gtp_duplicate(gsn, version, peer, seq))
+ return 0;
/* Find the linked context in question */
if (pdp_getgtp1(&linked_pdp, get_tei(pack))) {