gbproxy: Introduce new DOBJ log category; log object allocation/release

Related: OS#4472
Change-Id: I43bcbcda8667d193e7a17fd8e8e9109597b01484
This commit is contained in:
Harald Welte 2020-12-07 12:03:10 +01:00 committed by Daniel Willmann
parent c91f53ca0a
commit 7cb76a4321
4 changed files with 29 additions and 0 deletions

View File

@ -39,6 +39,7 @@ enum {
DIUCS,
DSIGTRAN,
DGTP,
DOBJ,
Debug_LastEntry,
};

View File

@ -142,6 +142,11 @@ struct gbproxy_nse {
#define LOGPBVC(BVC, LEVEL, FMT, ARGS...) \
LOGPBVC_CAT(BVC, DGPRS, LEVEL, FMT, ## ARGS)
#define LOGPCELL_CAT(CELL, SUBSYS, LEVEL, FMT, ARGS...) \
LOGP(SUBSYS, LEVEL, "CELL(%05u) " FMT, (CELL)->bvci, ## ARGS)
#define LOGPCELL(CELL, LEVEL, FMT, ARGS...) \
LOGPCELL_CAT(CELL, DGPRS, LEVEL, FMT, ## ARGS)
/* gb_proxy_vty .c */
int gbproxy_vty_init(void);

View File

@ -209,6 +209,12 @@ static struct log_info_cat gprs_categories[] = {
.description = "GPRS Network Service (NS)",
.enabled = 1, .loglevel = LOGL_INFO,
},
[DOBJ] = {
.name = "DOBJ",
.description = "GbProxy object allocation/release",
.enabled = 1,
.color = "\033[38;5;121m"
},
};
static const struct log_info gprs_log_info = {

View File

@ -86,6 +86,11 @@ struct gbproxy_bvc *gbproxy_bvc_alloc(struct gbproxy_nse *nse, uint16_t bvci)
hash_add(nse->bvcs, &bvc->list, bvc->bvci);
LOGPBVC_CAT(bvc, DOBJ, LOGL_INFO, "BVC Created\n");
/* We leave allocating the bvc->fi to the caller, as the FSM details depend
* on the type of BVC (SIG/PTP) and role (SGSN/BSS) */
return bvc;
}
@ -96,6 +101,8 @@ void gbproxy_bvc_free(struct gbproxy_bvc *bvc)
if (!bvc)
return;
LOGPBVC_CAT(bvc, DOBJ, LOGL_INFO, "BVC Destroying\n");
hash_del(&bvc->list);
rate_ctr_group_free(bvc->ctrg);
@ -167,6 +174,8 @@ struct gbproxy_cell *gbproxy_cell_alloc(struct gbproxy_config *cfg, uint16_t bvc
hash_add(cfg->cells, &cell->list, cell->bvci);
LOGPCELL_CAT(cell, DOBJ, LOGL_INFO, "CELL Created\n");
return cell;
}
@ -201,6 +210,8 @@ void gbproxy_cell_free(struct gbproxy_cell *cell)
if (!cell)
return;
LOGPCELL_CAT(cell, DOBJ, LOGL_INFO, "CELL Destroying\n");
/* remove from cfg.cells */
hash_del(&cell->list);
@ -225,6 +236,8 @@ bool gbproxy_cell_add_sgsn_bvc(struct gbproxy_cell *cell, struct gbproxy_bvc *bv
for (i = 0; i < ARRAY_SIZE(cell->sgsn_bvc); i++) {
if (!cell->sgsn_bvc[i]) {
cell->sgsn_bvc[i] = bvc;
LOGPCELL_CAT(cell, DOBJ, LOGL_DEBUG, "CELL linked to SGSN\n");
LOGPBVC_CAT(bvc, DOBJ, LOGL_DEBUG, "BVC linked to CELL\n");
return true;
}
}
@ -255,6 +268,8 @@ struct gbproxy_nse *gbproxy_nse_alloc(struct gbproxy_config *cfg, uint16_t nsei,
hash_init(nse->bvcs);
LOGPNSE_CAT(nse, DOBJ, LOGL_INFO, "NSE Created\n");
return nse;
}
@ -267,6 +282,8 @@ void gbproxy_nse_free(struct gbproxy_nse *nse)
if (!nse)
return;
LOGPNSE_CAT(nse, DOBJ, LOGL_INFO, "NSE Destroying\n");
hash_del(&nse->list);
hash_for_each_safe(nse->bvcs, i, tmp, bvc, list)