Commit Graph

100 Commits

Author SHA1 Message Date
Neels Hofmeyr a46a126fb1 add osmo_pfcp_ip_addrs_get
This pattern shows up a lot when working with PFCP. Let's make it easier
to handle IPv4 and v6 at the same time.

Change-Id: I4338a83f26ef2443f90cf835621e73aed5eac521
2024-03-23 13:03:53 +01:00
Neels Hofmeyr 5d2ee7e72c pfcp up_function_features: allow shorter lengths
eUPF sends a short CP Function Features bitmap, which is easy to solve
by just zero padding to the minimum length specified in PFCP (3GPP TS
29.244)

Related: SYS#6590
Change-Id: I40e255fd0b4770e578aea7a10ba88f5eeba087f4
2024-03-19 04:40:06 +01:00
Neels Hofmeyr 172dc5a72d osmo_gtlv_cfg: fix api doc
Change-Id: Idcbb10edf384f49bd3f685323a68cdbf8b5d009d
2024-03-19 04:40:06 +01:00
Harald Welte da1796678c add missing GPLv2 license text as COPYING file
Change-Id: I33a57492d9f3ca409d5d1bd77a07ec746c668e80
2024-03-08 14:43:22 +01:00
Pau Espin 34220e80a8 Bump version: 0.2.0.14-d497-dirty → 0.3.0
Change-Id: I8c2455a799bdc9e3d527b5a8bf8f2303ebbd5796
2023-09-12 13:55:23 +02:00
Harald Welte d497660ac6 Fix license information in dpkg + rpm packages: GPLv2+ and not AGPLv3+
These look like copy+paste issues.  We don't generally do AGPL for
library code; libraries are typically under GPLv2+ for maximum
compatibility.

Change-Id: I94d0dda467b2c2b1c61ad1c6cb234cb66db46134
2023-06-27 09:11:49 +02:00
Oliver Smith 934b2ceefd debian: make consistent
* Make maintainer consistent
* Space in debhelper line

Related: OS#5958
Change-Id: I6ee4aace6bf7c246338408c41f790189d75d5488
2023-04-26 11:57:34 +02:00
Neels Hofmeyr b939974355 coverity: fix null deref
fixup for
"pfcp_msg: refactor LOG_PFCP_MSG
e6ff99d7ac
Change-Id Ic84090c9b1a34185577cfb2ea1efa9c07542df34

Related: CID#313611
Change-Id: I347a813b31c839eae6b752982952367b2e664dc4
2023-04-19 02:32:14 +02:00
Neels Hofmeyr e6ff99d7ac pfcp_msg: refactor LOG_PFCP_MSG
It was requested during code review to make this a function and not a
macro.

One effective change: no longer log "NULL{fi=NULL}" when no
m->ctx.session_fi or .peer_fi are set.

Change-Id: Ic84090c9b1a34185577cfb2ea1efa9c07542df34
2023-04-15 00:19:34 +02:00
Neels Hofmeyr 761e17039a build: add gen__pfcp_ies_auto_LDFLAGS = -no-install
Change-Id: I4c1e1eed90acc3466262750e235f03e8e00105b6
2023-03-14 22:58:19 +01:00
Neels Hofmeyr d116902c7d build: fix linking gen__pfcp_ies_auto to use build-tree libosmo-gtlv
By moving *_LIBS to libosmo_pfcp_la_LIBADD, fix linking of
gen__pfcp_ies_auto to prefer the locally built libosmo-gtlv over a
system installed one.

Related: OS#5942
Change-Id: I2e92238b214d8e79bab1095d6093139bad05bc66
2023-03-14 20:49:23 +01:00
Neels Hofmeyr b97f9e1906 build: libosmo-gtlv: move LIBS to libosmo_gtlv_la_LIBADD
Change-Id: I6fd777bed9366c35f5b1453cde1e6f5c1617e338
2023-03-14 20:48:47 +01:00
Neels Hofmeyr 1aa3a0889c build: drop LIBOSMOVTY from libosmo-pfcp
libosmo-pfcp does not use libosmovty.

Change-Id: I8c772386ee7c6d035aabbc854fadbbcde03f7d33
2023-03-14 20:47:41 +01:00
Neels Hofmeyr e2f94c2b57 build: drop $(all_includes)
Drop this mysterious empty variable. No idea where it came from, there
is nothing here that would set it.

Change-Id: I7f2736366b34e7a15f73fa81ef1d4659ed6e2361
2023-03-14 20:29:34 +01:00
Neels Hofmeyr eeba253ccd build: drop COVERAGE
There isn't even an --enable-coverage in the configure.ac, so drop the
always empty COVERAGE_CFLAGS and COVERAGE_LDFLAGS.

Change-Id: Ib256ce7d979aec5c368b19ac2c145f75a9dab0fc
2023-03-14 20:25:33 +01:00
Neels Hofmeyr a2a8f56513 libosmo-pfcp.pc.in: add missing libosmogsm
We use osmo_apn_from_str() and osmo_apn_to_str(), defined in libosmogsm,
since this commit:
"fix coding of Network Instance IE"
8368e7d5d5
I9d67464ef0f92b0512cfd6e48d203f8828a82a19

Since libosmo-pfcp merely calls the two functions and none of
libosmogsm is exposed in the libosmo-pfcp API, it suffices to use
Requires.private in the .pc file.

Change-Id: Ie1c92d251af6a3e42759ff0da0d3693356b5e1d3
2023-02-24 19:06:13 +01:00
Oliver Smith a2154c7350 Run struct_endianness.py
Ensure there is no diff to prepare to run this in CI.

Related: OS#5884
Change-Id: I0ae0b911f02b4f57d82c928cfc4a14a3dc397ab3
2023-02-20 09:50:13 +01:00
Neels Hofmeyr abf1d43e5e add doc/charts/pfcp_msgs*.msc
(I used these while implementing libosmo-pfcp and osmo-upf, but never
submitted them.)

Change-Id: I8d2343224d02d728e2eee2090ee2d4c6bec79e78
2023-02-11 06:07:19 +01:00
Neels Hofmeyr c518e3fa06 clarify API doc for osmo_pfcp_endpoint_tx()
I recently discovered some use-after-free in osmo-upf by wrong API usage
of osmo_pfcp_endpoint_tx(). Highlight this pitfall in API doc.

Change-Id: I637e7bb5d1296b5ad8db8ab0b8151fdbb9e7be03
2023-02-10 02:23:52 +00:00
Pau Espin 6df7905736 Bump version: 0.1.2.25-9c96-dirty → 0.2.0
Change-Id: I44bb6b839a6aefaf269e124c990ff0f0b837588d
2023-02-07 13:58:41 +01:00
Neels Hofmeyr 9c96c3986f silence compiler warning in gtlv_dec_enc.c
This was reported with gcc version 12.2.0:

 /git/libosmo-pfcp/src/libosmo-gtlv/gtlv_dec_enc.c: In function
 'osmo_gtlvs_decode_unordered':
 /git/libosmo-pfcp/src/libosmo-gtlv/gtlv_dec_enc.c:237:42: warning:
 'presence_flag_p' may be used uninitialized [-Wmaybe-uninitialized]
   237 |                         *presence_flag_p = true;
       |                                          ^
 /git/libosmo-pfcp/src/libosmo-gtlv/gtlv_dec_enc.c:113:23: note:
 'presence_flag_p' was declared here
   113 |                 bool *presence_flag_p;
       |                       ^~~~~~~~~~~~~~~

There is no actual code path that will use presence_flag_p
uninitialized, but it doesn't hurt to init with NULL.

Change-Id: I8f4c420f2182c607abb1ee5d1c8175eaeda904af
2023-01-02 14:05:45 +01:00
Neels Hofmeyr bf8e49a1bd gtlv: decoding error: log size limited hexdump of IE
When a decoding error is encountered, log the value part of the root
cause as hexdump, but at most 16 bytes (16*3 chars as hexdump).

Contrived example of the change:
before this patch:

  <-tx- PFCP seq-4 ASSOC_SETUP_RESP: 0: Invalid FQDN (-22: Invalid argument)
  <-tx- PFCP seq-4 ASSOC_SETUP_RESP: 0: tag 0x3c = Node ID: Error while decoding this IE (-22: Invalid argument)

after this patch:

  <-tx- PFCP seq-4 ASSOC_SETUP_RESP: 0: Invalid FQDN (-22: Invalid argument)
  <-tx- PFCP seq-4 ASSOC_SETUP_RESP: 0: tag 0x3c = Node ID: Error while decoding this IE. L=20 V=[ 02 07 65 78 61 6d 70 6c 65 03 63 6f 6d 01 02 03 ...] (-22: Invalid argument)

Change-Id: Ie814a117db3dfea32cf3f01cf124a2e472cb869f
2022-12-08 04:23:09 +01:00
Neels Hofmeyr 43dd5ddf97 bitmask to string: shorten
Remove braces and spaces from PFCP bits to string conversion.

Instead of "( FOO BAR BAZ )", print "FOO+BAR+BAZ".
Instead of "( FORW )", print "FORW".
Instead of "( )", print "-".

The spaces tend to break up readability of strings logged by osmo-upf.

In particular, this affects UP and CP capability bits, Apply Action,
Outer Header Creation.

Change-Id: I38426d6381e96d4a683e46eba1bdd29c73d3f027
2022-12-08 04:23:09 +01:00
Neels Hofmeyr 4f6c95cc77 fix coding of Node ID: FQDN type
Decode FQDN type Node IDs into "human" dotted notation instead of
storing the DNS type data in the FQDN string.

Related: OS#5806
Change-Id: I25d0f9b095287aa30e24498d8361c0a326ded447
2022-12-08 04:23:09 +01:00
Neels Hofmeyr 8368e7d5d5 fix coding of Network Instance IE
Network instance names should be coded like in DNS, where each label is
preceded by a length byte.

Related: SYS#6192
Change-Id: I9d67464ef0f92b0512cfd6e48d203f8828a82a19
2022-12-08 04:23:09 +01:00
Neels Hofmeyr 2ee6a68045 pfcp coding errmsgs: drop extra newlines
Change-Id: I4eea1efc9bd67676b6202e50d41974b2717a2511
2022-12-01 03:19:51 +01:00
Neels Hofmeyr c6663802c0 tweak comment in pfcp_ies_custom.c
Change-Id: I1530939cc63369668d2f3e5a126912713c06d0c1
2022-12-01 03:19:51 +01:00
Neels Hofmeyr 1dd8f06ea7 add osmo_pfcp_ie_outer_header_creation_to_str_*()
Make osmo_pfcp_enc_to_str_outer_header_creation() as
osmo_pfcp_ie_outer_header_creation_to_str_*() functions.

Used by I0d4d9edcfc94b61bdc74cfd4ff837f151d1c28ae (osmo-upf)

Change-Id: I4ad1570485c8081b82284e4e6b4de4d7eed414b0
2022-12-01 01:03:41 +01:00
Neels Hofmeyr abecf78926 osmo_pfcp_ip_addrs_set(): do not set port number
struct osmo_pfcp_ip_addrs uses an osmo_sockaddr for storing IP
addresses. Even though osmo_sockaddr contains a port number, no port
number gets encoded in PFCP messages. Hence always set the port to 0.

I noticed that when osmo_pfcp_ip_addrs_set() is invoked with an
osmo_sockaddr that incidentally has a port number set, subsequent
logging of e.g. a PFCP F-TEID shows a port number, which is confusing.

Change-Id: Ib29a123c06d459c99d7c1c0b9a7694fb78cd9fd8
2022-11-26 03:05:42 +01:00
Neels Hofmeyr c41bfcbbf0 add osmo_pfcp_ip_addrs_to_str_*()
Move static function ip_addrs_to_str_buf() to public API as
osmo_pfcp_ip_addrs_to_str_buf() and osmo_pfcp_ip_addrs_to_str_c().

So far the static function was only used in places where it follows
other strings, so that it made sense to always start with a comma. Move
this comma out of the function to the callers.

Sensibly handle a NULL pointer and an empty address set.

Rationale: osmo-upf would like to print an osmo_pfcp_ip_addrs struct in
logging.

Change-Id: I5f67db8d347690cbb1ce273a2d072636859f1bf6
2022-11-26 03:04:13 +01:00
Neels Hofmeyr 25c4c9b355 PFCP: add Network Instance IE in PDI IE
So far the optional Network Instance IE in PDI IEs was not coded by
libosmo-pfcp. Add it.

Test it by adding Network Instance IEs in pfcp_test.c.

osmo-upf needs this, because we are about to add support for Network
Instance in PDI IEs, to determine which local interface to use for GTP
tunnel mapping and encapsulation/decapsulation.

Related: SYS#6192
Change-Id: I162299e70b4fb0c3fef8039d693ac7d3fe4df16a
2022-11-23 23:40:28 +00:00
Neels Hofmeyr 3ee13ea857 pfcp_test: fix order of dependencies
When LIBOSMOCORE_LIBS comes before locally built libs, for some reason
libtool puts system lib/ first in LD_LIBRARY_PATH, leading to ABI
breakage in pfcp_test when an older libosmo-pfcp is still installed.

Change-Id: I63880c1b4f326687ce9a35584a55742c1016d72b
2022-11-22 09:33:33 +00:00
Vadim Yanitskiy c3a6ef446b tests: use 'check_PROGRAMS' instead of 'noinst_PROGRAMS'
When using 'check_PROGRAMS', autoconf/automake generates smarter
Makefiles, so that the test programs are not being compiled during
the normal 'make all', but only during 'make check'.

Change-Id: I62a7b4d76c910b3fa90deb0d35a8fc36146d66e6
2022-11-22 09:30:30 +00:00
Neels Hofmeyr 7b3927c77d pfcp_test: add missing 'pdi_present = true'
test_enc_dec[8] includes a PDI IE in Update PDR. The PDI is optional
here, so it requires setting a presence flag to true. This was missing,
hence the PDI part was not being tested at all. Add this presence flag.

This was probably a copy-paste error from testing the Create PDR IE,
where the PDI is mandatory and has no presence flag.

Change-Id: Idc70ae23f15d3af65f98557cc51a111f2e6d75c9
2022-11-21 00:56:40 +01:00
Neels Hofmeyr 7278fd810e pfcp_test: init logging, for PFCP errors
Initialize logging so that potential errors are shown by the test.

Normally, pfcp_test does not cause any logging. However, I encountered a
linking problem, which caused error logging from libosmo-pfcp, which was
not shown because osmo logging aborted the program first.

Change-Id: I32a99d27ff72edceacb2cf4f4cd996650bc10710
2022-11-21 00:56:40 +01:00
Neels Hofmeyr 3a86c92dce api doc: explain heartbeat handling in rx_msg_cb
Related: SYS#5599
Change-Id: I3849060d703494ea43773c0208203f1fc206067f
2022-11-11 18:59:06 +00:00
Vadim Yanitskiy 24b06cd451 contrib/jenkins.sh: build with --enable-werror
Change-Id: I5d22083e40b5c95b2412e1dcb4aba4f023f54e23
2022-11-04 21:01:19 +00:00
Harald Welte 990c1989c0 Add -Werror=implicit-int -Werror=int-conversion -Werror=old-style-definition
... if --enable-werror is used

Change-Id: I8e6cdc40cb77777677e5ffbbf3bf9e5c32555b2c
2022-11-03 12:43:00 +01:00
Harald Welte c9b46a1c34 Support building with -Werror=strict-prototypes / -Werror=old-style-definition
Unfortunately "-std=c99" is not sufficient to make gcc ignore code that
uses constructs of earlier C standards, which were abandoned in C99.

See https://lwn.net/ml/fedora-devel/Y1kvF35WozzGBpc8@redhat.com/ for
some related discussion.

Change-Id: I79c51b78d1b055361f9ef5434361847353791d0d
2022-11-03 12:42:57 +01:00
Neels Hofmeyr 2404c9ae2a gtlv: test repeated IEIs to several struct members
Test the behavior fixed by Ie37585178ff27306d425b75d8e407b71f92f1cdc

Related: CID#275415
Related: SYS#5599
Change-Id: I994d0fb1f1435d2c27a8630a43fe106652ac6e41
2022-08-24 17:04:42 +02:00
Neels Hofmeyr 65c72dbe61 gtlv: fix repeated IEIs to several struct members
Coverity Scan has brought my attention to a problem with decoding
repeated IEIs, where there are multiple struct members in the decoded
struct that these are decoded to.

Before this patch, gtlv aborts with an error as soon as the first struct
member for a given tag is full, not parsing following IEIs into
subsequent struct members.

After this patch, gtlv continues to look whether subsequent entries in
the message coding also decode the same tag, but to a different struct
member.

First commit without changing the gtlv regression test, to show that all
current tests still succeed. The test for this particular issue follow
in I994d0fb1f1435d2c27a8630a43fe106652ac6e41

Related: CID#275415
Related: SYS#5599
Change-Id: Ie37585178ff27306d425b75d8e407b71f92f1cdc
2022-08-24 17:04:42 +02:00
Neels Hofmeyr 035b692673 gtlv: check memory bounds 3/3: encoding to str
See Id8d997c9d5e655ff1842ec69eab6c073875c6330

Related: CID#275417
Related: SYS#5599
Change-Id: I63d52a4f5dba32d3a3887dd9c5e42e1695fb2aa3
2022-08-24 17:04:42 +02:00
Neels Hofmeyr 92860a29cd gtlv: check memory bounds 2/3: decoding TLV
See Id8d997c9d5e655ff1842ec69eab6c073875c6330

Related: CID#275417
Related: SYS#5599
Change-Id: I841da89112ccf70fcd0f60eb902445fb1712eb48
2022-08-24 17:04:42 +02:00
Neels Hofmeyr cb724a3484 gtlv: check memory bounds 1/3: encoding TLV
Introduce a maximum bound of memory access to the osmo_gtlv API.

Properly pass const-ness within the gtlv implementation. This patch adds
membof_const(). The following patch will add the non-const membof()
equivalent, which is not needed in this patch, yet.

Coverity CID#275417 drew my attention to the fact that the gtlv decoding
and encoding does not actually guard against access past the end of the
decoded struct.

We have not yet officially released libosmo-gtlv; also, osmo-upf and
osmo-hnbgw so far only use the libosmo-pfcp API, which "hides" the gtlv
API. Hence just change the API without a backwards compat shim.

Related: CID#275417
Related: SYS#5599
Change-Id: Id8d997c9d5e655ff1842ec69eab6c073875c6330
2022-08-24 17:04:42 +02:00
Neels Hofmeyr ced68154d2 pfcp_msg: check use count correctness
Related: CID#275414
Related: SYS#5599
Change-Id: I685855da8b6f373fdc62a3c75f7f2e0af2839617
2022-08-24 17:04:42 +02:00
Neels Hofmeyr 096c2eb2dd Bump version: 0.1.1.1-2904 → 0.1.2
Fix packaging, only.

Change-Id: I6ae6cf59e769214e11447107316d38fe5fad583d
2022-08-24 16:39:11 +02:00
Neels Hofmeyr 2904ba36bd pkgconfig: add missing 'Requires:'
Change-Id: I018caa584cb1f5fa1b2a7e6e6f9ec26e5b54eea7
2022-08-23 18:46:25 +02:00
Oliver Smith a6eba99ab0 Bump version: 0.1.0.32-823b → 0.1.1
Tag a new release with all the packaging fixes, so building libosmo-pfcp
for latest isn't failing anymore on obs.osmocom.org.

Related: OS#5654
Change-Id: I9a7be8342754fdbc21b83281c8ebcbf38112c61b
2022-08-22 11:39:51 +02:00
Oliver Smith 823b88873c packaging: depend on libosmocore >= 1.7.0
Require the same libosmocore version in configure.ac and rpm spec as
already set in debian/control.

Change-Id: I701f1aacca22a697f35aba0041a71945c5aea107
2022-08-22 11:37:07 +02:00
Oliver Smith 5af922f249 debian/control: move -dev deps of libosmo-gtlv-dev
Only the -dev package of libosmo-gtlv should depend on other -dev
packages.

Change-Id: I4a7ba317e54f7f19d0947e95f7ab0b4f1e8fd43a
2022-08-22 11:33:44 +02:00