Commit Graph

174 Commits

Author SHA1 Message Date
Pau Espin a3ca2d185b Bump version: 1.7.1.20-8cbd-dirty → 1.8.0
Change-Id: I21502c6e0b804237fe9bd8f5579dbabd519d6d51
2021-11-16 13:49:16 +01:00
Pau Espin f32c6a9095 gtp: Support tx/rx RAN Information Relay message
See 3GPP TS 29.060 sec 7.5.14.1 RAN Information Relay.

Related: SYS#5314
Change-Id: Iea3eb032ccd4aed5187baca7f7719349d76039d4
2021-05-06 18:57:12 +02:00
Pau Espin 2eed6ec5ec gtp: constify pointer arg
Change-Id: Ib5b5a8b64247202a2538c2ff8f8601981ccda822
2021-05-05 17:51:34 +02:00
Pau Espin 641206ad5e cosmetic: gtpie.c: Fix trailing whitespace
Change-Id: I552e3b5f694e1b49fe5e21fa4023e4a24ffc2784
2021-05-03 17:24:30 +02:00
Pau Espin bfd3119ae4 gtp: Improve logging of failing pdp ctx resolution from TEI/TID
Change-Id: I4f2084ec7e3a830e0224dd998ff0fe6654cc23bd
2021-04-22 16:24:55 +02:00
Pau Espin 00e0559e17 gtp: Rework parsing logic of UpdatePdpCtxResponse
The previous order of parsing lead to non-optimal information gathering
when pushing events to upper layers.

This patch rearranges parsing of packet data to always gather as much
info as possible for the benefit of the upper layer. This way it can
gather information such as the cause, which is important in the case of
"Non-existent", since user should then drop the context.

First we want to parse the recovery state, but delay cb to upper layers
until we tried to gather the pdp ctx (meaning all except that pdp ctx
should be freed).
Second, we want to parse the cause, in order to know if there's an
associated pdp ctx we can gather from TEID.
Third, once we know if we should expect a meaningul TEID, parse it.

Related: SYS#5435
Change-Id: Idd10b494e8fbac8703c49ecd8f9bbe4246e51c57
2021-04-22 16:24:48 +02:00
Pau Espin 0b1d9dbc40 gtp: Update teic_confirmed only on resp success
Change-Id: I54c54cbb51bfa5d1520855f448fa27511037b396
2021-04-21 19:45:23 +02:00
Pau Espin Pedrol b1f641b5b7 Bump version: 1.6.0.22-f01c-dirty → 1.7.0
Change-Id: I05d9bee0791cec5aebbeb1602be6697ecc2e2b74
2021-02-23 13:34:40 +01:00
Keith Whyte fb2a7298e0 GTP: Replace recently introduced imsi_str2gtp()
Replace with the version from osmo-sgsn, renamed so
as not to collide with that version.

Change-Id: I910d5339a823332277ce7b5854d5c943ed69ea81
2020-10-12 15:47:26 +02:00
Keith Whyte 4831851ca3 Minor: remove code duplication
Change-Id: Id18ebcd3b3c20ce28e383edf9354e9f8516e1e81
2020-10-12 13:11:26 +02:00
Keith Whyte cbc07bdd82 Fix vty PDP lookups by IMSI
The PDP context is searched on the hash which is generated
on context creation from the IMSI in gtp format. - A hash
created from "human-readable" IMSI does not match.
Check user input for length then convert the IMSI to gtp format
before continuing.

Change-Id: Icd2e2bc6068c06fbf5d5fe905ebcda8954f33f04
2020-10-12 13:11:19 +02:00
Pau Espin e71e0f2af8 Bump version: 1.4.0.32-bd8f-dirty → 1.5.0
Change-Id: I84bbe9eff37e14985b812b49e53eb6d62fff14a5
2020-01-02 20:39:39 +01:00
Pau Espin c94837c6a4 gtp: Manage queue timers internally
Currently each user (application) of libgtp needs to manage its own
timers in order to call gtp_retrans_timeout() and gtp_retrans() and
maintain retransmit and duplicate queues working correctly. This adds
unnecesary complexity to applications since nowadays, as a libosmocore
user, libgtp can handle this internally in an easy way.
Furthermore, keeping the timers internal to the library allows for
easier extension of features as well as re-implementation of related
code in the future.
Last but not least, it was detected that existing known applications
(osmo-sgsn, osmo-ggsn, sgsnemu) are not using correctly the API, since
they should be updating their timers through gtp_retrans_timeout()
everytime a message is enqueued/transmitted, otherwise they may fire
gtp_retrans() for retransmition too late in some cases.

Related: OS#4178
Change-Id: Ife7cfd66d6356f413263fe5bda9e43091f5c9e98
2019-09-05 09:59:52 +00:00
Vadim Yanitskiy 68c5a74557 gtp/gtp.c: cosmetic: use get_tid() where we need TID
Change-Id: I39e92f25ed51665c8a615826ed52f35024bdd54b
2019-09-02 09:03:43 +00:00
Vadim Yanitskiy bdf2cf9038 gtp_error_ind_conf(): fix: guard against an unknown GTP version
This change fixes the following compiler warnings (found by Clang):

  gtp.c:2747:13: warning: variable 'pdp' is used uninitialized
			  whenever 'if' condition is false
			  [-Wsometimes-uninitialized]
		 } else if (version == 1) {

  gtp.c:2781:14: note: uninitialized use occurs here
  		 OSMO_ASSERT(pdp);
			     ^^^

Shall not happen in general, but let's make Clang happy.

Change-Id: Id471b22afd4c45435589a4edda0a804e66be3a7a
2019-09-02 09:03:43 +00:00
Vadim Yanitskiy 00a6171b8d gtp_update_pdp_ind(): fix NULL-pointer dereference
As stated in the comment above, we need to use the tunnel identifier
to find a GTP context, and derive both IMSI and NSAPI from that TID,
when speaking GTP version 0.

This change fixes the following warnings (found with Clang):

  gtp.c:2115:22: warning: variable 'pdp' is uninitialized
			  when used here [-Wuninitialized]
		 pdp_set_imsi_nsapi(pdp, tid);
				    ^^^

  gtp.c:2118:34: warning: variable 'imsi' is uninitialized
			  when used here [-Wuninitialized]
		 if (gtp_pdp_getimsi(gsn, &pdp, imsi, nsapi))
						^^^^

  gtp.c:2118:40: warning: variable 'nsapi' is uninitialized
			  when used here [-Wuninitialized]
		 if (gtp_pdp_getimsi(gsn, &pdp, imsi, nsapi))
						      ^^^^^

Change-Id: I8f1c8d0ba2e8189d97fe1bb5c872680e5ad1cd7a
2019-09-02 09:03:43 +00:00
Pau Espin 4e605b32d4 cosmetic: gtp: Improve documentation of gtp_delete_context_req2()
Change-Id: I1f85c7cc7684e146fca4f17914927d45410dbb84
2019-08-29 14:07:04 +02:00
Pau Espin 494d873fe3 cosmetic: gtp: Drop commented out code calling pdp_freepdp()
That code was commented out in 0b076a331e
(year 2003), and indeed it makes no sense to call those in current pdp
lifecycle (they are expected to be freed by the application).

Change-Id: I096d8cb8d749ff9b737d6f3f96b1d423660ece37
2019-08-29 14:07:00 +02:00
Pau Espin b4c98e7397 gtp: Log msg retransmits and timeouts
Change-Id: Ie768ddb45313582b4b5358b97a981080be64fd42
2019-08-28 18:47:58 +02:00
Pau Espin 3eb05d2c1a cosmetic: fix formatting in if line
Fixes: eefa30dce8
Fixes: 2d6a69e69a
Change-Id: I9ee5f4142cacf912145693c72a53c0f531bad2c6
2019-08-28 11:34:51 +02:00
Pau Espin 5d8b226597 libgtp: Introduce cb_recovery3
Since osmo-ggsn can manage several GSN structures simultaneously, it
needs the gsn_t pointer to know the ggsn it should forward the call to.

Related: OS#4165
Change-Id: I33b4fe594d5833993af01cce34737e61e597b320
2019-08-28 11:24:08 +02:00
Pau Espin 88ce94c2bd pdp: constify param in pdp_count_secondary()
Change-Id: Ie772f2c54264c8bc91f50d9030479861dd8868b7
2019-08-28 11:14:57 +02:00
Pau Espin d950134c53 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
2019-08-23 14:39:35 +02:00
Pau Espin 623c5b36e9 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
2019-08-23 14:38:56 +02:00
Pau Espin 67aebc9d1c Bump version: 1.3.0.50-ea1c-dirty → 1.4.0
Change-Id: I5ca7ada037a9b91c3b747cea6d83654d0b9afed3
2019-08-07 21:28:30 +02:00
Pau Espin e725d87d13 gtp: queue.c: Document queue APIs
Change-Id: I8523a0d0508d7fb870a4a9119aa8eb4c3a4d6f17
2019-06-20 16:47:11 +00:00
Pau Espin 8b90bce962 gtp: Add missing headers
Those headers are using types defined in other places (like sockaddr_in)
and don't explicitly include them, which makes future queue_test fail.

Change-Id: I65e12a067d89ef71be3719636b64f4d93ea73cc4
2019-06-20 17:08:13 +02:00
Pau Espin f0829ff34b cosmetic: gtp: queue: remove trailing whitespace
Change-Id: I20c83cd607ae8e1025fdc1a810c0d27bad80b178
2019-06-20 17:08:06 +02:00
Pau Espin 9fbcb10568 gtp: Make use of new libgtp APIs with multi-gsn support
Drop use of deprecated APIs everywhere in libgtp and use the new ones instead.

Related: OS#2873
Change-Id: Ibf56a063f01d1f95a2a3271416da6e062e85fdfa
2019-06-04 17:45:06 +02:00
Pau Espin eefa30dce8 gtp: Introduce new pdp APIs (and deprecate old ones) to support multiple GSN
Move static global pdp storage arrays to be per GSN. This way now
several GSN per process are supported without collisions.

* pdp_init() is defined in public API but it's actually only intended
for use (and currently only used) internally in gtp_new(). So let's
document that and re-use it for backward compatibility with now
deprecated API, where only one GSN per process is supported.

* Back pointer to gsn_t (pdp->gsn) moved from gtp.c:gtp_new() to
gtp_pdp_newpdp(), since it makes more sense to have it there. This way
backpointer is always set, even in case were app calls pdp_newpdp() API
directly instead of creating them through gtp.c, like osmo-sgsn does.

* Create new versions of required APIs with a pointer to gsn_t where the
pdp ctx is to be created/found. Some APIs receiving a pointer to a pdp
ctx can be left intact because we have a backpointer to its gsn_t.

* pdp_getpdp() is nowhere used, and makes little sense now that we have
pdpa reachable in gsn->pdpa, so let's deprecate it without adding a
replacement.

* Deprecate gtp.h gtp_newpdp(), since it's nowhere used and useless
(does same as new gtp_pdp_newpdp() and doesn't allow for old_pdp to be
passed as parameter).

Fixes: OS#2873
Change-Id: I653cbdc185165592d985e3efab6e3f1add97877b
2019-06-04 17:42:16 +02:00
Pau Espin a469a90d5e cosmetic: gtp.h: Remove trailing whitespaces
Change-Id: I60f8cf5e36bcef767f90b150a488a800445bf744
2019-05-31 16:44:01 +02:00
Pau Espin 84515f4b8b pdp: Drop unused code for haship
Nowadays we have one tun device per APN, so we don't need this hash
table because we use the ippool of the APN to find the related PDP ctx
pointer.

Change-Id: Ife3f222daa87f0630ff34ffc3e63f4dad2ad914b
2019-05-31 16:44:01 +02:00
Oliver Smith 1cde2c1691 ggsn: Use gtp_delete_context_req2() everywhere
Replace calls to gtp_delete_context_req() with
gtp_delete_context_req2().

Related: OS#2741
Change-Id: Iecc8c5ac45207e7e20129559c4ac7f3c67dfb36a
2019-05-31 16:44:01 +02:00
Pau Espin 93dd798a99 gtp: Re-arrange free pdp ctx code 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: I299765816e9d885497110d2e834f7ccdc943052c
2019-05-31 16:42:07 +02:00
Pau Espin 8651573632 cosmetic: gtp: Document free pdp ctx in non-teardown scenario
Change-Id: Ia47ac792111fe1e9aa68222b32b5da823642206b
2019-05-31 16:40:39 +02:00
Pau Espin 0d0b0592f0 gtp: Refactor code to use gtp_freepdp(_teardown) APIs
* API gtp_freepdp was already there but was not really being used by
anyone currently, so we can change its behaviour to call cb_delete_ctx.
It makes sense to call the cb in there too to be consistent with rest of
APIs.
* Add API gtp_freepdp_teardown, which calls gtp_freepdp on pdp and its
secondary contexts. It will also be used later on by osmo-ggsn.
* Use new APIs in internal code to simplify it.

Change-Id: I9f0b774e9385a7a8d81ec9702f158e2f9a50d571
2019-05-31 16:34:32 +02:00
Pau Espin aad77a0acf gtp_create_pdp_ind: simplify code by reordering and compacting parsing
Move all parsing with same conditions under same blocks to make code
easier to follow and make it more compact.

Change-Id: I52d5a3543ce6cf764bd84303b5a0d8b0643d998d
2019-05-31 16:34:32 +02:00
Pau Espin 9ee8d3264b pdp: Introduce new API pdp_count_secondary
Change-Id: Id2d84ad1cdb0f3b500efeda4cc0fbccb24ae0c61
2019-05-31 16:34:32 +02:00
Pau Espin de72d26f49 gtp: Fix typo dublicate->duplicate
Change-Id: Ic572c216e74fa937dfd12f9f3dc03de18b6b123e
2019-05-31 14:25:57 +00:00
Pau Espin ceac078d77 gtp: Take queue_resp into account to schedule retrans timer
Before this patch they were not taken into account, which means some
resp messages could stay more time than required enqueued.

Change-Id: Iebf405b2310a34785f3b363cc2a9f415281f6030
2019-05-31 14:25:57 +00:00
Pau Espin 742a6b55ce gtp: Document spec reasoning drop of Rx DeleteCtxReq
Change-Id: I563fc0b48595d71ebdf56a50f4e9984eee423676
2019-05-30 13:36:56 +02:00
Harald Welte f5a268a96d Bump version: 1.2.2.44-6da8-dirty → 1.3.0
Change-Id: Ie12af1d57df178a9ab27937ef0b764c98dd96e32
2019-01-20 21:34:23 +01:00
Stefan Sperling 3730c550cd fix a format string directives in queue_seqset()
Coverity pointed out that a format string used inappropriate
format string directives for variables of type size_t.

Change-Id: I889019aad963932fdc032421e60a72c809a93bca
Related: CID#135197
2018-11-22 13:17:18 +00:00
Alexander Couzens e1412d9493 libgtp: implement gtp_clear_queues to clear req/resp queue
Clearing the request and response queue is useful for debugging
to reset "some" state. Otherwise some tests will get un-expected
packets.

Change-Id: I279d1d7cbf5d37dd5609c2b968f317fe9a0e348d
2018-09-16 10:30:10 +00:00
Pau Espin b5f93346df gtp: Add new replacement cb_recovery2 for cb_recovery
Sometimes the originating pdp ctx causing the Recovery Procedure is
required, in order to drop all pdp ctx but this one, which specs specify
should be handled as valid:
"""
The SGSN receiving the Recovery information element shall handle it as when an
Echo Response message is received but shall consider the PDP context being created as active if the response indicates
successful context activation at the GGSN.
"""

Change-Id: I53e92298f2f6b84d662a3300d922e8c2ccb178bc
2018-07-23 11:25:53 +02:00
Pau Espin 8e8c7ef3c7 gtp: Add new API to avoid freeing pdp contexts during DEL CTX REQ
With this API, user is expectd to free the PDP ctx when the confirmation
for the release has been received (cb_conf time). This way user can
maintain the pdp ctx alive during all this time. Extra code is added to
gtp_delete_pdp_resp() since it's now possible to match it and push it up
to the user cb_conf.

This way, cb_conf() can be used for locally-initiated DEL CTX REQ, while
delete_context() cb is left for remotely-initiated DEL CTX REQ. In this
later case, when the DEL CTX RESP is sent the ctx is deleted and the
delete_context() is called, where the user can do related actions or
trigger consequence events (in the case of SGSN, it will drop all
related GGSN bits for that PDP ctx and forward the DEACT PDP CTX to the
MS).

Change-Id: I29d366253bb98dcba328c7ce8aa3e4daf8f75e6c
2018-07-21 17:22:54 +00:00
Pau Espin d1bd6fce9c gtp: Log ignore CTX DEL REQ due to no teardown and only 1 ctx active
Change-Id: Ic950c04d309d5686bfbeab332f79c48678e743ae
2018-07-13 19:11:59 +02:00
Pau Espin a32e4c4fb8 gtp: Allow recv DEL CTX REQ in sgsn and DEL CTX RSP in ggsn
According to 3GPP TS 29.060 section "7.3.5
Delete PDP Context Request", both directions are valid in both GSNs.

This allows osmo-sgsn receive delete ctx indication (cb_delete_context)
in order to implement GGSN initiated requests.

Change-Id: I6927c07be4ddf74defe338d01d947056e15cd14d
2018-07-13 19:05:03 +02:00
Pau Espin 3b84e92ab3 gtp: Log type name of unexpected signalling message
Change-Id: Iae0f045e4128cf97aa7824d7d774b59bf966cbe8
2018-07-13 18:32:38 +02:00
Pau Espin 36c4fac9c9 debian/rules: Fix debian packaging after 1.2.0 release
The 1.2.0 release bumped lib version to 3 and updated the debian package
file accordingly, but forgot to increase dh_strip line in debian/rules.

Change-Id: Ib54f231943348c06acecd6f413b2c96b24f6db28
2018-05-04 11:28:24 +02:00