Commit Graph

13 Commits

Author SHA1 Message Date
Harald Welte 318795635e gtp-kernel: proper cleanup in error path
When genl_socket_open() succeeds but genl_lookup_family() fails,
we have to clean up the socket that we just opened.

This requires a new version of libgtpnl :/

Change-Id: I31df046530347f88cb7b16c37a899b456ed1b080
2017-11-14 00:08:51 +09:00
Harald Welte 22e1573831 gtp-kernel: Make sure repeated calls to gtp_kernel_init() are safe
We have to factor out the "run once" code and make sure to really
only run that once, while the per-device code remains in the
gtp_kernel_init() function.

Change-Id: Iba5bd71e4b725eef59fe4f233fbb965e396a06c3
2017-11-14 00:08:51 +09:00
Harald Welte c85e89961a gtp-kernel: Avoid global state variable
Whether or not GTP kernel support is enabled is the property of a
given APN, and not a global state variable.

Change-Id: Iff3bd8a52bd6c20f9811ee41ff700486d08591f3
2017-11-14 00:08:51 +09:00
Harald Welte 698a2339eb gtp-kernel: Get rid of hard-coded kernel GTP device name
The existing kernel GTP support code inherited from OpenGGSN was overly
simplistic and didn't support multiple GTP devices or user-defined GTP
device names.  Let's remove that restriction in this patch

Change-Id: I51df223788fd5b7cf8099463b8aa0ca4a4fd1c96
2017-11-14 00:08:48 +09:00
Harald Welte e3c5918aee gtp_kernel: Change gtp_kernel_init() function signature
Rather than taking an explicit in_addr, prefix_length and a
string-formatted prefix, let's pass in an in46_prefix and derive
the other representations from it.

Also, don't refer to a no-longer-existing global 'ipup' variable but
add it as a function argument.

Change-Id: Ife87142c86589b4fa4062d62afe3670467548589
2017-11-13 23:57:58 +09:00
Harald Welte 51127ea962 sgsnemu: Don't leak FILE handle in proc_read()
Change-Id: Ie22e6a9bc172427e867e7a4001b6c710477a232b
Fixes: Coverity CID#178660
2017-11-06 02:42:59 +09:00
Harald Welte 8ffd7fc782 gtp-kernel: Remove dependency to cmdline.[ch]
Change-Id: I760f25df609c309eba4d5716f3e23b49320449bf
2017-09-05 22:42:17 +02:00
Harald Welte d12eab9c4e ippool: Add IPv6 support to IP pool implementation
Extend the IP pool implementation to be able to manage both pools
of 32bit addresses (IPv4) as well as pools of 128bit addresses (IPv6)

Change-Id: Ib98cc4bf634d6be9a7bf8c03a24e629455fcafc8
2017-08-09 22:08:57 +02: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
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
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