aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/gtphub
AgeCommit message (Collapse)AuthorFilesLines
2016-10-13gtphub_test.c: remove unused include of msgb.hNeels Hofmeyr1-1/+0
Change-Id: I7a8003a0e0bff803941d7981ffc07cf78c3ae9a9
2016-09-15Build fixesAlexander Huemer1-1/+3
Some fixes for build environments where dependencies are installed in distinct directories. Change-Id: I38808fd2911747b266ee6fde91187a88dd7ae355
2016-09-15Consistenly format variables in */Makefile.am filesAlexander Huemer1-8/+24
Change-Id: Ifa21513c007072314097b7bec188579972dc1694
2016-04-29use new libosmocore gsm_23_003.h for IMEI/IMSI lengthHarald Welte1-1/+1
... rather than our private definitions everwhere. As an added benefit, gprs_gsup_messages.h is now free of any header dependencies within openbsc.
2015-12-07gtphub: improve handling of restarted peer.Neels Hofmeyr2-9/+48
Handle peer restart earlier, so that all the tunnels are deleted by the restart code path, instead of the first one being deleted due to reused TEI. That caused confusing logging messages. Also, when receiving Delete confirmations from the peer that didn't restart, don't complain about unknown peer, but acknowledge and remove the half invalidated tunnel. This means that the pending delete entry from the restart code path is not needed / not used, so don't bother to add pending delete entries upon peer restart. The test test_peer_restarted_reusing_tei() hits the situation where a tunnel is removed because of a reused TEI rather than the restart counter. Adjust the test to expect the "out-of-band" delete request earlier on, and to still see the half invalidated tunnel around. Enhance the test by adding the delete response from the peer that didn't restart, and add a final tunnels_are() verification. Sponsored-by: On-Waves ehi
2015-12-07gtphub: simplify/fix: one TEI mapping per tunnel.Neels Hofmeyr1-79/+102
Because the sender is known, one unique TEI per tunnel suffices to map the TEIs that the peers are sending to gtphub, instead of previously 4 (SGSN<->GGSN interaction on User and Ctrl plane, where each had an own unique TEI). Also, previously, a tunnel's endpoints should also have been checked against each other for TEI reuse, not only against the endpoints of other tunnels. This simplification fixes that problem for free. Thus simplify TEI reuse detection and improve VTY show readability and debugging. Adjust log and VTY output for tunnels. Adjust tests accordingly. Suggested-by: Holger Hans Peter Freyther <holger@moiji-mobile.com> Sponsored-by: On-Waves ehi
2015-12-07gtphub_test: add test_parallel_context_creation()Neels Hofmeyr2-0/+161
Sponsored-by: On-Waves ehi
2015-12-07gtphub: tweak logging.Neels Hofmeyr1-32/+32
Less spaces in tunnel strings, adjust tests accordingly. Use side_idx to remove code dup in rate counter output. Sponsored-by: On-Waves ehi
2015-12-03gtphub: add test for SGSN behind NATNeels Hofmeyr2-0/+105
2015-12-03gtphub_test: tweak test_user_data(): no seq routing.Neels Hofmeyr1-4/+4
Don't route User message back by sequence number, rather test that a completely unrelated User message is routed back properly. Sponsored-by: On-Waves ehi
2015-12-03gtphub: fix restart cleanup peer matching.Neels Hofmeyr2-3/+6
Adjust test expectations accordingly. Sponsored-by: On-Waves ehi
2015-12-03gtphub: wrap gtphub_write() for test suite.Neels Hofmeyr2-1/+20
Sponsored-by: On-Waves ehi
2015-12-03gtphub: add restart counter testNeels Hofmeyr2-0/+165
Sponsored-by: On-Waves ehi
2015-12-03gtphub: add test for reused TEI.Neels Hofmeyr2-0/+78
Sponsored-by: On-Waves ehi
2015-12-03gtphub_test: add test for Del PDP from GGSN side.Neels Hofmeyr2-6/+58
Sponsored-by: On-Waves ehi
2015-12-03gtphub_test: add some cleanup asserts.Neels Hofmeyr1-0/+5
Sponsored-by: On-Waves ehi
2015-12-03gtphub: handle Delete PDP Context.Neels Hofmeyr2-4/+74
During resolution of the header TEI, also return the tunnel struct that resolved the TEI, so the Delete PDP Ctx code does not need to look it up again. Upon Delete PDP Ctx Request, remember the IEs and that a request was made. Upon Delete PDP Ctx Response, find the pending delete and remove the corresponding tunnel, iff the response indicates success. Add a context deletion to regression tests, rename the test appropriately. Sponsored-by: On-Waves ehi
2015-12-03gtphub: refactor: use side_idx everywhere.Neels Hofmeyr1-36/+36
This is a mostly cosmetic change. Instead of separate buffer handling functions, reduce some code duplication by using a side_idx just like the plane_idx, with arrays. Sponsored-by: On-Waves ehi
2015-12-03gtphub: use a single TEI pool across planes.Neels Hofmeyr1-14/+14
There's no need to keep two separate number pools when both can be fed from the same pool. User and Ctrl plane TEIs can technically overlap without colliding, but it doesn't hurt if they don't overlap, either. Sponsored-by: On-Waves ehi
2015-12-03gtphub: implement restart counter properly.Neels Hofmeyr1-4/+4
Force passing a restart counter, by adding such arg to gtphub_start() (test suite is not affected by this). In gtphub_main.c, add -r,--restart-file <path> and next_restart_count() to maintain the counter file. While at it, tweak the cmdline help to unify the formatting (mostly commas and a missing line break). Send gtphub's own restart counter. So far, the sender's restart counter was copied through, which would break as soon as more than one GSN would talk to the same peer with differing restart counters. Also fix the in-mem restart counter data type (one octet, not two). Sponsored-by: On-Waves ehi
2015-12-03gtphub: track tunnels explicitly.Neels Hofmeyr1-10/+63
So far, gtphub worked perfectly by only tracking single TEIs ... for probably most uses. But a Ctrl plane tunnel may have expired despite a still active corresponding User plane tunnel. The User plane would continue to work indefinitely, but if any Ctrl messages followed after more than six hours of Ctrl silence, they would have been dropped due to an expired TEI mapping. We want to - combine expiry of a user TEI with its ctrl TEI. (done in this patch) - upon delete PDP context, remove both user and ctrl TEI mappings. (future) - when a peer indicates a restart counter bump, invalidate its tunnels. (future) To facilitate these, track tunnels, complete with both SGSN's and GGSN's address, original and replaced TEIs, all for both user and ctrl plane, in a single struct. A single expiry entry handles the entire tunnel, instead of previously four separate expiries for each endpoint identifier. Add the concept of a "side", being either GGSN or SGSN, to index tunnel endpoint structs, and so on. Track the originating side in the gtp_packet_desc. Add header_tei_rx: set_tei() overwrites header_tei, but the originally received header TEI is still needed to match a Create PDP Context Response up with its Request (and for logging). Adjust the test suite to expect tunnel listing strings instead of TEI mappings, with a bonus of making it a lot easier to grok, and including the IP addresses. Add regression test for refreshing tunnel expiry upon use. Note: the current implementation is as slow as can possibly be, iterating all the tunnels all the time. Optimizations are kept for a future commit, on purpose. BTW, the sequence number mapping/unmapping structures remain unchanged. Sponsored-by: On-Waves ehi
2015-12-03gtphub: add explicit cleanup handles.Neels Hofmeyr1-6/+21
Clean up functionality is added for the test suite only, to be able to clean out all allocations and test against memory leaks. So far, it was sufficient to expire everything to free a gtphub. In preparation for the upcoming rate counters, which will need to be freed explicitly, add gtphub functions to clean up everything. As added bonus, also close the sockets explicitly -- not really needed upon program exit, neither by the test suite, but *if* we have a cleanup function, it should clean up everything properly. Closing the sockets is however kept separate, for the test suite. gtphub_start() and gtphub_stop() are for normal use (published in gtphub.h), and gtphub_init() and gtphub_free() are for the test suite, without sockets. (gtphub_stop() will probably never be called by anyone, but its existence completes the picture.) In gtphub_test.c, have a function to clean up the testing gtphub struct. First, expire everything by timeout, assert emptiness, then call the cleanup function. Call from each test in the end. Sponsored-by: On-Waves ehi
2015-12-03gtphub: nr_map: add min,max and wrap.Neels Hofmeyr1-2/+47
Implement min/max bounds for nr_pool, adjust nr_pool_init() and current tests, and create unit tests for nr_map wrapping. Sequence numbers range from 0 to 65535, while TEIs range from 1 to 0xffffffff. Both cause problems when the nr_pool surpasses the range: seq exit their valid range, causing unmappings to fail, and a TEI would be mapped as zero (invalid). Add a comment about TEI wrapping, and lose the comment about random TEIs (not really important). Sponsored-by: On-Waves ehi
2015-12-03gtphub: fix number map range for TEIs.Neels Hofmeyr1-3/+3
Use unsigned int for nr_map, just large enough to fit the TEI space. Adjust log output formats and casts accordingly. Fixes: TEIs are uint32_t, but the nr_map so far used int. This would cause TEIs from 0x80000000 on to be handled and printed as a negative value. Sponsored-by: On-Waves ehi
2015-11-29gtphub_test: build only when c-ares and gtp are present.Neels Hofmeyr1-0/+4
2015-11-20gtphub: fix echo reply to SGSNs: wrong fd. Add test.Neels Hofmeyr1-15/+61
The actual fix is just one character, but also add a regression test against this, on both CTRL and USER plane.
2015-11-18fix build: remove obsolete gtphub EXTRA_DIST.Neels Hofmeyr1-4/+1
Sponsored-by: On-Waves ehi
2015-11-16gtphub: cosmetic: break long lines.Neels Hofmeyr1-58/+76
Fit most of the code in 80 chars width. Some instances still leak past 80 characters because of long function names, inline comments or the like, "the exception proves the rule." Sponsored-by: On-Waves ehi
2015-11-16gtphub: fix User plane decoding, add unit test.Neels Hofmeyr2-8/+119
Split decoding return code GTP_RC_PDU in GTP_RC_PDU_C and GTP_RC_PDU_U. Don't do IEs in GTP_RC_PDU_U. Add a unit test for User plane data, expected to fail (nonstandard port case). In gtphub_test.c, tweak logging so that it is easily visible which test produced which output. Also add the global resolved_sgsn_addr and ggsn_sender, symmetrically to resolved_ggsn_add and sgsn_sender. Sponsored-by: On-Waves ehi
2015-11-16gtphub: make test code reusable for future tests.Neels Hofmeyr1-177/+242
Generalize to make the PDP ctx message definitions and "sending" of messages from SGSN->gtphub->GGSN and back reusable in future tests. Publish gsn_addr_from_sockaddr() in gtphub.h for use in gtphub_test.c. Use an osmo_sockaddr for resolved_ggsn_addr, because one is needed for comparison in probably every future test. Add LVL2_ASSERT() to print assertion message and return instead of abort, so that functions can be called from several tests without losing the info of which test caused it from which line. Use globals for struct gtphub and time_t now, to reduce nr of args that need to be passed around when writing tests. Add a default test setup function. Sponsored-by: On-Waves ehi
2015-11-16gtphub: fix Echo behavior: respond directly.Neels Hofmeyr2-67/+62
Up to now I used the Echo as a test for sequence nr mappings. But Echos should be handled differently: they are scoped on the link and an Echo response should be sent right back to the requester. Sponsored-by: On-Waves ehi
2015-11-16gtphub: add first bits of GRX aresNeels Hofmeyr3-35/+105
For the resolving function, change the function signature to return a gtphub_peer_port. In consequence, publish two functions concerned with gtphub_peer_port instances for use in test and gtphub_ext.c. Add GGSN resolution queue, callback and cache. Simple implementation: if an SGSN asks for a GGSN, it will first get no answer, and I hope it will ask again once the GGSN is in the cache. Within gtphub_ext.c, have a dummy sgsn struct, as the sgsn_ares code currently depends on it (half the functions pass an sgsn instance pointer around, but the other half use the global one). In the unit tests, wrap away the ares initialization so that they can work without a DNS server around. The netcat test breaks because of this, will remove it. Using sgsn_ares, implement the gtphub_resolve_ggsn_addr() function, I hope: untested. Minor cosmetics just to see if you're paying attention... ;) Sponsored-by: On-Waves ehi
2015-11-16Add GTP hub initial code base.Neels Hofmeyr3-0/+732
First steps towards a new GTP hub. The aim is to mux GTP connections, so that multiple SGSN <--> GGSN links can pass through a single point. Background: allow having more than one SGSN, possibly in various remote locations. The recent addition of OAP to GSUP is related to the same background idea. (This is a collapsed patch of various changes that do not make sense to review in chronological order anymore, since a lot of it has thorougly transmorphed after it was first committed.) Sponsored-by: On-Waves ehf