Commit Graph

767 Commits

Author SHA1 Message Date
Harald Welte c5150cecc5 gtpie: Add doxygen API documentation
libgtp should have proper API documentation, let's start with the
gtpie.[ch] parts.

Change-Id: I97df5bd3c8dcc5c97a114c8c6abadabf33147b05
2017-10-13 16:36:43 +02:00
Harald Welte 02af9b3ca2 gtpie_tlv() gtpie_tv0(): const-ify read-only input argument
Change-Id: Ide487e34884c8356694246f43c3f1f562357304c
2017-10-13 16:36:43 +02:00
Harald Welte db924d3908 Add unit tests for lib/in46_addr.c code
Change-Id: Id032c330405e5dca8ecfc0970d128341ed75c675
2017-10-13 16:36:39 +02:00
Harald Welte 34a7416ec0 in46a_to_sas(): Return AF_INET6 in case of IPv6 address
Change-Id: Ia2f9ac60f08823d5f7c1a76c0b7cbd65ac615e26
2017-10-13 16:28:01 +02:00
Pau Espin 45ce2725ac tests: Remove Makefile.in
Change-Id: Ie21e8bfab7cda52aa696dd26280efc05c4b51bba
2017-10-13 16:28:01 +02:00
Harald Welte a2eb5eb760 update .gitignore
Change-Id: I030bd616dd27d49e55b5bdcc7c0b4fa3eb523da4
2017-10-13 16:28:01 +02:00
Pau Espin fdd732b130 Remove trailing whitespace
Change-Id: I8e24f95a88bef3a59006a89c219871e6156963d7
2017-10-13 16:28:01 +02:00
Harald Welte 1d8ffc6b23 Add ippool unit-test for 'make check' runs
This test creates a variety of v4 (and one v6) pool and performs
allocations until the pool is full, then frees a random number of
randomly distributed addresses, re-allocates them and again checks that
they're all available and finally once the pool is full allocations
fail.

Change-Id: Ibf4588e8f3ae71684e5262c0caaa2689aee73a94
2017-10-13 16:28:01 +02:00
Pau Espin 58c0da7833 lib/tun.c: tun_ipv6_linklocal_get(): fix memory leak with getifaddrs()
From getifaddrs(3) man:
"The data returned by getifaddrs() is dynamically allocated and should
be freed using freeifaddrs() when no longer needed"

Change-Id: If6300d1c8d36fcafef294a4c11bbda31a158bb9c
2017-10-12 18:00:16 +02:00
Pau Espin 958256f5cf create_context_ind(): Fix crash on apn not found
Program terminated with signal SIGSEGV, Segmentation fault.
0  create_context_ind (pdp=0xb6b391b0 <pdpa>)
    at /usr/src/debug/osmo-ggsn/1.0.0+gitrAUTOINC+ab5e160937-r0/git/ggsn/ggsn.c:453

453             if (!apn->started)

(gdb) bt
0  create_context_ind (pdp=0xb6b391b0 <pdpa>)
    at /usr/src/debug/osmo-ggsn/1.0.0+gitrAUTOINC+ab5e160937-r0/git/ggsn/ggsn.c:453
1  0xb6b225e0 in gtp_create_pdp_ind (gsn=gsn@entry=0x74f28, version=version@entry=1, peer=0x0,
    peer@entry=0xbee6ead4, fd=-1092167056, fd@entry=8, pack=pack@entry=0xbee6eae4, len=len@entry=179)
    at /usr/src/debug/osmo-ggsn/1.0.0+gitrAUTOINC+ab5e160937-r0/git/gtp/gtp.c:1591
2  0xb6b245e4 in gtp_decaps1c (gsn=0x74f28)
    at /usr/src/debug/osmo-ggsn/1.0.0+gitrAUTOINC+ab5e160937-r0/git/gtp/gtp.c:2986
3  0x41d770c0 in osmo_select_main () from /usr/lib/libosmocore.so.8
4  0x000121b8 in main (argc=4, argv=0xbee70e54)
    at /usr/src/debug/osmo-ggsn/1.0.0+gitrAUTOINC+ab5e160937-r0/git/ggsn/ggsn.c:897

Fixes: dd266066c7, b16c46b4c3

Change-Id: Ie4ec74e87aaf1d067dd1717d986673be56c4d6ed
2017-10-11 20:37:24 +02:00
Harald Welte 6748dc90b8 sgsnemu: Add IPv6 support via tun device and "-t v6 --createif"
The idea is to only implement the GTP-C plane and configure the right
link-local source address on the tun-device and let the regular (Linux)
kernel take care of sending router solicitations and
accepting/processing the related router advertisement.  This avoids a
lot of complexity in sgsnemu.

For this to work, you must have /proc/sys/net/ipv6/conf/$tun/accept_ra
set to either 1 (works only if no IPv6 forwarding/routing configured on
your sgsnemu-running system) or 2 (works even if forwarding/routing is
configured).

Change-Id: I57e4c53ee648e1efecfba3eea592d1129849557c
Closes: OS#2518
2017-10-10 08:56:09 +08:00
Harald Welte 7bd7b6815a Merge "create_context_ind(): ignore a non-started default APN" 2017-10-01 10:31:09 +00:00
Harald Welte b16c46b4c3 create_context_ind(): ignore a non-started default APN
If the default APN has not been started, it is not eligible to be
used in starting of new PDP contexts.

Change-Id: I93b5c205c033f275824ee8bc8cdcf1428fb086df
2017-10-01 18:29:41 +08:00
Harald Welte 840a8e9713 sgsnemu: Allow specification of PDP (EUA) Type IPv4 or IPv6
This just adds the capability to sgsnemu to request a certain PDP
EUA type.  It doesn't mean it actually handles anything beyond the
existing IPv4 yet.

Change-Id: I157f9157a7ff2ea56c37a4a902d4706de4c7d35d
2017-10-01 18:19:07 +08:00
Harald Welte cee7546f15 Replace EUA magic numbers for IETF, IPv4 and IPv6 with #defines
Change-Id: I33f65e404217e717bd795e5229c8d9456a7b3739
2017-10-01 18:19:07 +08:00
Harald Welte ed1ba2c902 apn_start(): Extend error message when setting IPv6 address fails
Tell the user about possible causes of failure to set the IPv6
address of the tun device, such as general lack of IPv6 support in
the kernel/OS, or the use of /proc/sys/net/ipv6/conf/default/disable_ipv6

Change-Id: I5ff812425ee12b8386bb66521e05c93e825a4506
2017-10-01 18:19:07 +08:00
Harald Welte ed08eb1c5a apn_stop(): Print tun device name when closing tun device
Change-Id: If981cc0696122cb69c01ceac6f54ae01bcbf4a2d
2017-10-01 18:19:07 +08:00
Harald Welte 2e84d2c29a create_context_ind(): ignore any non-started APNs
If we receive a GTP-C CREATE PDP CONTEXT for an APN that we were
unable (or not configured) to start, ignore that APN.

Change-Id: I8011a9ccc1d5effd3779f184c9055af46838ccaf
2017-10-01 18:19:07 +08:00
Harald Welte dd266066c7 apn_start(): fix clean-up after errors bringing up APN
When there's an interim error (e.g. in resolving the link-local address
or setting up the tun device), apn_start() simply calls apn_stop()
on the not-yet-fully-started apn_ctx.

This only works if apn_stop() doesn't bail out early in case of
a not-started apn_ctx, so let's remove the related check at the
start of the function.

Change-Id: I2917a6258cb73cc12fd9d81296ff0eaa616890b9
2017-10-01 18:19:07 +08:00
Pau Espin b5624c3d48 contrib: osmo-ggsn.service: Use expected suffix for cfg file
files in doc/examples/ dir end with .cfg, as well as all configuration
files present in all projects.

Change-Id: I361c67809d095dd08b0f400de2a6f84f981411c5
2017-09-27 20:57:06 +02:00
Max 6a21527a2d Move extended PDP logging macro to header
It might be useful for any user of libgtp who uses libosmocore so let's
make generalized version of it available as part of installable header.

Change-Id: I79aba10ef989384a28f059c30899e65c771ae5e1
Related: SYS#3610
2017-09-25 10:35:34 +02:00
Harald Welte 1a8bc9839a Merge "sgsnemu: Add --no-tx-gpdu-seq option to suppress transmission of G-PDU sequence numbers" 2017-09-24 15:20:23 +00:00
Harald Welte 79aa4bd837 Merge "ggsn: Add per-APN VTY configuration option on G-PDU sequence numbers" 2017-09-24 15:20:23 +00:00
Harald Welte fbb9c7f59a sgsnemu: Add --no-tx-gpdu-seq option to suppress transmission of G-PDU sequence numbers
Related: OS#2519
Change-Id: Idc650d896f0f72329090b56a37d9c16359294860
2017-09-24 23:10:05 +08:00
Harald Welte 3c1cce245e libgtp: Allow each PDP context to specify if it transmits G-PDU sequence numbers
GTP sequence numbers on GTP-U are optional for G-PDU type messages (i.e.
user-ip messages).  Let's allow the user to specify this behavior by
a new pdu_t.tx_gpdu_seq flag.  The flag is enabled by default to stay
compatible with the prior behaviour.

Related: OS#2519
Change-Id: Icf22a2ddd5c4a968ef5bda7c202b921d93fb49e6
2017-09-24 23:10:01 +08:00
Harald Welte 93fed3bc51 ggsn: Add per-APN VTY configuration option on G-PDU sequence numbers
This per-APN vty option determines if we are transmitting GTP sequence
numbers in downlink G-PDU messages.  This behavior is optional as per
GTP spec.  The default behavior is "true", like before this change.

Related: OS#2519
Change-Id: Ibf0de261f83951309b01b4feae998b6656c77664
2017-09-24 23:10:01 +08:00
Harald Welte 00d346092b Merge "ggsn: Fix double whitespace in writing "ifconfig" lines" 2017-09-24 14:58:50 +00:00
Harald Welte 3ca419a2ef ggsn: Fix config file writing of IPv6 DNS settings
There was a copy+paste mistake that created syntax errors during the
write of a config file that contained IPv6 DNS server settings.

Change-Id: Ida40c32c72dba8155f8294b93484e46e8bd27739
2017-09-24 22:49:21 +08:00
Harald Welte ff438174aa ggsn: Fix double whitespace in writing "ifconfig" lines
This is merely a cosmetic issue, no functional change.

Change-Id: I8663ee633524eedeed5ddd45ddb65a06825052ac
2017-09-24 22:49:21 +08:00
Harald Welte f85fe9720b ICMPv6: Send router advertisement from own link-local address
I'm not quite sure how I ended up doing this, but for some strange
reason the code before this commit is sending the ICMPv6 Router
Advertisements from some weird non-standard source address.  This is
a violation of RFC4861 which clearly states that the source address
of router advertisements "MUST be the link-local address assigned to the
interface from which this message is sent."

Change-Id: Ib444af70fc8f0b433d371281601fd5a37b29039e
2017-09-24 20:51:47 +08:00
Harald Welte fed598f41d gtp: Avoid magic numbers when operating on GTP header flags
Let's introduce a couple of #defines that make the code much more
readable.

Change-Id: I3635d679fd54507274b46e99a02bdbbe41d7684e
2017-09-24 16:53:16 +08:00
Harald Welte 471e349ecc libgtp: Avoid extra memcpy() in gtp_data_req() by using sendmsg()
Adresses two "TODO Should be avoided" comments about an extra memcpy()
before sendto() that can be replaced by a single sendmsg() call with an
iovec array: 1 record for the GTP header + 1 record for the user payload.

Change-Id: Ie332a6b15972330fcf540753898eb84ecb84fe24
2017-09-24 16:12:39 +08:00
Harald Welte 7e1175f6d8 sgsnemu: Fix gengetopt package name
gengetopt by default picks the program name from PACKAGE (autotools),
which is osmo-ggsn and is obviously wrong in case of sgsnemu.

After this patch, "sgsnemu --help" no longer shows "osmo-ggsn" but
"sgsnemu" at the top of the help text.

Change-Id: Ifabc2435a503ef71aa5a002ca46833f329068b37
2017-09-24 10:53:53 +08:00
Harald Welte f621498129 sgsnemu: Re-generate cmdline.[ch] using gengetopt
This will replace the manual additions to cmdline.[ch] with
auto-generated code from gengetopt.  We need to fix-up the RAT Type in
sgsnemu.c as the manually-added code diverged from what gengetopt
generates.

Change-Id: Ia687e13d5cec1655a57078a767d2123aa022842c
2017-09-24 10:27:07 +08:00
Harald Welte 7c20148e39 sgsnemu: Fix up gengetopt file for --norecovery
In commit 3a4c67b4bf we introduced the
--norecovery command line option, but this was apparently done by
manually editing the C source code rather than adding it to the .ggo
and letting gengetopt do its magic.  Let's fix this up.

Change-Id: I1698280a699b17cea65651c3736ef149aba7e432
2017-09-24 08:56:14 +08:00
Harald Welte b6fc227763 sgsnemu: Fix up gengetopt file for RAI
In commit 41af5691ef we introduced the
--rai command line options, but this was apparently done by
manually editing the C source code rather than adding it to the .ggo
and letting gengetopt do its magic.  Let's fix this up.

Change-Id: Iaab404c3bcfc0c3943764f6616763f4f407d5644
2017-09-24 08:53:58 +08:00
Harald Welte 1d94585f96 sgsnemu: Fix up gengetopt file for rattype, userloc, mstz, imeisv
In commit 944dce3e66 we introduced various
command line options, but this was apparently done by manually editing
the C source code rather than adding it to the .ggo and letting
gengetopt do its magic.  Let's fix this up.

Change-Id: Ib8e7ef1cad5fc4423a1a4af628950aa93a4e073a
2017-09-24 08:51:02 +08:00
Harald Welte 05ac095006 sgsnemu: Fix up gengetopt file for QoS Extensions of 24.008
In commit 11a398fbc3 we introduced the
--qose{1,2,3,4} command line options, but this was apparently done by
manually editing the C source code rather than adding it to the .ggo
and letting gengetopt do its magic.  Let's fix this up.

Change-Id: I4cd827a96ac17f6eb9f824342f195727426d0e20
2017-09-24 08:41:14 +08:00
Harald Welte 73d28c9dda sgsnemu/cmdline.ggo: Remove 'unsigned' which is no longer supported
It seems like modern gengetopt no longer supports 'unsigned int'
argument types, and we need to use 'int' instead.  tested with 2.22.6

Change-Id: I34ca86cb3cc482400a7c4b3bf77c8668aaef562e
2017-09-24 08:34:36 +08:00
Max ea70f3619a Fix leftovers after rename
* Use proper name in jenkins test
* Fix naming in systemd service
* Fix git-review config

Change-Id: I934f897002215d7d4e610cbd312383181bbe97c9
2017-09-15 12:19:23 +02:00
Harald Welte 98146776dd ggsn: Add ability to specify local IP addresses for GTP-C and GTP-U
In case the GGSN is behind some kind of DNAT, the public GTP-C and
GTP-U IP addresses as exposed inside the GTP payload information
elements are different from the (internal, behind-nat) IP address
to which it listens/binds.

Change-Id: I548c9011c9abd66d46f963b1def61575f3dabb89
2017-09-06 12:22:31 +02:00
Harald Welte b5b02c2a51 Bump version: 0.94.34-23e4 → 1.0.0
Change-Id: I00a00a7d537fd3c1ff8f8fe128c5bf82d39bda76
2017-09-06 12:22:28 +02:00
Harald Welte bd60930f36 libgtp: Bump major LIBVERSION for recent API/ABI breakage
in Change-Id I68ae49a765828fa681054c68bf7f5e74dbe48ad2 we introduced
a new struct member that breks ABI and API.

Change-Id: Ie631880155513b1b78d1e9dd473dc5dc50e05943
2017-09-06 12:22:05 +02:00
Harald Welte 720c939799 clarify relationship of OsmoGGSN to OpenGGSN.
Change-Id: If0e18fb02a7dcc472f5f5fbfaf53a107382ef7e5
2017-09-06 12:11:44 +02:00
Harald Welte 4aa22db1b4 debian: fix name of config file
Change-Id: I9e563d41b74c334fd98bb71fad946e93f214fa34
2017-09-06 10:54:14 +02:00
Harald Welte db08819f85 debian: Remove no longer existing NEWS file from 'docs'
Change-Id: Ieb319ea29179ed97d746e13a9e63b3ceea2b917a
2017-09-06 10:54:13 +02:00
Harald Welte 8fcfe58269 debian: Fix debian/copyright syntax
Change-Id: I819ca05440cca041f26e7800821f4763f887c08b
2017-09-06 10:54:11 +02:00
Harald Welte ce316f4962 Move examples to doc/examples and include them in DIST
Change-Id: I0846e21ac63774939934ab629c6d7212269be9a6
2017-09-06 09:17:15 +02:00
Harald Welte 59ffc89d42 remove bogus 'version' script
Change-Id: I3977cd4777aa4cf37a1d6e21eba0bc37d61421f3
2017-09-06 09:17:15 +02:00
Harald Welte 632e843e5f Rename OpenGGSN to OsmoGGSN
Osmocom has maintained this program since about 7 years now, while
the original author / copyright holder has completely disappeared.

With the introduction of Osmocom-style CTRL and VTY interfaces,
the way how the program is used and configured has substantially
changed.  In order to avoid confusion in terms of configuration file
format etc, let's rename it to OsmoGGSN.

Change-Id: I2da30f7d4828e185bfac1a4e2d8414b01cbe4f9d
2017-09-06 09:17:15 +02:00