Commit Graph

96 Commits

Author SHA1 Message Date
Neels Hofmeyr eaf2d153a8 fix copy-paste bug in up_endpoint.c
Related: CID#307544
Change-Id: I055179a81e1a71987cc8087626279505b65d1b62
2023-02-01 14:54:56 +01:00
Neels Hofmeyr 341e2ff692 manual: fix broken reference to netinst section
Change-Id: Ifeee1e90eb2af0e5bff357a000189c047fda03fb
2023-01-11 01:09:10 +01:00
Neels Hofmeyr d2f02df613 manual: some tweaks in overview
Related: SYS#6192
Change-Id: I5a672d24eb12bd29d8684117b2658ad4cd89d682
2023-01-06 00:28:44 +01:00
Neels Hofmeyr cd345bd6cd manual: add charts explaining tunend and tunmap
Change-Id: Ia0674c97eb0d8b5caeae988aefe523c5eee7318b
2023-01-06 00:28:40 +01:00
Neels Hofmeyr 52f9da22ff manual: tweak 'running' for new netinst feature
Related: SYS#6192
Change-Id: Iaa7af53aae72099283bb29ef0fc0eba03ae2f27d
2023-01-06 00:18:44 +01:00
Neels Hofmeyr b9d4ac8379 manual: explain new netinst cfg
Related: SYS#6192
Change-Id: I1d636b8a6ae7628b4369734a45e60f2eaf437dce
2023-01-06 00:18:44 +01:00
Neels Hofmeyr 4832e932e6 manual: use 'tunend' and 'tunmap'
Change-Id: I09a2fa28465945c98b58b4093c7d5de65e184645
2023-01-06 00:18:44 +01:00
Neels Hofmeyr 2a2884fbbe tunend: choose local GTP addr by Network Instance IEs
Implement handling of the Network Instance IEs from PFCP for tunend,
like already done for tunmap.

In 'tunend' cfg, allow indicating a local GTP address for both 'dev
create' and 'dev use'. Select a GTP device by the local address the
Network Instance IE in PFCP PDR indicates.

Related: SYS#6192
Change-Id: I376c09bfc1844df1e61d2efac17561fac614858b
2023-01-06 00:18:40 +01:00
Max c4eb92d211 ctrl: take both address and port from vty config
Change-Id: Ia652ce820e1299b23055f032f8cd0a87a8d60ba3
2022-12-17 21:36:37 +03:00
Neels Hofmeyr 95ab35035a nft: append 'accept' to each rule
This 'accept' is not an optional addition, it should always be present.
(Just saying because previous patch added a VTY command to configure
additions to the rules, and this patch is orthogonal to that.)

Related: OS#5810
Change-Id: I129133cc5d7180ce3761d5604d602d23a5ef9825
2022-12-09 18:28:19 +01:00
Neels Hofmeyr 8525c49c5d add cfg: tunmap / nft-rule append
It can be useful to add 'meta nftrace set 1' to nftables rules to help
analysis / site debugging. Add the possibility to do this by cfg.

Instead of adding the fixed string of 'meta nftrace set 1', allow
appending arbitrary strings to the nftables rules, to accomodate any
other future tweaks that may be useful.

Related: SYS#6192
Change-Id: Ia1fac67108902a48b43d8d1dc184ccf541fd9ba8
2022-12-09 18:28:19 +01:00
Neels Hofmeyr 0e66d699ed vty: add: show nft-rule tunmap example
Add VTY command to print out an nftables ruleset that osmo-upf produces,
with arbitrary IP addrs / TEIDs inserted. This allows tracking in *.vty
tests how the nftables rulesets are changed by patches.

future:
- Adding the 'tunmap' keyword to allow adding show commands for
  different uses of nftables.
- Adding the 'example' keyword to allow adding show commands for
  actual tunmap IDs / PFCP session IDs / ...
- Matches upcoming vty commands
  'nft-rule tunmap append .NFT_RULE'
  'no nft-rule tunmap append'
  'show nft-rule tunmap append'

Add new separate nft-rule.vty -- more to come here in upcoming patch.

Change-Id: I9b57aa492c051e480c9bd819ae58f8f59a13af40
2022-12-09 18:28:19 +01:00
Neels Hofmeyr eb8361f4c5 nft: allow to get the ruleset string without running
Separate string composition of the nftables ruleset from the actual
actvation of the ruleset to nftables.

For a 'show' VTY command added in upcoming patch, I'd like to be able to
vty_out() an nftables rule set. Provide API for that.

Change-Id: I0124a68ccf1ac7b90c5cc32d0cbf58d0cc219ccc
2022-12-09 18:28:19 +01:00
Neels Hofmeyr 9c6a8e32a0 GTP,UE addrs in osmo_sockaddr: assert( port == 0 )
Assert that all port numbers in osmo_sockaddr parts of up_gtp_action are
zero: uncover code paths that leak port numbers into the gtp_action API.

GTP and UE addresses have no port information. Port numbers in GTP,UE
addresses stored in struct osmo_sockaddr should be zero, so that
- to-string conversion via osmo_sockaddr_to_str_c() returns only an IP
  address: for nftables rules and logging.
- osmo_sockaddr_cmp() matches on identical IP addresses "only", without
  the port numbers causing mismatches: for finding tunnels and devs.

Change-Id: If49f1e82e8cb92b7225e85a7c3b059e0f7f92fa3
2022-12-09 18:28:19 +01:00
Neels Hofmeyr 08af1f15f8 nft: ensure to assign rule id only once
Make sure an assigned id is not overwritten.

So far this function was guaranteed to be called only once. But I would
like to allow getting the nftables ruleset string more than once in a
future patch. Prepare that.

Change-Id: I4e8c48c01fb2f5d4cfd223fe03abbf15b1a55670
2022-12-09 18:28:19 +01:00
Neels Hofmeyr bd737c14fa nft: end each rule in semicolon
also cosmetic: put the line ending in a separate PRINTF so that adding
or removing items to the rule in future patches does not affect the line
ending.

Change-Id: I6ff6f59fb24a18596aa60848fb00ac70deb1985f
2022-12-09 18:28:19 +01:00
Neels Hofmeyr 2a9d91792e nft: log nft rulesets on debug log
Change-Id: I4436d107dc37abf3669970e8e5346d714dd17192
2022-12-09 17:26:09 +00:00
Neels Hofmeyr 95e56eaecb nft: rewrite source IP in outgoing GTP-U
Change-Id: I6d293c1dc69d1bab714564f48e3f85b769501d13
2022-12-09 17:25:58 +00:00
Neels Hofmeyr 341e130841 nft: incoming GTP-U: match on local IP, not remote IP
Change-Id: Ib6db148ca350107b2fc7adcaec0fc2930ffcbcde
2022-12-09 17:25:58 +00:00
Neels Hofmeyr feeaf35e44 nft: rename addr to addr_remote, add addr_local
Change-Id: I8d2ca99b17c26d1a869f4d84ad57157d29d9750b
2022-12-09 17:25:58 +00:00
Neels Hofmeyr 629647a535 in GTP actions, also store local GTP addrs
At first, this mostly improves logging of GTP actions.

Subsequently, we will use these to:
- for tunend, pick a GTP device based on the local interface.
- for tunmap, change the netfilter rules to match on the *local* GTP
  address instead of the remote one.

Related: SYS#6192
Change-Id: I8488c478c4790d3882b22dcdb1f127838e23dd7b
2022-12-09 17:25:58 +00:00
Neels Hofmeyr 1a341ee418 fix PFCP Session Mod: Update FAR
Fix parsing of the Update FAR information so that a Session Modification
Request properly causes a GTP action to become active:

Add missing forw_params_present = true, and copy the information from
the incoming message instead of the current state.

Related: SYS#6192
Change-Id: I2a2c015d5615bb461b4d7b476a7c9830dc8e130f
2022-12-09 17:25:58 +00:00
Neels Hofmeyr d059391125 log: add missing sep in far_to_str
Change-Id: I1789cdb65b1e355d28cb6d22c8a18e011c202383
2022-12-09 17:25:58 +00:00
Neels Hofmeyr 3572241df5 tunmap: choose local GTP addr by Network Instance IEs
Add 'netinst' config section to osmo-upf.cfg, to define Network Instance
name to local IP address mappings.

For the tunmap use case (forwarding GTP tunnels), heed the Network
Instance IEs in PFCP session creation and return IP addresses in F-TEIDs
accordingly.

Related: SYS#6192
Related: I37bebc7d6ef75c3e6ae05e81b83a1b5895839a64 (osmo-ttcn3-hacks)
Change-Id: I15ee046a1c37b83b8a83527a67a6215a30106d81
2022-12-09 17:25:58 +00:00
Neels Hofmeyr e68eca0e8f clarify comments and naming around PDR+FAR classification
No functional change.

Rename forw_to_core to access_to_core.
Rename forw_from_core to core_to_access.

Rename add_gtp_action_endecaps to add_gtp_action_tunend.
Rename add_gtp_action_forw to add_gtp_action_tunmap.

Add assertions to clearly indicate expected PDR and reverse PDR
directions.

Tweak various comments and log messages.

Fix some comments that have Access / Core flipped.

Change-Id: Ia199bb6944476eff6af89b5ab015a9a2f8ce330e
2022-12-09 17:25:58 +00:00
Neels Hofmeyr 8e842b890c fix access/core mixup of PDR IDs / tunmap FAR
The GTP action detection always has 'pdr' detecting on the Access side
and its reverse 'rpdr' on the Core side.

  Access      osmo-upf      Core
    |------>  pdr|far  ----->|
    |<------ rfar|rpdr <-----|

Related: SYS#6192
Change-Id: I66babdfe4c1746bd3bf259342ce80dae2661de8c
2022-12-09 17:25:58 +00:00
Neels Hofmeyr d7f683a66c VTY 'show gtp': more accurately identify local/remote IP
Indicate whether a shown IP address is local or remote, by adding '-l'
or '-r' to the field names shown.

So far, osmo-upf is only tracking remote GTP addrs, but we are about to
implement choosing local GTP addrs by Network Instance IEs. Those should
also be shown and will need to be set apart from the remote addresses.

Related: I440466f1cc9689391869ac2579a4497ef6008adb (osmo-ttcn3-hacks)
Change-Id: Ic539ebe84a0853f665e5b8b8489dd587e6907287
2022-12-09 17:25:58 +00:00
Neels Hofmeyr 65788ed64e gtpu_echo: do not osmo_fd_register twice
Change-Id: Ib498cc8d5252c05e12196f84bd1ea18d67e3052c
2022-12-09 17:25:58 +00:00
Oliver Smith 88b3b63987 debian: add osmo-pfcp-tool to osmo-upf package
Make the osmo-upf debian package consistent with the rpm package, by
adding osmo-pfcp-tool to it.

Related: OS#5817
Change-Id: Icf4bb566d9b627ead370174e92629a9fccde755e
2022-12-08 16:52:07 +01:00
Neels Hofmeyr 391259bd8c use osmo_pfcp_ie_outer_header_creation_to_str_buf()
Fix missing IP address in to-string of Outer Header Creation IE: Use
osmo_pfcp_ie_outer_header_creation_to_str_buf() from libosmo-pfcp
instead of re-inventing.

Depends: I4ad1570485c8081b82284e4e6b4de4d7eed414b0 (libosmo-pfcp)
Change-Id: I0d4d9edcfc94b61bdc74cfd4ff837f151d1c28ae
2022-12-01 00:59:36 +01:00
Neels Hofmeyr 6d17c43c42 up_gtp_action_to_str_buf(): always print PDR IDs
Change-Id: I16dae4d693850435e98e8ba18ea4ab339ee28e23
2022-12-01 00:58:24 +01:00
Neels Hofmeyr 54ebc4772b VTY: show gtp: still list tunmap if no tunend device is open
When there was only tunend implemented, it made sense to show on VTY
when no GTP kernel device was open. Since we now also have tunmap via
netfilter, drop the early exit.

Change-Id: I9a43a240f2ca55cf2ca237a83aa13e68a625d6ea
2022-11-21 17:28:05 +01:00
Neels Hofmeyr 0575e9bad9 vty: revert rename of 'show gtp'
Rename 'show tunend' back to 'show gtp'.
Clarify the VTY doc.

While renaming 'gtp' to 'tunend', i also renamed the general 'show gtp'
VTY command by accident / by misunderstanding. This command shows all
GTP tunnel state, not just the tunend state.

Reverts a small portion of commit "VTY: rename 'gtp' to 'tunend'"
  95eb2c6a89
  I49ac7b1f8b5b74f586edfed1dfb29f9af55a521b

Change-Id: I8f619d4ddda3efffb62cf594878d3166cb37fe45
2022-11-21 16:47:22 +01:00
Neels Hofmeyr 28180a6246 cosmetic: rename upf_gtp_dev_tunnel_* to upf_gtp_dev_tunend_*
Change-Id: I73e7b3c4841520909185aaba3ec41c6cf1e3ff51
2022-11-19 00:10:14 +01:00
Neels Hofmeyr 0fca3412d8 drop unused upf_gtp_dev_is_tunnel_active()
Change-Id: Ia8517f702118af55ce47a4f63fb08ac5ee284217
2022-11-19 00:09:56 +01:00
Neels Hofmeyr b183aa84af cosmetic: rename upf_gtp_tun to upf_gtp_tunend
Change-Id: I0815012679237838a031e28c0afb98b7e0d184bd
2022-11-19 00:03:28 +01:00
Neels Hofmeyr 527f1b3b94 cosmetic: in code, rename 'endecaps' to 'tunend'
Change-Id: I55ce7cc842f36b2528e6a1a15d6f3bcb960f492b
2022-11-18 23:49:14 +01:00
Neels Hofmeyr cd3f25cc20 osmo-pfcp-tool VTY: rename 'endecaps' to 'tunend'
We're establishing 'tunend' as short name for
encapsulation/decapsulation, also do this in osmo-pfcp-tool.

Keep a hidden "session endecaps" VTY cmd as backwards compat alias.

Related: SYS#6192
Change-Id: I0b44429cd6762fe401a4dced22ae2a3fd9bbe93b
2022-11-18 23:49:14 +01:00
Neels Hofmeyr 701bb8addc VTY: rename 'nft' to 'tunmap'
So far the config nodes were named after the implementation:
"GTP kernel module" = "gtp" and
"netfilter" = "nft"

We found that this is confusing, since both are related to handling GTP.
Rename "nft" to "tunmap"; a previous patch already renamed "gtp" to
"tunend".

Keep a hidden "nft" VTY cmd as backwards compat alias.

Related: SYS#6192
Change-Id: Ia3c5224dd3b5f5c9437bbdec997d02176818cc97
2022-11-18 23:49:14 +01:00
Neels Hofmeyr 95eb2c6a89 VTY: rename 'gtp' to 'tunend'
So far the config nodes were named after the implementation:
"GTP kernel module" = "gtp" and
"netfilter" = "nft"

We found that this is confusing, since both are related to handling GTP.
Rename "gtp" to "tunend"; a subsequent patch will rename "nft" to
"tunmap".

Keep a hidden "gtp" VTY cmd as backwards compat alias.

In log output, also print "tunend" instead of "endecaps"
(up_gtp_action_to_str_buf()).

Related: SYS#6192
Change-Id: I49ac7b1f8b5b74f586edfed1dfb29f9af55a521b
2022-11-18 23:49:14 +01:00
Neels Hofmeyr 80aefa42c6 tests/upf.vty: add some missing nodes to the test
Change-Id: I93c49dce23efaf9c533619112fb7a8114e258fa0
2022-11-18 23:49:14 +01:00
Neels Hofmeyr a3b5488b69 drop unused enum up_session_kind
Change-Id: I10e17338485b11d6c03da209c70323f69f93fc2e
2022-11-18 23:49:14 +01:00
Neels Hofmeyr 6730f104d8 silence misleading error: "HEARTBEAT_REQ: Unknown message type"
Heartbeat is handled in libosmo-pfcp, osmo-upf does not need to take any
action.

Related: SYS#5599
Change-Id: Id81556129b528fa3a1f11ae4d01ad8b89a9be2f9
2022-11-06 22:20:46 +01:00
Neels Hofmeyr 2d2fcd81bc vty doc: indicate default nft table name
Change-Id: I79b4d287cae47c37b45a35904f298e57120a65f0
2022-09-17 23:02:40 +02:00
Neels Hofmeyr ffc461ab38 manual: add 'Configure Primary Links'
Add section 'Configure Primary Links' with detailed explanation of the
GTP and netfilter setup.

Related: SYS#5599
Change-Id: I2378d4856b28e81dae2a85e20aaf2999768de4d9
2022-09-17 23:01:49 +02:00
Neels Hofmeyr 361ecd8cd0 manual: add/fix running.adoc
Actually add running.adoc to osmoupf-usermanual.adoc so that the chapter
shows in the generated PDF.

Related: SYS#5599
Change-Id: I1ae668ff75882e7ac55dd5b27566a68c449bdee5
2022-09-17 23:00:12 +02:00
Vadim Yanitskiy 7c3eeb0760 update git URLs (git -> https; gitea)
Change-Id: I7e0190b36861710d8cc8dd0cfd50d3dbe301ede5
2022-09-08 13:47:38 +00:00
Max c88dc7866f Set working directory in systemd service file
By default systemd will execute service with root directory (or home directory for user instance) which might result in
attempts to create files in unexpected place. Let's set it to 'osmocom' subdir of state directory (/var/lib for system instance) instead.

Related: OS#4821
Change-Id: I786e4a655c35617bbea523275a709e865fc86689
2022-09-05 13:05:43 +00:00
Neels Hofmeyr f95bd5b895 drop charts/, duplicated from libosmo-pfcp.git
When placing libosmo-pfcp in a separate repository, I accidentally
duplicated the charts. Since the charts are generally valid for PFCP,
libosmo-pfcp is the proper place, not here.

Change-Id: I95f11e1525b3bc6b782e5f8aecddea672a104c99
2022-08-30 14:21:31 +00:00
Neels Hofmeyr 114277cff7 Allow running without a GTP dev
Allow running without opening a GTP dev for encapsulation/decapsulation.
Probe and open the mnl socket for talking to the GTP kernel module only
when actual GTP devices exist in the config.

A site that is only doing tunnel proxying via netfilter hence does not
require GTP support in the kernel.

Change-Id: Ibb79b3ce1906136f77a895ff6f691d72a92c9fb9
2022-08-30 14:21:14 +00:00