aboutsummaryrefslogtreecommitdiffstats
path: root/ggsn
AgeCommit message (Collapse)AuthorFilesLines
2017-12-14ggsn: Add 'ipv6 link-local' vty cmdPau Espin Pedrol3-1/+37
This vty cmd let's you set up a new link-local IP for a specific APN to be used during ICMPv6 Router Advertisement procedure. osmo-ggsn hence requires a link-local IPv6 address to be added to the tun interface, otherwise the apn will not be configured correctly and it won't be able to allocate addresses from the ipv6 pool later on. This feature is useful in case your OS doesn't support autoconfiguring link-local IPs when the interface is brought up (some linux versions are known to fail at this) or in case you configured your OS specifically to avoid automatic set up (sysctl net.ipv6.conf.*.autoconf). If "no ipv6 link-local" is provided (default), osmo-ggsn will rely on the OS or the ipup-script setting up the link-local IP for the tun interface at creation time, then fetching it after ipup-script time and using the first link-local ip found. On the other hand, if the "ipv6 link-local" cmd is provided, osmo-ggsn will add the link-local IP to the interface manually and use that one for later Router Advertisement procedures. Change-Id: I09ef27f54940d4c47150e5f9016d1cd4298c16b5
2017-12-14ggsn.c: Improve logging info on link-local ipv6 addr not foundPau Espin Pedrol1-3/+5
Change-Id: I18fb952514712ff30d18c7626f84309055d3efa1
2017-12-11Add support for IPv4v6 End User AddressesPau Espin Pedrol2-43/+59
Before this commit, when an MS requested an ipv4v6 context osmo-ggsn returned an error stating the type was unknown, and this text was printed in the log: Processing create PDP context request for APN 'ims' Cannot decode EUA from MS/SGSN: f1 8d This patch has been tested with an MS running the 3 types of addresses: - IPv4 and IPv6: no regressions observed, the context is activated and packets are sent to the ggsn. - IPv4v6: Wireshark correctly parses request and reponse, and then ICMPv6 traffic from both sides. Finally I see the MS using the IPv4 and IPv6 DNS addresses advertised and TCP traffic over IPv4 (because probably my IPv6 network setup is not correct). I also checked I can disable/enable data (pdp ctx delete and activate) several times without any issue. Change-Id: Ic820759167fd3bdf329cb11d4b942e903fe50af5
2017-12-05ggsn: Ignore PCO with length 0, don't abort processingHarald Welte1-2/+0
The existing code would abort iterating over the list of PCO TLVs if a TLV of length zero was encountered. However, there's nothing in the spec that would make a zero-length PCO invalid, so we should continue to iterate over any PCO TLVs after the zero-length one. This issue was discovered while writing test cases in osmo-ttcn3-hacks.git Change-Id: I36660566a8ee2ca80ae6ee99c86e167e7c208df2
2017-12-05ggsn.c: Fix byte order of IPCP IPv4 DNS serversHarald Welte1-2/+2
... this probably didn't show up as 8.8.8.8 is dual-endian. doh! The address was already in network byte order, but msgb_put_u32 "of course" expects host byte order, ending up the wrong way in the actual packets :/ Change-Id: Ia4bcac5fcebfc24760432eb66be258a01d78f65f Closes: OS#2685
2017-12-05Log APN and tun names for packetsMax1-3/+4
Change-Id: I6f7ce33f6585b2b78e2b8a5c0f7111f0316d6ddd
2017-12-04ggsn.c: Print version of unhandled ip packetPau Espin Pedrol1-1/+1
Change-Id: I7e226a12b074c96c572f90e3aaf62716d0cd47c5
2017-11-16ggsn_vty: Stop using deprecated API vty_install_defaultPau Espin Pedrol1-2/+1
Changes made as requested by the deprecation text. Fixes warning below: warning: ‘vty_install_default’ is deprecated: Now happens implicitly with install_node() [-Wdeprecat ed-declarations] vty_install_default(GGSN_NODE); ^~~~~~~~~~~~~~~~~~~ Change-Id: I5c6197129e0c251a4e8dd174027b011c8f6476c6
2017-11-14gtp-kernel: Add device nime in pdp_debug() log statementsHarald Welte1-4/+5
Change-Id: Iad0e7a9fa48fcddc31b8d555244581efdbd61b4e
2017-11-14gtp-kernel: Add function name to pdp_debug() function callsHarald Welte1-4/+4
This allows us to distinguish "add" from "del" operatons in the log Change-Id: Ibe2e76a6eecc7b5fa5f44ab2c1578597138e30b9
2017-11-14gtp-kernel: Get rid of SYS_ERR where not applicableHarald Welte1-14/+8
SYS_ERR is for logging an error from the (operating) system including the errno value. For general logging, we have DEBUGP/LOGP. Let's convert the gtp-kernel logging over. This also fixes the related line ending mess-up as SYS_ERR adds a LF while LOGP/DEBUGP don't. Change-Id: Idb4069a28227b770e20d62bf306cd294f47146ae
2017-11-14gtp-kernel: proper cleanup in error pathHarald Welte1-0/+2
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-14gtp-kernel: Make sure repeated calls to gtp_kernel_init() are safeHarald Welte1-15/+25
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-14gtp-kernel: Avoid global state variableHarald Welte2-23/+0
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-14gtp-kernel: Align logging for APN start in kernel-gtp case with that of TUNHarald Welte1-1/+1
Change-Id: Ie53d37f151e8b6448636a8cde5777b3841989d05
2017-11-14gtp-kernel: shut down kernel GTP device in apn_down()Harald Welte1-0/+1
When we take the APN down, we should also take the GTP device down. Change-Id: Idd250dd454a1603834d388884a24a63e044fdd7b
2017-11-14gtp-kernel: Get rid of hard-coded kernel GTP device nameHarald Welte3-27/+25
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-13gtp-kernel: Re-add support for kernel GTP-U accelerationHarald Welte1-5/+9
When we branched off osmo-ggsn from the old openggsn code base, the support for kernel-gtp got temporarily removed. This patch re-introduces support for handling the GTP-U plane in the Linux kernel by means of libgtpnl + the kernel GTP-U driver. This only works for IPv4 at the moment, until the kernel GTP-U code gains IPv6 support. Kernel GTP currently also is restricted to a single APN per GSN. Change-Id: Ieb1bc1bd0d51d41947f0abd6ebbc2e5d102592d6
2017-11-13gtp_kernel: Change gtp_kernel_init() function signatureHarald Welte2-7/+16
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-13Properly NULL-out blacklist in alloc_ippool_blacklist()Harald Welte1-4/+8
This ensures that in case of error, any caller can still safely call talloc_free() on the blacklist pointerm as free on NULL is well-defined. With the code prior to this patch we fear a double-free. Change-Id: Idc511cb3f0dfb922920aba8f88ea77df1722ecdc
2017-11-13remove unused argument to alloc_ippool_blacklist()Harald Welte1-3/+3
Change-Id: I4d3ea077ba46446e537ec9a6de6f4080fcaa428c
2017-11-06sgsnemu: Don't leak FILE handle in proc_read()Harald Welte1-34/+10
Change-Id: Ie22e6a9bc172427e867e7a4001b6c710477a232b Fixes: Coverity CID#178660
2017-10-17ippool: Implement and use blacklist instead of blindly using IPPOOL_NOGATEWAYPau Espin Pedrol1-2/+52
Commit dda21ed7d4a897c9284c69175d0da598598eae40 modified previous calls to ippool_new() removing the pass of flags to avoid allocating certain problematic IPs from the pool to MS, such as the network, gateway and broadcast IPs. Today I did some unsucessful tests with osmo-ggsn with a pool "ip prefix dynamic 176.16.222.0/24", and thus IP 176.16.222.0 was being assigned to the MS. De-capsulated DNS packets were received in the tun interface, but the Linux system in there was unable to correctly forward the packets to the gateway interface connected to the Internet. However, adding a second MS which got 176.16.222.1 had its packets forwarded correctly. However, previous implementation relies on flag IPPOOL_NOGATEWAY flag to blindly blacklist first IP after the network ip (ie, .0 and .1 are removed), which limits the IP reserved for the tun device to be .1. If a different IP in the range is assigned, it may cause issues. As a result, a blacklist is introduced in this commit to dynamically fetch the tun IP address and exlucde it from the pool of available IPs. Change-Id: I8e91f7280d60490c858a769dd578c1c8e54e9243
2017-10-16tun: Convert tun_ipv6_linklocal_get to be more genericPau Espin Pedrol1-1/+3
Add support for IPv4 and IPv6 global IPs. Also return the prefix length of the IP address by using a in46_prefix. Change-Id: I277af191dc611b6bbcb83479f4ae338083740322
2017-10-14ggsn: Avoid crash on wrong EUA typeHarald Welte1-0/+28
If the EUA in the Create PDP Context Request was not supported by the given APN (e.g. IPv6 request for a v4-only APN), we crashed. Avoid this and add proper handling of this error case. Change-Id: I8d1f7ec727c5d2d4427232015f81ed57d3440dff
2017-10-13Remove trailing whitespacePau Espin Pedrol1-3/+3
Change-Id: I8e24f95a88bef3a59006a89c219871e6156963d7
2017-10-11create_context_ind(): Fix crash on apn not foundPau Espin Pedrol1-2/+2
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: dd266066c7cc96c797034da352cc9d72177c5780, b16c46b4c36383368eb1581e40d0a8ca751ddc53 Change-Id: Ie4ec74e87aaf1d067dd1717d986673be56c4d6ed
2017-10-01create_context_ind(): ignore a non-started default APNHarald Welte1-0/+5
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-01apn_start(): Extend error message when setting IPv6 address failsHarald Welte1-1/+2
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-01apn_stop(): Print tun device name when closing tun deviceHarald Welte1-1/+1
Change-Id: If981cc0696122cb69c01ceac6f54ae01bcbf4a2d
2017-10-01create_context_ind(): ignore any non-started APNsHarald Welte1-0/+3
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-01apn_start(): fix clean-up after errors bringing up APNHarald Welte1-3/+0
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-09-25Move extended PDP logging macro to headerMax1-2/+1
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-24ggsn: Add per-APN VTY configuration option on G-PDU sequence numbersHarald Welte3-0/+31
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-24ggsn: Fix double whitespace in writing "ifconfig" linesHarald Welte1-2/+2
This is merely a cosmetic issue, no functional change. Change-Id: I8663ee633524eedeed5ddd45ddb65a06825052ac
2017-09-24ggsn: Fix config file writing of IPv6 DNS settingsHarald Welte1-1/+1
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-24ICMPv6: Send router advertisement from own link-local addressHarald Welte4-10/+25
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-06ggsn: Add ability to specify local IP addresses for GTP-C and GTP-UHarald Welte3-4/+50
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-06Rename OpenGGSN to OsmoGGSNHarald Welte3-10/+10
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-06ggsn: Handle SIGTERM like SIGINT and terminateHarald Welte1-1/+3
Change-Id: I0c8773bd6ef41332b91b5b025aef9ef129af8289
2017-09-06Introduce a VTY, factually turning OpenGGSN into an Osmocom programHarald Welte7-1958/+1562
Change-Id: I9613ca3436e77ea132c47f0096df7c5050d7e826
2017-09-05libgtp: Remove ctrl_handle from gsn_t, replace with private contextHarald Welte1-3/+3
The control interface handle never belonged into libgtp in the first place. Commit 727417dd28813c697b4820aef9f54f249e30c4b8 should not have added this to the shared library (used by sgsnemu, osmo-sgsn, ...), but to some private state of the GGSN. Introducing a private context pointer at the same location will keep ABI compatibilty. Change-Id: I4f17516dae3e04114564828a3e5f6e2ea54212a5
2017-09-05lib/ippool: Move ippool_aton() out of ippool_new()Harald Welte1-10/+11
we rather pass the in46_prefix directly into ippool_new() Change-Id: Iadf6274e881a9bfc75eb41f9380f5ae2d8c92a0f
2017-09-05gtp-kernel: Remove dependency to cmdline.[ch]Harald Welte3-21/+14
Change-Id: I760f25df609c309eba4d5716f3e23b49320449bf
2017-08-30ggsn: Fix DNS not sent in PDP context responsePau Espin Pedrol1-2/+2
During IPv6 support implementation, helper function pco_contains_proto was added which contains an error: It is only capable of finding first protocol correctly, and as a consequence, in my setup DNS servers where not sent back to the SGSN/MS, resulting in phone being able to connect to IPs but not to domain names which required DNS resolution. The condition in the while loop is also changed to match the increment of the variable inside the loop to make it easier to understand at first glance. Fixes: 1ae98777d9b1ee62e6900caf4bb580d1a42bb416 Change-Id: Icc2e6716c33d78d3c3e000f529806228d8aa155e
2017-08-12Properly format IMSI before using it in trapHarald Welte1-1/+1
For some reason Max' commits introducing the CTRL/trap interface about one year ago didn't convert the IMSI to its actual textual representation before usign it in the CTRL interface. Let's clean that up by properly interpreting the IMSI. Change-Id: I8b20d2e47a29de266d93a7ddd5e6877f7e346a63
2017-08-11Support setting TUN device IPv6 address + prefixHarald Welte1-8/+8
As we can now have PDP contexts with IPv6 user IP payload, it is useful to extend the TUN related code to be able to configure the tun device IPv6 address + prefix length Change-Id: I899d21e52d02e0b8384af29ddd489ff19c8f2cf6
2017-08-11IPv6: Support PCO for IPv6 DNS addressesHarald Welte1-41/+136
In IPv6, DNS server information is not passed along as IPCP6 like in IPv5 with IPCP. The reason is that IPCP6 (for PPP) doesn't support passing DNS server information. Rather, the relevant RFCs indicate DHCPv6 should be used even over point-to-point links. 3GPP decided to avoid DHCPv6 dependency for stateless autoconfiguration (the only mandatory IPv6 configuration mechanism) and added some new non-PPP-style PCO information elements ("containers") which can among other things inform a MS about IPV6 DNS servers. That same mechanism can also be used to inform the MS about IPv4 DNS servers, so for IPv4 there are now two competing mechanisms: IPCP and the new "native" PCO container. With this patch, we support both for IPv4. Change-Id: I21499afd61def8c925f7838bde76f34d28214b56
2017-08-11IPv6: Implement IPv6 prefix assignment via ICMPv6 router advertisementHarald Welte6-2/+504
The 3GPP specs are quite strange when it comes to how an IPv6 address or rather prefix is assigned to an IPv6 PDP context. The designated method for allocating the IPv6 address via the PDP EUA (End User Address) Information Element in the GTP signalling plane is *not* used to allocate the address/prefix. Instead, the EUA is used to allocate an "interface identifier" to the MS, which it the uses to derive its link-local source address to send a router solicitation. The GGSN subsequently answers witha router advertisement, advertising a single/64 prefix, whihcthe MS then uses to generate it's real IPv6 source address for subsequent communication. Change-Id: Icddf7d30e01d76a4784bcef5787b36f52f703a9f
2017-08-09ippool: Extend pool to work with /64 prefixesHarald Welte1-1/+5
In IPv6 GPRS, we actually don't want to allocate an individual v6 address (like in IPv4), but we want to allocate a prefix. The standard prefix lengh is 8 bytes, i.e. a /64 prefix. This patch extends the pool to be able to work with such v6 prefixes. Change-Id: I0cf700b6baf195a2e5fbea000531f801acaaa443