aboutsummaryrefslogtreecommitdiffstats log msg author committer range
path: root/src/rate_ctr.c
AgeCommit message (Collapse)AuthorFilesLines
2020-07-17rate_ctr: Add functions to reset rate counter (groups)Daniel Willmann1-0/+21
Change-Id: If2f806d044cd0fb6929dac44ef8f8a15941ffe9b Related: SYS#4877
2019-05-10Revert "Print error message if application fails to call rate_ctr_init()"Harald Welte1-5/+2
This reverts commit 9685a48c7bc83b1f5ee9b51e29419164b387ade2 which has caused massive fall-out among (particularly) unit tests in osmo-{msc,bts,pcu}. Change-Id: Iede72e86451d94cf678045992cb71f6b1bf16896
2019-05-10Print error message if application fails to call rate_ctr_init()Harald Welte1-2/+5
Change-Id: Ie8093b66b7e27cf863d2558fe21b2c6e0f3fcdfd Closes: OS#3580
2019-03-27src/rate_ctr.c: drop some incorrect \ref referencesVadim Yanitskiy1-3/+3
rate_ctr.c:411: warning: unable to resolve reference to handle_group' for \ref command rate_ctr.c:208: warning: unable to resolve reference to talloc' for \ref command Change-Id: I24a80ff6cf11ce0455529515d1ecb9900f0271a8
2019-03-27Doxygen: fix documentation of rate_ctr_for_each_counter()Vadim Yanitskiy1-1/+1
Doxygen was confused by duplicated documentation for both definition and declaration of rate_ctr_for_each_counter(). Moreover, both variants contained some mistakes. Let's avoid this duplication and keep the only (corrected) one. Change-Id: Icca2d4a95bd5f96ae85a86909ec90fb8677cacf3
2019-03-19rate_ctr_group_free(): guard against empty or NULL inputMax1-1/+5
Change-Id: I859a91ee4400b3685c05971f8c66bceca6758724
2018-07-21rate_ctr: Improve loggingPau Espin Pedrol1-15/+20
Previous logic regarding logging of verification and mangling of rate_ctr groups made it difficult to debug when an issue occurrs. Change-Id: I992d165cab5ee6ca9b5b7e4a2210a0951954bd34
2018-04-16cosmetic: log: fix typo, clarify msg for rate_ctr name manglingNeels Hofmeyr1-2/+3
Change-Id: I9a04d501698f8a3360ef9dcbf04b57c5ac10e63b
2017-12-20rate_ctr: fix osmo-sgsn DoS: don't return NULL on already used indexNeels Hofmeyr1-3/+26
Recent patch I563764af1d28043e909234ebb048239125ce6ecd introduced returning NULL from rate_ctr_group_alloc() when the index passed already exists. Instead of returning NULL, find an unused group index and use that, adjust the error message. In stats_test.c, adjust, and also assert allocated counter group indexes everywhere. Rationale: The original patch causes osmo-sgsn to crash as soon as the second subscriber attempts to establish an MM context. Of course osmo-sgsn is wrong to a) fail to check a NULL return value and crash and b) to fail to allocate an MM context just because the rate counter group could not be allocated (it still rejects the MM context completely if rate_ctr_group_alloc() fails). Nevertheless, the price we pay for rate counter correctness is, at least in this instance, way too high: osmo-sgsn becomes completely unusable for more than one subscriber. Numerous other places exist where rate_ctr_group_alloc() is called with a constant index number; from a quick grep magic I found these possible breaking points: osmo-sgsn/src/gprs/gb_proxy.c:1431: cfg->ctrg = rate_ctr_group_alloc(tall_bsc_ctx, &global_ctrg_desc, 0); osmo-sgsn/src/gprs/gprs_sgsn.c:139: sgsn->rate_ctrs = rate_ctr_group_alloc(tall_bsc_ctx, &sgsn_ctrg_desc, 0); osmo-sgsn/src/gprs/gprs_sgsn.c:270: ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, 0); osmo-sgsn/src/gprs/gtphub.c:888: b->counters_io = rate_ctr_group_alloc(osmo_gtphub_ctx, &gtphub_ctrg_io_desc, 0); osmo-bsc/src/libfilter/bsc_msg_acc.c:87: lst->stats = rate_ctr_group_alloc(lst, &bsc_cfg_acc_list_desc, 0); osmo-pcu/src/bts.cpp:228: m_ratectrs = rate_ctr_group_alloc(tall_pcu_ctx, &bts_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:793: tbf->m_ctrs = rate_ctr_group_alloc(tbf, &tbf_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:879: tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_ul_egprs_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:880: tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_ul_gprs_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:970: tbf->m_dl_egprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_dl_egprs_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:977: tbf->m_dl_gprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_dl_gprs_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:1475: ul_tbf->m_ctrs = rate_ctr_group_alloc(ul_tbf, &tbf_ctrg_desc, 0); osmo-pcu/src/bts.cpp:226: m_ratectrs = rate_ctr_group_alloc(tall_pcu_ctx, &bts_ctrg_desc, 1); We can fix all of these callers and then reconsider returning NULL, but IMO even into the future, rate counter group indexes are not something worth failing to provide service for. For future bugs we should keep the automatic index picking in case of index collisions. We will get an error message barfed and can fix the issue in our own time, while the application remains completely usable, and even the rate counters can still be queried (at wrong indexes, but life is tough). Related: I49aa95b610f2faec52dede2e4816da47ca1dfb14 (osmo-sgsn's segfault) Change-Id: Iba6e41b8eeaea5ff6ed862bab3f34a62ab976914
2017-12-18rate_ctr: print proper error message if rate_ctr already existsHarald Welte1-1/+4
Change-Id: I86b7ccb0931f5a2a489bb8c7c6aee0894a126eb8
2017-12-17Do not allocate already existing counter groupMax1-0/+3
Check that no group with the given name and index already exist before allocating it. Add corresponding test case. Change-Id: I563764af1d28043e909234ebb048239125ce6ecd Related: OS#2757
2017-11-20rate_ctr: fix mem leak for mangled descNeels Hofmeyr1-9/+9
Using the NULL context creates mem leaks that bother sanitizer builds. Allocate as talloc "child" of the rate_ctr_group, so that the mangled desc (if any) gets freed when the rate_ctr group is freed. Remove the comment concerning osmo-msc: the way to fix the unexpected talloc state in osmo-msc tests is to have no invalid rate counter names in osmo-msc. See Ib1db8e3dc6c833174f1b0b1ca051b0861f477408 (osmo-msc). Change-Id: Ief9abfeb78b7706200bcc6aaa5dcb04fbeaa9b5b
Let's fix some erroneous/accidential references to wrong license, update copyright information where applicable and introduce a SPDX-License-Identifier to all files. Change-Id: I39af26c6aaaf5c926966391f6565fc5936be21af
2017-10-24rate_ctr: Fix null pointer dereference in error pathHarald Welte1-1/+2
In Change-Id Ifc6ac824f5dae9a848bb4a5d067c64a69eb40b56 we introduced a variable de-reference before we check if it's NULL. Let's reorder the statements to avoid this. Fixes: Coverity CID#178219 Change-Id: I99265a7ee76f85c479543c19ce8c05ce5d43ae69
2017-10-24rate_ctr: Enforce counter (and ctr_group) names are valid identifiersHarald Welte1-1/+117
As rate counters are automatically exposed on the CTRL interface, we need to make sure they don't contain special characters such as '.' which are not permitted/supported by CTRL. In order to be able to run old versions of osmocom programs with libosmocore versions after this commit, we introduce some special name mangling: Any '.' in the names are replaced with ':' during counter group registration, if valid identifiers can be obtained this way. Change-Id: Ifc6ac824f5dae9a848bb4a5d067c64a69eb40b56
2017-10-16[doc] rate_ctr: Extend Doxygen API documentation with human-readable text on ↵Harald Welte1-2/+35
its use Change-Id: If9abd46e1b0ebb6114522418fd3b45c1d802968a
2017-06-23doxygen: unify use of \file across the boardNeels Hofmeyr1-7/+3
Considering the various styles and implications found in the sources, edit scores of files to follow the same API doc guidelines around the doxygen grouping and the \file tag. Many files now show a short description in the generated API doc that was so far only available as C comment. The guidelines and reasoning behind it is documented at https://osmocom.org/projects/cellular-infrastructure/wiki/Guidelines_for_API_documentation In some instances, remove file comments and add to the corresponding group instead, to be shared among several files (e.g. bitvec). Change-Id: Ifa70e77e90462b5eb2b0457c70fd25275910c72b
2017-06-23doxygen: enable AUTOBRIEF, drop \briefNeels Hofmeyr1-10/+10
Especially for short descriptions, it is annoying to have to type \brief for every single API doc. Drop all \brief and enable the AUTOBRIEF feature of doxygen, which always takes the first sentence of an API doc as the brief description. Change-Id: I11a8a821b065a128108641a2a63fb5a2b1916e87
2017-06-12update/extend doxygen documentationHarald Welte1-0/+1
It's a pity that even with this patch we still are fare away from having the whole API documented. However, at least we have a more solid foundation. Updates not only extend the documentation, but also make sure it is rendered properly in the doxygen HTML. Change-Id: I1344bd1a6869fb00de7c1899a8db93bba9bafce3
Add a new function timer function to set up the timer, similar to what we have in the Linux kernel. This patch also converts existing opencoded timer setup in the libosmocore tree as initial client of this new function. This patch implicitly removes function callback passed by reference that defeat compile time type validation. Compile-tested only, but I ran make check that reports success when testing timer infrastructure. Change-Id: I2fa49972ecaab3748b25168b26d92034e9145666
2016-05-05Update doxygen annotations in libosmocoreHarald Welte1-3/+20
This adds and improves doxygen API descriptions all over libosmocore, reducing the 'white spots' that don't have any documentation.
2015-11-26stats: Add TODO comment to rate_ctrJacob Erlbeck1-0/+3
Currently the counters are scanned twice, once for interval computation and once for reporting. This adds a reminder to move the interval computation code to a special stats reporter which just shall update the fields. Sponsored-by: On-Waves ehf
2015-10-28core: Extend rate_ctr by helper functionsJacob Erlbeck1-0/+41
For global value reporting, some additional helper functions are needed. The statsd protocol expects differential counter values, which are currently not provided by rate_ctr (except for s/m/h/d intervals). This commit adds several helper functions to rate_ctr: - rate_ctr_difference returns the counter delta since the last call to this function for a given counter - rate_ctr_for_each_counter iterates through each counter of a group - rate_ctr_for_each_group iterates through all globally registered counter groups Note that the rate_ctr_difference function can only be used by a single backend, since it modifies the 'previous' field in the rate_ctr obj. Sponsored-by: On-Waves ehf
2012-04-18doc: Fix the Doxygen section endingsSylvain Munaut1-1/+1
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-08-17doxygen: Add docs for rate_ctrHarald Welte1-0/+19
2011-05-07timer: use namespace prefix osmo_timer*Pablo Neira Ayuso1-3/+3
Summary of changes: s/struct timer_list/struct osmo_timer_list/g s/bsc_add_timer/osmo_timer_add/g s/bsc_schedule_timer/osmo_timer_schedule/g s/bsc_del_timer/osmo_timer_del/g s/bsc_timer_pending/osmo_timer_pending/g s/bsc_nearest_timer/osmo_timers_nearest/g s/bsc_prepare_timers/osmo_timers_prepare/g s/bsc_update_timers/osmo_timers_update/g s/bsc_timer_check/osmo_timers_check/g
2011-04-18stats: Fix the compiler warningsHolger Hans Peter Freyther1-2/+2
Do not remove the const, include strings.h for strcmp
2011-04-09Add functions to search for rate counters by nameDaniel Willmann1-0/+34
* rate_ctr_get_group_by_name_idx, rate_ctr_get_by_name
2011-03-23include: reorganize headers file to include/osmocom/[gsm|core]0.2.0Pablo Neira Ayuso1-5/+5
This patch moves all GSM-specific definitions to include/osmocom/gsm. Moreover, the headers in include/osmocore/ have been moved to include/osmocom/core. This has been proposed by Harald Welte and Sylvain Munaunt. Tested with `make distcheck'. Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2010-12-20rate_ctr: No need to include the inttypes.hHolger Hans Peter Freyther1-1/+0
There should not be any u_int*_t types in this file, no need to include this file. It is breaking compilation with the last x86 build of GNU ARM for GCC 3.4.
2010-05-13[rate_ctr] always 'overflow' in next larger inetrval when interval endsHarald Welte1-0/+6
If a second ends, we add the number of events in that just-ended second to the number of events in the currently running minute. The same happens at the end of a minute: We add the number of events in that just-ended minute into the number of events of the still-running hour, etc. This gives a much more meaningful numbers and we don't end up with "12 events per second, but 0 events per minute" kind of situations anymore.
2010-05-13rate_counters: Remove group-name-sprintf-with-idx stringHarald Welte1-3/+0
2010-05-13rate_ctr: Store the numeric index as part of 'rate_ctr_group'Harald Welte1-0/+1
2010-05-13Add new 'rate counter' implementation to libosmocoreHarald Welte1-0/+124
A 'rate counter' is a counter that counts events but also keeps track of the rate of events (per second, minute, hour and day). 'rate counters' are generally abstracted in 'rate counter groups', which are instances of a 'rate counter group description'. This way we can have e.g. a description describing what kind of counters a BTS (or TRX) has - and we can then create one instance of that group for every BTS or TRX that exists.