Commit Graph

128 Commits

Author SHA1 Message Date
Pablo Neira Ayuso e01b17c8eb gtp-tunnel-add: fix incorrectly swapped sgsn and ms addresses 2014-02-01 01:16:08 +01:00
Pablo Neira Ayuso 6aaa76c62b gtp: check if the tunnel already exists
This patch checks if the tunnel already exists, in that case, if the
NLM_F_EXCL flag is set, we hit EEXIST.
2014-02-01 01:15:25 +01:00
Pablo Neira Ayuso 96a73cdcc5 gtp: set UDP header checksum to zero
UDP header checksum is optional. Let's set this to zero by now
so wireshark doesn't complain. Let's revisit this later.
2014-02-01 00:02:18 +01:00
Pablo Neira Ayuso 516a76f46c gtp: fix wrong endianess conversion in gtpv0 seq field
While at it, also set to 0xff the spare bytes as the specs indicates.
2014-01-31 23:44:56 +01:00
Pablo Neira Ayuso 40907844b9 gtp: this device is not an ethernet device
Remove all code that configures the special gtpX tunnel device as
an ethernet device, eg.

34: gtp0: <NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
    link/generic

This also removes the ethernet header from the packet that is
transmitted through the gtp device. So now wireshark shows a well-formed
GTP packet in the output path.
2014-01-31 23:31:48 +01:00
Pablo Neira Ayuso 21544dd479 gtp: fix gtpv0 and gtpv1 headers
Fix missing endianess conversions and missing GTP' flag set in v0.
2014-01-31 22:37:48 +01:00
Pablo Neira Ayuso a155b2f03a gtp: working xmit path of gtp0
It includes lots of pr_info messages, still in very early stage, but
it already transmit packets that look like GTP.

Set IFF_NOARP flag in device to disable ARP resolution in gtp0, the
actual device doing is the real one behind it.

This patch also move code to gtp*_push_header headers.
2014-01-24 00:39:38 +01:00
Pablo Neira Ayuso 1350e5f734 gtp: fix missing family in pdp context
Add also some instrumentation, I'll remove it later on.
2014-01-24 00:33:26 +01:00
Pablo Neira Ayuso 2ccd6261d9 gtp-tunnel-add: allow to specific ms and sgsn address
Moreover, display output in gtp-tunnel-get.
2014-01-22 22:51:34 +01:00
Pablo Neira Ayuso 4eec5f0f7d gtp: destroy sockets if there have been initialized
Fixes a crash if you remove the gtp module and no configuration was
enabled.
2014-01-22 21:46:07 +01:00
Pablo Neira Ayuso 3522ef80c5 gtp: fix refcounting issues
We don't need the hackish dev_hold in the dellink path anymore.
2014-01-22 21:45:18 +01:00
Pablo Neira Ayuso 317fe2ccc0 gtp: destroy UDP sockets on module removal
Otherwise we hit "Address already in used" when reloading this module
and the socket remains there in a "crashable" state.
2014-01-22 21:27:26 +01:00
Pablo Neira Ayuso c156be41fd gtp: add GTP_CMD_CFG_* commands
This patch detaches the hashtable and the UDP setup from the
GTP_CMD_TUNNEL_* command. The gtp kernel modules needs to support
UDP socket reconfiguration.

After this patch, the steps to bring up a tunnel are:

1st) bring up the device gtp0 via rtnetlink using the "gtp" link type.
2nd) attach a configuration to the gtp0 device, it includes the
     initialization of the hashes and the UDP socket, via genetlink
     "gtp" family using the GTP_CMD_CFG_NEW command.
3rd) add/delete tunnels using genetlink "gtp" family and GTP_CMD_TUNNEL_*
     commands.

Still unusable, but the netlink interface looks in better shape.
2014-01-22 21:02:37 +01:00
Pablo Neira Ayuso fea67e726e gtp-tunnel-get: remove debugging information 2014-01-21 19:01:58 +01:00
Pablo Neira Ayuso 034da83bd8 gtp: fix several interfaces 2014-01-21 18:59:04 +01:00
Pablo Neira Ayuso ca33914a12 gtp-tunnel-add: create one tunnel
And allow to specify the tunnel ID for tests.
2014-01-21 18:56:36 +01:00
Pablo Neira Ayuso 1c44eab539 gtp: tid is u64 and set other fields in pdp context 2014-01-21 18:38:50 +01:00
Pablo Neira Ayuso e4f11ebf67 gtp: stop iteration when all pdp ctx has been dumped
otherwise it loops forever.
2014-01-21 18:21:17 +01:00
Pablo Neira Ayuso 3fb29d4ab7 gtp-tunnel-add: fix crash if no arguments are passed 2014-01-21 18:09:38 +01:00
Pablo Neira Ayuso e24258f4b1 genl: ix crash due to missing wrong prototype
In function genl_socket_talk().
2014-01-21 18:09:17 +01:00
Pablo Neira Ayuso acbbbc3e5a add gtp-tunnel-get
This allows listing the existing tunnels.
2014-01-21 18:08:23 +01:00
Pablo Neira Ayuso fa4c10f4d7 genl: introduce genl_nlmsg_build_hdr and use it
Add new generic function to build the netlink and genetlink headers.
2014-01-21 17:42:08 +01:00
Pablo Neira Ayuso 49ed1fb379 gtp: missing cb->args annotation in dump loop
Annotate the last gtp instance that has been visited.
2014-01-21 17:24:08 +01:00
Pablo Neira Ayuso ccf3095e6e gtp: add dump operation
I also added the skeleton of the get operation.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2014-01-21 15:14:17 +01:00
Pablo Neira Ayuso 85dfd1ab09 call if_nametoindex out of the loop
This uses a rtnetlink socket to look up for the interface index.
This should speed up tunnel creation.
2014-01-21 14:23:30 +01:00
Pablo Neira Ayuso b0ff3b67ef provide simple genl library
So we can get rid of genl-family-get.c to look up for the genetlink
family ID.
2014-01-21 14:21:58 +01:00
Pablo Neira Ayuso d539883390 Add missing Makefile 2014-01-20 13:43:54 +01:00
Pablo Neira Ayuso 24782b2aa7 initial import
Type `make' to compile kernel and userspace code. After that, you should
see gtp.ko kernel module that you can insmod.

The rudimentary userspace tools are:

* gtp-link-add, that allows you to bring up the gtp0 device (via
rtnetlink).

* gtp-tunnel-add, to create tunnels via genetlink.

This is also using using genl-family-get to obtain the (dynamic) genetlink
family for the gtp operations, but that code is scheduled to be merged to
gtp-tunnel-add.

The tunneling code does not work yet, it triggers a crash, so it's been
temporarily disabled.

Original work from Harald Welte, I added the netlink interfaces and got
this compiling.
2014-01-20 13:42:39 +01:00