Commit Graph

709 Commits

Author SHA1 Message Date
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 f5fbb419ef ggsn: Implement echo req/resp and recovery
This patch is quite big because implementing echo req/resp and recovery
requires having knowledge and managing differentiated state for each GSN
peer attached/connected to osmo-ggsn. This kind of information was not
available in osmo-ggsn nor in libgtp.

So osmo-ggsn is now able to track GSN peers connected to a
ggsn_ctx (associated gsn_t from libgtp) by means of "sgsn_peer" data
structure, and accessible from the ggsn through a list. The instances of
sgsn_peer are currently allocated and destroyed dynamically based on
discovered peer who have at least a pdp context attached to us (we are
not interested in peers without pdp contexts because we don't need to
send echo requests/responses and maintain state in that case).

A new private pointer (pdp_t->priv) data structure struct pdp_priv_t is
added to be able to relate a pdp_t to an sgsn as well as the already
existing pointer to an apn.

An "echo-interval <0-36000>" VTY command is added which allows
configuring time wait between echo requests being sent to each
sgsn_peer. Transmission of echo requests is disabled by default.

Finally, a new "show sgsn" VTY command is introduced, and its output is
also printed during "show ggsn".

Related: OS#4165
Change-Id: Id2c84165dc59dff495106758146a701ca488834f
2019-08-28 11:34:11 +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 c602d7cf00 doc: Update vty reference xml file
Change-Id: I49e7db4d0f5c7868b86a4947d8b5739c2068da46
2019-08-28 11:21:23 +02:00
Pau Espin a019631c0b ggsn_vty.c: Improve output of VTY show pdp-context
GTP version and primary/secondary information is printed now for each
pdp context.

Related: OS#4154
Change-Id: If9682fe343e9a1e78175a12538fb80d4bda54802
2019-08-28 11:20:32 +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 310ea1db10 ggsn_vty.c: Avoid printing duplicates for pdp context with v4v6 EUAs
Fixes potential duplicates when calling following VTY cmd:
show pdp-context ggsn NAME
show pdp-context ggsn NAME apn APN

Related: OS#4154
Change-Id: I98db39a710a72a1438d71aabaf4f8227984643e3
2019-08-28 11:14:57 +02:00
Pau Espin 012d51ed7d Introduce LOGTUN log helper
Change-Id: I237acdee0be19498804e0d509c610f4e0454ba72
2019-08-28 11:14:57 +02:00
Pau Espin 1ef2621d3f gtp-kernel.c: Fix wrong use of in46a_from_eua, print IPv6 euas
in46a_from_eua() API documentation clearly states an array of 2 items
should be passed as pointer, but show_one_pdp() was passing only one,
which would end up in out-of-bounds writes on v4v6 EUAs.

Let's better use ippool to print allocated ip addresses instead of
parsing EUAs we sent some point in the past.

Change-Id: I7e164f40f50de43027bcd4464aa879450d2fb10e
2019-08-28 11:14:57 +02:00
Pau Espin f612ffea82 Move pdp_get_peer_ipv() to lib/util.*
Preparation for next commit, where this function will be needed inside
libmisc (lib/*).

Change-Id: Ibab4f6c09d1e5f0e9cfaea28ae1e7ab5b5c219b5
2019-08-28 11:14:57 +02:00
Pau Espin 421f22e8cf ggsn: Split application lifecycle related code into ggsn_main.c
This way we further shrink ggsn.c and leave there GGSN related code.

Change-Id: I9e6a3beac7657f0a8c02d514b54c6f1caa93bba7
2019-08-28 11:14:57 +02:00
Pau Espin 03cce86941 ggsn_vty.c: Fix wrong use of in46a_from_eua, print IPv6 euas
in46a_from_eua() API documentation clearly states an array of 2 items
should be passed as pointer, but show_one_pdp() was passing only one,
which would end up in out-of-bounds writes on v4v6 EUAs.

Let's better use ippool to print allocated ip addresses instead of
parsing EUAs we sent some point in the past.

Related OS#4154
Change-Id: Ia34939957bb7856388cb52a741cec0c015a08c70
2019-08-28 11:14:57 +02:00
Pau Espin 95cd897c3f in46_addr: Improve in46a_ntop documentation
Change-Id: I27238c330f9b805ac9e734e735d2c7ae158fe524
2019-08-28 11:14:51 +02:00
Pau Espin f7884e880e ggsn: Move PCO handling code into its own file
This way ggsn.c is shrinked in size and get rid of a lot of code there,
which is of no interest unless the reader is interested in that really
specific part.

Change-Id: Ieaa7e71f17c7fd9377c76ef53362eab596d669a6
2019-08-28 11:13:46 +02:00
Pau Espin 60ee0dbfa4 Introduce in46a_is_v{4,6}() helpers
It's clearer having size-related checks in one place for a data structure
in46_addr, instead of spread around the code.

Change-Id: Idc94bf0c8c01bb5a30e36d3c284b99f66b972abb
2019-08-28 11:13:32 +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
Jan Engelhardt aab47afe58 build: switch AC_CANONICAL_TARGET for AC_CANONICAL_HOST
$target/$target_os is never used, so AC_CANONICAL_TARGET is useless.
$host is, so employ AC_CANONICAL_HOST.

Change-Id: I6dc505888b42cfb686043470d3a3548c24cbe1f7
2019-08-15 14:12:00 +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 ea1cb3fa33 Require libosmocore 1.1.0
Older commit made use of gsm48_decode_bcd_number2(), which is available
in libosmocore 1.1.0 onwards, but forgot to increase configure.ac
requirements.

Fixes: fb62504160
Change-Id: I89b37be55fc4ba22b90e9aab9a5989573df2ae38
2019-08-07 21:27:00 +02:00
Pau Espin 0036a60c44 Remove undefined param passed to {logging,osmo_stats}_vty_add_cmds
Since March 15th 2017, libosmocore API logging_vty_add_cmds() had its
parameter removed (c65c5b4ea075ef6cef11fff9442ae0b15c1d6af7). However,
definition in C file doesn't contain "(void)", which means number of
parameters is undefined and thus compiler doesn't complain. Let's remove
parameters from all callers before enforcing "(void)" on it.
API osmo_stats_vty_add_cmds never had a param list but has seem problem
(no "void"), so some users decided to pass a parameter to it.

Change-Id: I0a89586ce683ad060212355b37470c349992ec49
Related: OS#4138
2019-08-05 17:47:55 +00:00
Pau Espin e47932976c sgsnemu: Fix unaligned pointer access during ip/icmp checksum
Catched by gcc 9.1.0:
osmo-ggsn/sgsnemu/sgsnemu.c:1294:2: error: converting a packed struct ip_ping pointer (alignment 1) to a uint16_t {aka short unsigned int} pointer (alignment 2) may result in an unaligned pointer value [-Werror=address-of-packed-member]
 1294 |  p = (uint16_t *) & pack;

Change-Id: I783f104c31234a07f2a13f6dbc577a71b25b36a7
2019-07-29 18:06:20 +02:00
Harald Welte f1e01517bc sgsnemu: Fix format string argument count
Change-Id: I6bb8c3df53a585913d5e0351ecad2e6ae9f0b886
Closes: CID#178643
2019-07-21 12:36:27 +02:00
Oliver Smith ad252e70aa contrib/jenkins.sh: run "make maintainer-clean"
Related: OS#3047
Change-Id: I0ad159a3973d28ac79ea7fb433401c72b247c2b0
2019-07-10 12:25:35 +02:00
Pau Espin 08ca425bc2 configure.ac: some versions of linux/if.h require including sys/socket.h
Related: OS#3230
Change-Id: Iba869a75745cea01024fa3ce04917c02fa608a13
2019-07-01 12:14:13 +02:00
Pau Espin 1eeb113c34 configure.ac: Use prefered AC_CONFIG_HEADERS over AM_CONFIG_HEADER
This macro is preferred by autofoo upstream. It was added around
automake 1.7, and offers backward compatibility with AM_CONFIG_HEADER.

Related: OS#3230
Change-Id: I88707d4895d9c231715d5252d2cfab589b42fe0c
2019-07-01 12:13:56 +02:00
Pau Espin d0ba664fec configure.ac: Use brackets in AC_INIT params
Change applied as a result of running "autoupdate".

Change-Id: I955b535737f0a0cbdf25377609cec8f3d8d3eb45
2019-07-01 12:13:56 +02:00
Pau Espin ec1d8c4004 configure.ac: Replace obosolete macro AC_CANONICAL_SYSTEM
$ autoconf -Wall
configure.ac:11: warning: The macro `AC_CANONICAL_SYSTEM' is obsolete.
configure.ac:11: You should run autoupdate.

autoupdate applied the change present in this commit.

Change-Id: Iee59e6e9a7670867d5bc55ba96f79130bc6982f6
2019-07-01 12:13:56 +02:00
Pau Espin 36e12d4db8 ggsn: Use structures instead of raw arrays when parsing ipcp_hdr
We have a structure to handle that data type, so let's use it.

Change-Id: I991e53544b733df7773d66280ffa19a2a5123d97
2019-07-01 12:13:56 +02:00
Pau Espin 2404c5b0b7 ggsn: Avoid unaligned mem access reading PCO proto id
Change-Id: I3d80833319869503691a52927892e6ac30744915
2019-07-01 12:13:56 +02:00
Harald Welte 32b76ee1af ggsn: More logging from PCO handling (e.g. in case of malconfiguration)
Change-Id: I38c2c4178ff4fd795f54638adec63166b1c0838e
2019-07-01 12:13:56 +02:00
Harald Welte 7bdc80de00 ggsn: Add minimalistic PAP support
Some modems are configured to use PAP as an additional authentication
mechanism beyond the GSM authentication that's part of GMM.  Let's
handle such PAP authentication requests by simply acknowledging them
all, without actually checking any credentials database.

This is the most sane thing we can do for now, without adding external
requirements / interfaces like radius servers or the like.

Closes: OS#3914
Change-Id: I81875f30f9f1497199253497f84718510747f731
2019-07-01 12:13:51 +02:00
Pau Espin 83f5266f43 gtp: queue: Add unit test queue_test
Closes: OS#1740
Change-Id: Id09bc5e23aa7a4b864822bc92cc23a4b60db52c3
2019-06-21 11:57:50 +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
Daniel Willmann e589c6544c manuals: Add script to regenerate vty/counter documentation
Related: OS#1700
Change-Id: I2f51ff19d2a1d7bcfdf569309a79a6e91a848302
2019-06-19 11:33:38 +02:00
Pau Espin d1a2ddfee6 sgsnemu: Replace use of deprecated libgtp API pdp_newpdp with new one
Related: OS#2873
Change-Id: I9742b82c382ae2e63f8aff4c5c32e2450059082b
2019-06-04 17:46:15 +02:00
Pau Espin 7b52f00192 ggsn: vty: Require ggsn param in <show pdp-context> cmd
Other similar commands already do it. This way we also get rid of
deprecated APIs, supporting search when more than one GSN is set up.

Related: OS#2873
Change-Id: I8357e20076348c8ded5e9f5b8e7252566b0fbfea
2019-06-04 17:45:36 +02:00
Pau Espin 25ab381c0f ggsn_vty_reference.xml: Update from last code changes
Change-Id: I5de2e5223e4532bbbec77b928fbdecb57ef2bca7
2019-06-04 17:45:36 +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 5560001af5 ggsn: Fix undefined behaviour shifting beyond sign bit
Fixes following ASan complaint during VTY "show running-config":
osmo-ggsn/ggsn/ggsn_vty.c:657:37: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Change-Id: I2b8d163dbc108b0fb5a1e820dc23181835d12869
2019-06-04 08:43:03 +00: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