Skip to content

Commit

Permalink
stats: track packet check results per ISD-AS and DRKey protocol number
Browse files Browse the repository at this point in the history
LF packet check results are now tracked for each ISD-AS and DRKey protocol that is listed as a peer in the configuration separately. The metrics are exposed on the telemetry path `lf/ia/stats`. Furthermore, `lf/ia/stats/list` provides a list of all combinations of ISD-AS and DRKey ptorocol numbers that are being tracked.
  • Loading branch information
Fabio Streun committed Jan 15, 2025
1 parent 96ad8f9 commit 88b9c1f
Show file tree
Hide file tree
Showing 9 changed files with 504 additions and 65 deletions.
7 changes: 6 additions & 1 deletion src/configmanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "lib/log/log.h"
#include "plugins/plugins.h"
#include "ratelimiter.h"
#include "statistics.h"


/*
Expand Down Expand Up @@ -54,6 +55,9 @@ lf_configmanager_apply_config(struct lf_configmanager *cm,
if (cm->km != NULL) {
res |= lf_keymanager_apply_config(cm->km, new_config);
}
if (cm->stats != NULL) {
res |= lf_statistics_apply_config(cm->stats, new_config);
}
res |= lf_plugins_apply_config(new_config);

/* update worker's config */
Expand Down Expand Up @@ -98,7 +102,7 @@ lf_configmanager_apply_config_file(struct lf_configmanager *cm,
int
lf_configmanager_init(struct lf_configmanager *cm, uint16_t nb_workers,
struct rte_rcu_qsbr *qsv, struct lf_keymanager *km,
struct lf_ratelimiter *rl)
struct lf_ratelimiter *rl, struct lf_statistics *stats)
{
uint16_t worker_id;

Expand All @@ -120,6 +124,7 @@ lf_configmanager_init(struct lf_configmanager *cm, uint16_t nb_workers,

cm->km = km;
cm->rl = rl;
cm->stats = stats;

return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion src/configmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct lf_configmanager {
/* Reference to other services which are notified on config change. */
struct lf_keymanager *km;
struct lf_ratelimiter *rl;
struct lf_statistics *stats;
};

/**
Expand All @@ -58,7 +59,7 @@ struct lf_configmanager {
int
lf_configmanager_init(struct lf_configmanager *cm, uint16_t nb_workers,
struct rte_rcu_qsbr *qsv, struct lf_keymanager *km,
struct lf_ratelimiter *rl);
struct lf_ratelimiter *rl, struct lf_statistics *stats);

/**
* Load new config from json file.
Expand Down
8 changes: 5 additions & 3 deletions src/lib/log/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ void
lf_print(const char *format, ...);

#define PRIISDAS "%u-%x:%x:%x"
#define PRIISDAS_VAL(isd_as) \
((isd_as) >> 48 & 0XFFFF), ((isd_as) >> 32 & 0XFFFF), \
((isd_as) >> 16 & 0XFFFF), ((isd_as) >> 0 & 0XFFFF)
#define PRIISDAS_VAL(isd_as) \
(unsigned int)((isd_as) >> 48 & 0XFFFF), \
(unsigned int)((isd_as) >> 32 & 0XFFFF), \
(unsigned int)((isd_as) >> 16 & 0XFFFF), \
(unsigned int)((isd_as) >> 0 & 0XFFFF)

#endif /* LF_LOG_H */
5 changes: 3 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ main(int argc, char **argv)
/*
* Setup Statistics
*/
res = lf_statistics_init(&statistics, lf_worker_lcore_map, lf_nb_workers);
res = lf_statistics_init(&statistics, lf_worker_lcore_map, lf_nb_workers,
qsv);
if (res < 0) {
rte_exit(EXIT_FAILURE, "Unable to initiate statistics\n");
}
Expand All @@ -532,7 +533,7 @@ main(int argc, char **argv)
* Setup Config Manager
*/
res = lf_configmanager_init(&configmanager, lf_nb_workers, qsv, &keymanager,
&ratelimiter);
&ratelimiter, &statistics);
if (res != 0) {
rte_exit(EXIT_FAILURE, "Fail to init config manager.\n");
}
Expand Down
6 changes: 3 additions & 3 deletions src/ratelimiter.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ dictionary_new(uint32_t size)

if (dic == NULL) {
LF_RATELIMITER_LOG(ERR, "Hash creation failed with: %d\n", errno);
rte_hash_free(dic);
return NULL;
}

Expand All @@ -159,8 +158,8 @@ static void
dictionary_free(struct rte_hash *dict)
{
uint32_t iterator;
struct lf_ratelimiter_dictionary_key *key_ptr;
struct lf_ratelimiter_dictionary_data *data;
struct lf_ratelimiter_key *key_ptr;
struct lf_ratelimiter_data *data;

for (iterator = 0; rte_hash_iterate(dict, (void *)&key_ptr, (void **)&data,
&iterator) >= 0;) {
Expand Down Expand Up @@ -410,6 +409,7 @@ lf_ratelimiter_close(struct lf_ratelimiter *rl)
rte_free(rl->workers[i]);
}

// TODO: double free here (see rte_hash_free above)
dictionary_free(rl->dict);
}

Expand Down
Loading

0 comments on commit 88b9c1f

Please sign in to comment.