Commit Graph

767 Commits

Author SHA1 Message Date
Harald Welte 9225bfc48c update version to 0.93
Change-Id: If65b8281933b5833b5ce83239688e775cc267f4c
2017-02-23 21:52:56 +01:00
Harald Welte bf5c0bb4b9 gtp.c: Don't print ""Unknown packet flags" error message in get_seq()
get_seq() is called also from contexts where GTP-U is used, and GTP-U
doesn't have sequence numbers.  Thus, it is perfectly normal if no
sequence number and/or no S flag in the header is present.

Change-Id: Ie19b95bbb4427e547843a019f5213a231a9f83da
2017-02-23 21:11:05 +01:00
Harald Welte 875e4dc8c3 gtp-kernel: Fix tunnel creation/removal for GTP Version 1
When Linux Kernel GTP-U support is enabled, OpenGGSN so far only worked
with GTPv0,but not with GTPv1, as the TEI values were not correctly
configured.  This patch fixes the initialzation of the local and remote
TEI before using libgtpnl to create a tunnel context in the kernel.

Change-Id: I3e953ff5b4ab44c26dbbe20d18b61038fa57ff32
2017-02-23 21:10:48 +01:00
Holger Hans Peter Freyther 68d244d302 abi/debian: Bump ABI version of libgtp after struct size change
The gsn_t changed the size with the addition of the ctrl pointer.
Bump the SO version to not break osmo-sgsn/ggsn on upgrade.

Call the -dev package libgtp-dev to follow the rest of Osmocom and
to ease making releases here.

Change-Id: Iac4d6d2effde1a6b2f60b1e1b49c91513d5ca8c3
2017-01-26 11:14:59 +01:00
Max 7716860845 Integrate Debian packaging changes
debian/control:
    * restructure to make it easier to incorporate further changes
    * update package descriptions
    * update project URL

debian/rules:
    * use proper hardening syntax
    * remove useless comment

debian/copyright: update to match Debian format

Change-Id: Ia7f0a3a583ad63f5c6e5cf5e5de2ff7dd9eed8a9
Related: OS#1694
2016-12-22 14:10:07 +00:00
Harald Welte d37b80a6d2 gtp.c: Improve debug statements about GTP header flags
* as there are muptiple flags in the field, use plural
* print the flags as hex value, not decimal.  Hex is customary for bitfields.

Change-Id: Ib23d80fae32b4e9fa146d82d8f5a1dada1a3cb2b
2016-12-15 20:55:54 +01:00
Max dbd7024919 Only send TRAP for defined PDP peer
Do not attempt to send TRAP message on PDP context deletion if peer is
unknown.

Change-Id: I5e02c1d42bb7aaf1ef81a9824aab7b12047cdd3e
Fixes: Coverity CID 150135
2016-11-02 09:32:31 +00:00
Neels Hofmeyr f41f5866ce gsn_restart file: wrap umask change tightly around file creation
An fopen("w") error used to omit the umask() call to reinstate the previous
umask. Also an fopen("r") at the top will never create a file and hence does
not need a umask set.

Instead, wrap the umask change and change-back tightly around the single
fopen("w") call.

Change-Id: If7d948e2f2ba47ecebba5614f18235a53b273d14
2016-10-14 11:39:49 +00:00
Neels Hofmeyr f7611c3cee fix gsn_restart file buffer overflow and missing path sep
Fix errors during gsn_restart file path composition:

- possible buffer overflow because the wrong remaining length was fed to
  strncat().
- missing path separator: put restart file in dir/gsn_restart instead of
  ../dirgsn_restart.

This assumes that the path separator is '/'.

Use talloc_asprintf() to fix all filename length problems and shorten the code.

In order to free the allocated path, add a free_filename label, and jump there
instead of returning from the fopen("w") failure branch. Also don't return from
"fclose failed" branch in order to free the path, remove the if {} braces.

Change-Id: Idf0a64ff45720aa818f2f9de1e8ba2fe2c82631b
2016-10-14 11:39:49 +00:00
Neels Hofmeyr 38929c9131 configure: check for pkg-config presence
Change-Id: I658152eb24fd783fce9ceac35872ab918c80209a
2016-10-12 23:26:17 +00:00
Neels Hofmeyr ee9d34a9cc build: be robust against install-sh files above the root dir
Explicitly set AC_CONFIG_AUX_DIR.

To reproduce the error avoided by this patch:

  rm install-sh        # in case it was already generated.
  touch ../install-sh  # yes, outside this source tree
  autoreconf -fi

This will produce an error like

  ...
  configure.ac:16: error: required file '../ltmain.sh' not found
  configure.ac:5: installing '../missing'
  src/Makefile.am: installing '../depcomp'
  autoreconf: automake failed with exit status: 1

See also automake (vim `which automake`) and look for 'sub locate_aux_dir'.

Change-Id: I4aef311d7a475800e09f48110a499c3759c69f5d
2016-10-12 23:26:17 +00:00
Max 727417dd28 Add control interface
Only generation of TRAP messages over Control Interface is supported so
far.

Note: requires corresponding version of libosmoctrl.

Change-Id: Ia76f841d2c9cd14394e9316fcd39f4060e23c898
Related: OS#1646
2016-10-12 09:30:30 +00:00
Max cd93f4f4be Add .gitreview to simplify gerrit integration
Change-Id: Ib141dc9ae03c2b10b8925e30a2782bf2d932e192
2016-10-12 09:25:49 +00:00
Max 395e213894 Remove unused function
Change-Id: Iff0f1499660b12a47277b16a435efecb42fab038
2016-10-11 15:31:49 +02:00
BJovke 03dbafb000 Add 'Bearer Control Mode' IE
This IE is known to be sent by a Cisco GGSN, and was added in
ETSI TS 129 060 V7.17.0 (2011-10) /
3GPP TS 29.060 version 7.17.0 Release 7

See https://lists.osmocom.org/pipermail/osmocom-net-gprs/2016-September/000711.html
Subject "sgsnemu failing to create PDP context with Cisco GGSN"
Tue Sep 13 08:00:37 UTC 2016

Tweaked-by: Neels Hofmeyr <nhofmeyr@sysmocom.de>
2016-09-15 13:53:13 +02:00
Alexander Couzens 86540de7f3 gtp/queue/queue_seqdel(): fix element check which was always true
Fix an apparent typo that prevented queue iteration to find the correct item to
be removed. Instead, the first item was always returned. Calling code has been
analyzed to find that mostly this fault is not visible, since usually, the
first item is indeed the correct item to be returned. See mail thread
http://lists.osmocom.org/pipermail/osmocom-net-gprs/2016-June/000618.html
Date: Wed Jun 1 11:51:38 UTC 2016
Subject: "[PATCH] gtp/queue/queue_seqdel(): fix element check which always was true"
2016-06-06 00:45:10 +02:00
Ruben Undheim cc077ae0bc Description: Fix some typos in the man pages and in the binary 2016-05-24 23:31:47 +02:00
Holger Hans Peter Freyther 6bf2f05df6 debian: Bump the version to ease upgrading from Debian
Debian SID has version 0.92-1 and we had 0.92. Bump it to 0.93.
2016-05-24 22:55:38 +02:00
Pablo Neira Ayuso 0eaa5b8e6c gtp: fix several compilation warnings
CC       gtpie.lo
gtpie.c: In function 'gtpie_encaps':
gtpie.c:437:22: warning: variable 'm' set but not used [-Wunused-but-set-variable]
  union gtpie_member *m;
                      ^
gtpie.c: In function 'gtpie_encaps2':
gtpie.c:537:22: warning: variable 'm' set but not used [-Wunused-but-set-variable]
  union gtpie_member *m;
                      ^

lookup.c: In function ‘lookup’:
lookup.c:40:24: warning: typedef ‘ub1’ locally defined but not used [-Wunused-local-typedefs]
  typedef unsigned char ub1; /* unsigned 1-byte quantities */
                        ^

Still one compilation warning left in cmdline.c, but that code
is autogenerated.
2016-05-12 17:02:34 +02:00
Pablo Neira Ayuso 176e895bd6 ggsn: fix compilation error with --disable-gtp-kernel
gtp-kernel.h: In function ‘gtp_kernel_init’:
gtp-kernel.h:25:15: error: ‘struct gengetopt_args_info’ has no member named ‘gtpnl_given’
  if (args_info->gtpnl_given) {
               ^
Makefile:422: recipe for target 'ggsn

Reported-by: Holger Freyther <holger@freyther.de>
2016-05-12 16:54:56 +02:00
Pablo Neira Ayuso 23d9976039 get rid of accidental copy of ggsn.conf
Included accidentaly in 8419e33 ("examples: ggsn.conf: document
tp-linux toggle").
2016-05-10 19:18:06 +02:00
Pablo Neira Ayuso 466da99934 configure: rename from --enable-gtp-kernel to --enable-gtp-linux
This software seems to run on other *nixes, so indicate explicitly that
this is the Linux kernel datapath support.
2016-05-10 19:11:43 +02:00
Pablo Neira Ayuso 8419e33c4a examples: ggsn.conf: document gtp-linux toggle
Enable Linux kernel GTP datapath driver.
2016-05-10 19:06:54 +02:00
Pablo Neira Ayuso d9d7be339d ggsn: cmdline: no need to specify interface anymore
--gtpnl is now gone, instead you have --gtpkernel that behaves as an on/off
toggle. We full rely on the kernel routing base to select the real device to
transmit.

I have updated ggsn/cmdline.ggo and then run 'gengetopt' to refresh the
automatic code generation for command line options that openggsn uses.
2016-05-10 19:06:01 +02:00
Pablo Neira Ayuso 7b31987a46 ggsn: gtp-kernel: adapt gtp_dev_create() to its new interface
Andreas modified this interface, so update so this compiles again.
2016-05-10 18:51:00 +02:00
Neels Hofmeyr f89dc4e127 queue_new(): fix NULL dereference on allocation failure
Coverity complains about a 'Dereference before null check' on *queue.
So, push the NULL check further up.

Though I doubt that 'return EOF' is the proper way to handle allocation
failure, this patch is only about the NULL dereference.

Fixes: CID#57918
2016-04-29 13:01:06 +02:00
Holger Hans Peter Freyther b29ff1da55 jenkins: Add the build script from jenkins here
This can be used to replicate a build issue more easily.
2016-04-13 19:02:13 -04:00
Daniel Willmann d997552d29 gtp: Handle gtpv1 in gtp_update_pdp_conf() correctly
libgtp cannot understand its own update pdp request (in gtp v1)
Only require the conditional and mandatory fields for gtpv1 and not
others.
Refer to 3GPP TS 29.060 Ch. 7.3.4
2016-02-05 07:48:20 +01:00
Daniel Willmann 05f3ef3eb8 gtp: Make gtp_update_pdp_conf() work for gtp0 and gtp1 connections
pdp_getgtp1(&pdp, get_tei(pack)) works like pdp_getgtp0 for gtp0
connections.
Using get_hlen() for gtpie_decaps is used in other places to decode ies
for both version 0 and 1.
2016-02-04 13:17:19 +01:00
Daniel Willmann 134a7752fd gtp: Pass pdp along when calling gtp_req() in gtp_update_context()
With no pdp parameter gtp_req() will send the packet to TEID 0 which is
not what we want. When trying to modify an established pdp context the
correct TEID of that context must be used.
2016-02-04 13:17:02 +01:00
Holger Hans Peter Freyther 8ddb6805a9 gtp: Do not leak the restart counter file handle in case of error
If the file exists but can not be read the file would not be closed.
Jump to a label that will close f.

Fixes: CID#57917
2016-01-23 10:40:52 +01:00
Holger Hans Peter Freyther 3a9befb516 gtp: Fix a bunch of compiler warnings when just including gtp.h
Attempt to fix a bunch of compiler warnings in OpenBSC.
‘struct pdp_t’ declared inside parameter list
2016-01-23 10:16:53 +01:00
Andreas Schultz c80680a9c4 ggsn: fix autotool pkg-config invokation
see https://autotools.io/pkgconfig/pkg_check_modules.html, Optional Modules
for explanation

Signed-off-by: Andreas Schultz <aschultz@tpip.net>
2015-12-21 08:37:50 +01:00
Andreas Schultz c5fbf9bd68 ggsn: update gpt-kernel logging to libosmocore
Signed-off-by: Andreas Schultz <aschultz@tpip.net>
2015-12-21 08:37:26 +01:00
Pablo Neira Ayuso 4b075b6cb8 ggsn: add support for GTP kernel data encapsulation
This patch adds the -g, --gtpnl=device option that allows you to
enable the GTP kernel tunneling mode in openggsn. You have to specify
the real downlink device that will be used to tunnel traffic, eg.

	-g=eth0

This means that the gtp0 device will be created and it will use eth0
as the real device to encapsulate packet coming from the Internet that
are addressed to the MS (so the tunnel devuce encapsulates these IP
packets in GTP packets when traveling to the SGSN).

Alternatively, you can also add this to the ggsn.conf configuration file:

	gtpnl eth0

The device has to be the real device that can route packets to the SGSN,
if you select the wrong device, the kernel routing code may not find a
way to reach the SSGN, you've been warned.

Therefore, if this option is set, the operational becomes the following:

1) A gtp0 device is created via rtnetlink and configure the socket
   encapsulation infrastructure in the kernel.
2) Whenever a PDP context is created, this adds the necessary tunnel
   configuration via genetlink GTP interface.
3) Whenever a PDP context is destroyed, this deletes the tunnel via
   genetlink GTP interface.
4) Destroy the gtp0 device if ggsn is stopped, including all of the
   existing tunnels.

You require the osmo-ggsn.git tree, which contains the kernel module
gtp.ko and the libgtpnl library that you have to compile and install.
Make sure you have loaded the gtp.ko kernel module before launching
the ggsn daemon using the kernel driver mode, otherwise you will get
a nice "operation not supported" error message ;-).

This patch also adds supports for "ipup" configuration option to invoke
an external script after the gtp0 device has been brought up. Typical
command to add the route to reach the MS behind the GGSN is required,
eg. ip route add 10.0.0.0/8 dev gtp0.

The (horrible) ggsn parser has been manually extended to support the
new configuration option. That code doesn't look nice, but it just
mimics what we already have there for consistency, please don't blame
me for that.

If you want to run in debugging mode, I suggest you to use:

	sudo ggsn -c ggsn.conf -f -d

Note that you do have to run openggsn as root to bring up the gtp0
device. You have to see this message that announce that the GTP kernel
mode is enabled.

openggsn[1106]: ggsn.c: 656: Using the GTP kernel mode (genl ID is 25)

This patch also automagically sets up route to reach MS from Internet
just like tun mode does. This is fundamental to get this working,
better don't leave to the admin, he may forget to add this route.

In this patch, I tried to encapsulate this new feature as much as
possible as Harald initially suggested.

To compile this feature, you have to pass --enable-gtp-kernel, ie.

./configire --enable-gtp-kernel

Otherwise, the code to interact with the gtp kernel part is not compiled.

Signed-off-by: Andreas Schultz <aschultz@tpip.net>
2015-12-21 08:37:11 +01:00
Holger Hans Peter Freyther 89dcb614e8 Release 0.92 of the GGSN needed for the gtphub 2015-11-30 14:06:09 +01:00
Harald Welte ac0b4f17fe update version to 0.92 2015-11-20 10:34:17 +01:00
Andreas Schultz 10abfba949 convert literal APN name to protocol encoded version before use
The definition of the APN field format in GTPv1 is hidden in a chain
of documents.

3GPP TS 29.060 (the GTPv1-C specification) Section 7.7.30:

> The Access Point Name contains a logical name (see 3GPP TS 23.060 [4]).
> It is coded as in the value part defined in 3GPP TS 24.008

3GPP TS 24.008 Section 10.5.6.1:

> The value part is defined in 3GPP TS 23.003.

3GPP TS 23.003 Section 9.1:

> The APN consists of one or more labels. Each label is coded as a one
> octet length field followed by that number of octets coded as 8 bit
> ASCII characters

This converts a literal APN (e.g. Label1.Label2.Label3) to a structured
field (e.g. \006Label1\006Label2\006Label3)

Signed-off-by: Andreas Schultz <aschultz@tpip.net>
2015-11-13 17:16:03 +01:00
Holger Hans Peter Freyther a377b0874a Revert "Makefile.am: define ACLOCAL_AMFLAGS, include directory m4"
aclocal: couldn't open directory `m4': No such file or directory

This reverts commit 04cbae494d.
2015-11-07 20:47:26 +01:00
Alexander Huemer 04cbae494d Makefile.am: define ACLOCAL_AMFLAGS, include directory m4 2015-11-07 12:41:25 +01:00
Alexander Huemer db852a14fe fix some format specifiers 2015-11-07 12:40:48 +01:00
Alexander Huemer e740e81281 configure.in -> configure.ac 2015-11-07 12:39:32 +01:00
Neels Hofmeyr 2ea010a1ed gitignore: add 'compile' (from autoconf) 2015-11-02 14:27:53 +01:00
Neels Hofmeyr 041824dfc8 sgsnemu: improve an error message 2015-11-02 14:27:44 +01:00
Holger Hans Peter Freyther cd14094bb6 Dump dead code and never look at it again
This seems to be a wrong search. It seems to assume that there are
no buckets. Let's just remove it before looking at it too much.
2015-11-02 14:13:31 +01:00
Neels Hofmeyr 0dc4748447 add todo comments 2015-11-02 14:13:31 +01:00
Neels Hofmeyr 6c06d25667 make install: also install gtpie.h 2015-10-27 14:57:18 +01:00
Neels Hofmeyr e845cb9505 gtp.c: fix an error log.
Fix: the code handles fd1u but prints fd1c.
2015-10-12 14:23:54 +02:00
Neels Hofmeyr b18e811e24 gtp.h: rename gsn_t.dublicate to duplicate.
Fix spelling dublicate -> duplicate.

This is potentially breaking API compat, but currently, no users of
gsn_t.dublicate are known.
2015-10-12 14:10:27 +02:00
Neels Hofmeyr 9b09738891 gtp.c: improve 3 error logs.
It would print the memory location of the address buffer. Instead, print the
human readable host address and port.

The current code base supports only IPv4, and thread safety is apparently not
required, hence just use inet_ntoa(). (The IPv6 and thread capable version is 4
times longer and harder to read.)
2015-10-12 14:09:57 +02:00