Commit Graph

207 Commits

Author SHA1 Message Date
Vadim Yanitskiy 1768414211 cosmetic changes
Change-Id: I1515a07bf39368d5c3f1528b4ea1c40cb0501c62
2024-04-17 21:27:51 +07:00
Vadim Yanitskiy cedc540cb3 fix NULL pointer dereference in gtp_sgsn_context_conf()
Change-Id: I79f8b0c44142469790693ab757ff88df1fdea1df
2024-04-17 21:27:04 +07:00
Daniel Willmann c5ad113a12 WIP
Change-Id: Ia8d595095462c30a56b8a0b30c8d24632776e4cc
2024-04-17 18:42:13 +07:00
Daniel Willmann cbda8cb8c6 gtp: WIP SGSN Context Request/Response/Ack support
* SGSN Context Request parsing
* SGSN Context Response generation
* Link to libosmo-gsm

Change-Id: I3a5046b67f73a81eeb6b509777132857a9abcf0c
2024-04-17 18:42:13 +07:00
Daniel Willmann 3c46927fa2 gtp: Add function gtp_resp2() which takes flow label and tei
Change-Id: Id9ff95e0e2a10a22e65ecf42b2a2b06a0f2d1a45
2024-04-17 18:42:13 +07:00
Daniel Willmann fa6b4afbd7 gtp: Make peer addr const in gtp_req/gtp_resp
Change-Id: I955b82ba8022754c3d23979d5c55bb61233047b1
2024-04-17 18:42:13 +07:00
Oliver Smith fa91a10498 Cosmetic: {lib,gtp}/Makefile.am: diff friendly
Change-Id: Ib1956794edc6e82cfa6c5419b2609565674d98a4
2024-02-23 13:25:32 +01:00
Oliver Smith 6929391ecf Cosmetic: AM_CFLAGS: make diff friendly
Change-Id: I3303cd8ba8c8b21ff267608833d9fb4833ffc471
2024-02-23 12:08:48 +01:00
Oliver Smith 9bd2711f39 Revert "kernel-gtp: support IPv6 on outer layer"
This reverts commit 0917ce4e22,
as it breaks building osmo-sgsn. This needs to be reworked to be
backwards compatible.

Related: OS#6373
Change-Id: I2c2b2ff0875217e041d94c8e2cef030d2a86c2d8
2024-02-22 16:06:33 +01:00
Oliver Smith 0917ce4e22 kernel-gtp: support IPv6 on outer layer
Related: OS#1953, OS#6096
Change-Id: I257fff1dcd9d030a7f9ea936b2693a3f13208230
2024-02-21 16:22:21 +01:00
Oliver Smith 2a0d37cb1d gtp_new: deduplicate create_and_bind_socket code
Change-Id: Iff3cfdfb0c08033d869c51499754b3416c71732b
2024-02-21 13:06:04 +01:00
Daniel Willmann 77734ac81b libgtp: Remove defines for reserved causes in gtp.h
As discussed in Gerrit change I9c3bf64537ef2223e29f8082861fa32fde26bf68
remove defines that don't serve any purpose. These are defines for
reserved values and changing them later if a newer spec defined them
would break API.

Keep the comments to explain the missing values.

Change-Id: I8db0aa0ade59785443a407b51dea326144406dcf
2023-11-29 16:40:49 +01:00
Oliver Smith 848ec697e2 Bump version: 1.10.2.1-a625 → 1.11.0
Change-Id: I1f116e1cded135f231f22ebc9b817aebf3736fc2
2023-11-28 13:07:17 +00:00
Daniel Willmann 6a2e82542d libgtp: Use gtp_cause_successful() instead of GTPCAUSE_ACC_REQ
In some cases the phone requests a PDP context type that isn't available
no the PGW/GGSN, e.g. phone requests a combined IPv4/v6 context, but
only IPv4 is supported.

In that case the GGSN can send a Create PDP Context Response with cause
"New PDP type due to network preference" or "New PDP type due to single
address bearer only". libgtp should continue handling these cause values
like the "Request Accepted" cause. Use the new gtp_cause_successful()
function for that.

Related: OS#6268
Change-Id: I7dd1e0aa185530e1e2d0402742df833c61a787a7
2023-11-24 09:48:22 +01:00
Daniel Willmann a625bdd136 gtp: Add net GTP cause values and a function to check for success
According to the spec the upf/pgw can accept a modified pdp context from
the request e.g. if an ipv4/6 context was requested, but only ipv4 is
availiable. Introduce a function that checks all cause values that are
considered successful.

See also: 3GPP TS 29.060 Ch 7.3.2

Related: OS#6268
Change-Id: I9c3bf64537ef2223e29f8082861fa32fde26bf68
2023-11-22 12:36:49 +01:00
Vadim Yanitskiy 4aa2e417c9 Do not hard-code -g and -O2 in CFLAGS
Let the user decide on the optimization level and debugging info.

Change-Id: I4b0b523b7dac4d67413bda37b546964262e5ea0d
2023-03-09 17:17:03 +07:00
Vadim Yanitskiy bf69ddbfef gtp: use OSMO_ASSERT() in gtp_new()
When using built-in static_assert() [1], gcc v12.2.1 fails:

In file included from gsn.c:27:
gsn.c: In function 'gtp_new':
gsn.c:444:54: error: expression in static assertion is not constant
  444 |         osmo_static_assert(gtp_T_defs[0].default_val != 0, first_default_val_not_zero);
      |                                                      ^

The reason is likely that gtp_T_defs[] is not const, so it cannot
be assert()ed statically.  With the current osmo_static_assert()
implementation, this assert does nothing.  One can change the
gtp_T_defs[0].default_val to 0 and the code will still compile.

Change-Id: Ia8af1736b63d501661046fe70befe5bbabc1045a
Related: [1] libosmocore.git I5ca34bc14c05e8c38c721d7df33feb1c6c41c76e
2023-02-27 17:07:26 +07:00
Vadim Yanitskiy 70a4e2e6f8 gtp/gsn.c: fix 'No newline at end of file'
git complains if it's missing, vim adds it automatically.

Change-Id: I3b4808a76da89e65b934d818e7ca280bc0651483
2023-02-27 17:07:26 +07:00
Pau Espin 55fe62f634 Bump version: 1.9.0.10-4fac-dirty → 1.10.0
Change-Id: I553fb72c577181c32005093eaf4fa986ae0e6ca8
2023-02-07 14:29:49 +01:00
Pau Espin 3a55b89777 gtp: Introduce VTY configurable GTP timer X3
This timer controls the amount of time a resp message transmitted by the
local gsn is to be stored in the resp queue. This is used in order to
detect duplicate requests received, since GTP states the exact same
response should be answered if a duplicate request is received.

Prior to this patch, this timer was hardcoded to 60 seconds.
This patch actually should be set, in general, to a value
equal than (T3-RESPONSE * N3-REQUESTS) values configured at
the peer, since that is the maximum period during which the local gsn
expects to receive req retransmissions from the peer.
Hence, this value must be user configurable to adapt it to the peers
connected to the GSN.

The 60 seconds hardcoded value is therefore changed to default to our
local (T3-RESPONSE * N3-REQUESTS), since the most common scenario for
osmo-ggsn/osmo-sgsn is to run it against a peer osmo-sgsn/osmo-ggsn,
which will have the same values by default.
This way we avoid by default caching response messages for way too long,
potentially filling the queue.

Related: OS#5485
Change-Id: Ia15c1cfd201d7c43e9a1d6ceb6725ddf392d2c65
2022-11-04 11:21:25 +01:00
Pau Espin 9f1f747d8e ggsn: Introduce tdef and make it configurable over VTY
Related: OS#5485
Change-Id: I10bc8e2e197c0e8753b23b684b5ae41025672bf7
2022-11-02 20:33:39 +01:00
Pau Espin b9036af7ca Use rate_ctr for gsn_t available_counters
This way they can be inspected with regular osmocom means.

Change-Id: I529305b4f824600c6e733a3c0d2c2c6673f99faf
2022-11-02 18:41:38 +01:00
Pau Espin 724ecc6680 Split gsn_t related APIs out of gtp.{c,h}
This way we split the gsn_t object API/logic from the protocol (message
handling) code.

Change-Id: I47cebb51bf08b9fcf7f115fc8dbea5f3493d4388
2022-11-02 18:41:34 +01:00
Pau Espin 0d3bd3435f cosmetic: gtp: Fix typo in comment
Change-Id: I54b80bba3126cb3ae534938e253721961d4e08c4
2022-11-02 13:22:17 +01:00
Pau Espin bc583d9763 Bump version: 1.8.0.13-ade4-dirty → 1.9.0
Change-Id: Id61cbe354437233fc6baf187ea90284da6a6944b
2022-06-28 17:48:22 +02:00
Pau Espin c97286f839 gtp: Fix typo in comment
Change-Id: I0e38e0966081d8b37c3f816f5330b4f52f81b7fa
2022-03-07 16:22:53 +01:00
Pau Espin f471800168 gtp: Log retrans queue register&free entries
Change-Id: I4e12376652fc7a6a96fbdcb579dbe916c1473012
2022-03-07 16:22:53 +01:00
Pau Espin bdf0697a5a gtp: Specify retrans queue name & seqnum in log lines
Change-Id: I4f193d7a482ace33afd8526b5f50d2d03467d5fa
2022-03-07 12:55:07 +01:00
Pau Espin 674a912fb5 gtp: Small log improvements in gtp_create_pdp_ind()
Drop unneeded log line, rewrite line to better fit code path.

Change-Id: Id254e04d539cc055fee8c16fb66cd897b041557e
2022-03-07 12:44:15 +01:00
Pau Espin 1bf3b3d0f9 gtp: Log detection of rx duplicate
Change-Id: I8bc9143db6743ad4fae2fe6d6fe0417648e9eec9
2022-03-07 12:20:13 +01:00
Pau Espin fb9303c610 gtp: Use switch statement in gtp_create_pdp_ind()
Double if had to be changed to if-else anyway, so let's simply use a
switch statement.

Change-Id: I91e8722947e58776742521d89abef8ae7584cb25
2022-03-07 11:34:30 +01:00
Pau Espin 0585769741 libgtp: Define retransmit QUEUE_SIZE relative to PDP_MAX (increase)
QUEUE_SIZE holds the number of pending transmitted messages
which can be handled concurrently.
Current value was 1024, same as PDP contexts (PDP_MAX). However, that
seems to be a quite low amount, which can be filled under certain
conditions, for instance if recovery procedure is triggered on the GSN
which is running full (around PDP_MAX pdp contexts created).
In this scenario, the GSN would need to send around PDP_MAX concurrent
messages (DeletePDPContextReq), which means the queue would very likely
end up being full.
Hence, let's define QUEUE_SIZE based on PDP_MAX, and set it to twice the
size to make sure it won't be filled in extreme conditions.

Change-Id: I6034b0fab2b2e5962314c2fca2f893246ce5cf4f
2022-03-01 12:39:08 +01:00
Pau Espin 9b288b788e libgtp: Fix ggsn crash if pdp alloc array is full (PDP_MAX)
osmo-ggsn crashes when concurrent pdp context num 1024 is created, due to
the gsn->pdpa array (of size PDP_MAX, 1024) being full.
The crash happens because return code of gtp_pdp_newpdp was not checked,
and hence a pointer "pdp" pointing to a temporary not-fully-allocated
object was being passed to gsn->cb_create_context_ind() callback.

Let's avoid crashing and instead reject the PDP context.

Related: OS#5469
Change-Id: I0d94ffad97eb4fef477d981bf285bf99740592a3
2022-03-01 12:38:58 +01:00
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