summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2009-06-26 19:39:35 +0200
committerHarald Welte <laforge@gnumonks.org>2009-06-26 19:39:35 +0200
commit966636f39f17e5d42e7918a2055d400c791671b4 (patch)
treef7bc3c7ac76e2c63ad4a1f5190ed218ab53c2c6b
parentf16571635a9d81893cb7bcc3d12dbf6639f3b3df (diff)
use named variant when allocating msgb's
when we generate a talloc report (SIGUSR1), we can now see which system allocated a given msgb, this helps memory leak debugging
-rw-r--r--openbsc/include/openbsc/msgb.h7
-rw-r--r--openbsc/src/abis_nm.c3
-rw-r--r--openbsc/src/abis_rsl.c3
-rw-r--r--openbsc/src/e1_input.c2
-rw-r--r--openbsc/src/gsm_04_08.c5
-rw-r--r--openbsc/src/gsm_04_11.c3
-rw-r--r--openbsc/src/input/ipaccess.c2
-rw-r--r--openbsc/src/input/misdn.c4
-rw-r--r--openbsc/src/msgb.c5
-rw-r--r--openbsc/src/rs232.c2
-rw-r--r--openbsc/src/trau_mux.c3
11 files changed, 22 insertions, 17 deletions
diff --git a/openbsc/include/openbsc/msgb.h b/openbsc/include/openbsc/msgb.h
index 2c31d1587..5ecac459b 100644
--- a/openbsc/include/openbsc/msgb.h
+++ b/openbsc/include/openbsc/msgb.h
@@ -47,7 +47,7 @@ struct msgb {
unsigned char _data[0];
};
-extern struct msgb *msgb_alloc(u_int16_t size);
+extern struct msgb *msgb_alloc(u_int16_t size, const char *name);
extern void msgb_free(struct msgb *m);
extern void msgb_enqueue(struct llist_head *queue, struct msgb *msg);
extern struct msgb *msgb_dequeue(struct llist_head *queue);
@@ -100,9 +100,10 @@ static inline void msgb_reserve(struct msgb *msg, int len)
msg->tail += len;
}
-static inline struct msgb *msgb_alloc_headroom(int size, int headroom)
+static inline struct msgb *msgb_alloc_headroom(int size, int headroom,
+ const char *name)
{
- struct msgb *msg = msgb_alloc(size);
+ struct msgb *msg = msgb_alloc(size, name);
if (msg)
msgb_reserve(msg, headroom);
return msg;
diff --git a/openbsc/src/abis_nm.c b/openbsc/src/abis_nm.c
index 6b1fc54f7..4a73930fc 100644
--- a/openbsc/src/abis_nm.c
+++ b/openbsc/src/abis_nm.c
@@ -423,7 +423,8 @@ static void fill_om_fom_hdr(struct abis_om_hdr *oh, u_int8_t len,
static struct msgb *nm_msgb_alloc(void)
{
- return msgb_alloc_headroom(OM_ALLOC_SIZE, OM_HEADROOM_SIZE);
+ return msgb_alloc_headroom(OM_ALLOC_SIZE, OM_HEADROOM_SIZE,
+ "OML");
}
/* Send a OML NM Message from BSC to BTS */
diff --git a/openbsc/src/abis_rsl.c b/openbsc/src/abis_rsl.c
index b8990c7ee..0488b9dfe 100644
--- a/openbsc/src/abis_rsl.c
+++ b/openbsc/src/abis_rsl.c
@@ -293,7 +293,8 @@ unsigned int get_paging_group(u_int64_t imsi, unsigned int bs_cc_chans,
static struct msgb *rsl_msgb_alloc(void)
{
- return msgb_alloc_headroom(RSL_ALLOC_SIZE, RSL_ALLOC_HEADROOM);
+ return msgb_alloc_headroom(RSL_ALLOC_SIZE, RSL_ALLOC_HEADROOM,
+ "RSL");
}
#define MACBLOCK_SIZE 23
diff --git a/openbsc/src/e1_input.c b/openbsc/src/e1_input.c
index 84dde9047..9de6b0141 100644
--- a/openbsc/src/e1_input.c
+++ b/openbsc/src/e1_input.c
@@ -458,7 +458,7 @@ struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts,
}
break;
case E1INP_TS_TYPE_TRAU:
- msg = msgb_alloc(TSX_ALLOC_SIZE);
+ msg = msgb_alloc(TSX_ALLOC_SIZE, "TRAU_TX");
if (!msg)
return NULL;
len = subchan_mux_out(&e1i_ts->trau.mux, msg->data, 40);
diff --git a/openbsc/src/gsm_04_08.c b/openbsc/src/gsm_04_08.c
index c081b45c2..56db65439 100644
--- a/openbsc/src/gsm_04_08.c
+++ b/openbsc/src/gsm_04_08.c
@@ -975,7 +975,8 @@ static int encode_more(struct msgb *msg)
struct msgb *gsm48_msgb_alloc(void)
{
- return msgb_alloc_headroom(GSM48_ALLOC_SIZE, GSM48_ALLOC_HEADROOM);
+ return msgb_alloc_headroom(GSM48_ALLOC_SIZE, GSM48_ALLOC_HEADROOM,
+ "GSM 04.08");
}
int gsm48_sendmsg(struct msgb *msg)
@@ -1856,7 +1857,7 @@ static int mncc_recvmsg(struct gsm_network *net, struct gsm_trans *trans,
mncc->msg_type = msg_type;
- msg = msgb_alloc(sizeof(struct gsm_mncc));
+ msg = msgb_alloc(sizeof(struct gsm_mncc), "MNCC");
if (!msg)
return -ENOMEM;
memcpy(msg->data, mncc, sizeof(struct gsm_mncc));
diff --git a/openbsc/src/gsm_04_11.c b/openbsc/src/gsm_04_11.c
index 571da4cba..1b622b12b 100644
--- a/openbsc/src/gsm_04_11.c
+++ b/openbsc/src/gsm_04_11.c
@@ -51,7 +51,8 @@ static void *tall_gsms_ctx;
struct msgb *gsm411_msgb_alloc(void)
{
- return msgb_alloc_headroom(GSM411_ALLOC_SIZE, GSM411_ALLOC_HEADROOM);
+ return msgb_alloc_headroom(GSM411_ALLOC_SIZE, GSM411_ALLOC_HEADROOM,
+ "GSM 04.11");
}
int gsm0411_sendmsg(struct msgb *msg)
diff --git a/openbsc/src/input/ipaccess.c b/openbsc/src/input/ipaccess.c
index b76629e5e..cee53cc13 100644
--- a/openbsc/src/input/ipaccess.c
+++ b/openbsc/src/input/ipaccess.c
@@ -244,7 +244,7 @@ static int handle_ts1_read(struct bsc_fd *bfd)
unsigned int ts_nr = bfd->priv_nr;
struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
struct e1inp_sign_link *link;
- struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE);
+ struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE, "Abis/IP");
struct ipaccess_head *hh;
int ret;
diff --git a/openbsc/src/input/misdn.c b/openbsc/src/input/misdn.c
index 44f09646d..367d8e4a6 100644
--- a/openbsc/src/input/misdn.c
+++ b/openbsc/src/input/misdn.c
@@ -96,7 +96,7 @@ static int handle_ts1_read(struct bsc_fd *bfd)
unsigned int ts_nr = bfd->priv_nr;
struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
struct e1inp_sign_link *link;
- struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE);
+ struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE, "mISDN TS1");
struct sockaddr_mISDN l2addr;
struct mISDNhead *hh;
socklen_t alen;
@@ -278,7 +278,7 @@ static int handle_tsX_read(struct bsc_fd *bfd)
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
- struct msgb *msg = msgb_alloc(TSX_ALLOC_SIZE);
+ struct msgb *msg = msgb_alloc(TSX_ALLOC_SIZE, "mISDN TSx");
struct mISDNhead *hh;
int ret;
diff --git a/openbsc/src/msgb.c b/openbsc/src/msgb.c
index 8bdc9aa70..ae1334614 100644
--- a/openbsc/src/msgb.c
+++ b/openbsc/src/msgb.c
@@ -29,18 +29,17 @@
static void *tall_msgb_ctx;
-struct msgb *msgb_alloc(u_int16_t size)
+struct msgb *msgb_alloc(u_int16_t size, const char *name)
{
struct msgb *msg;
if (!tall_msgb_ctx)
tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 1, "msgb");
- msg = talloc_size(tall_msgb_ctx, sizeof(*msg) + size);
+ msg = _talloc_zero(tall_msgb_ctx, sizeof(*msg) + size, name);
if (!msg)
return NULL;
- memset(msg, 0, sizeof(*msg)+size);
msg->data_len = size;
msg->len = 0;
diff --git a/openbsc/src/rs232.c b/openbsc/src/rs232.c
index 2a64de5ef..a58472364 100644
--- a/openbsc/src/rs232.c
+++ b/openbsc/src/rs232.c
@@ -127,7 +127,7 @@ static int handle_ser_read(struct bsc_fd *bfd)
int rc = 0;
if (!sh->rx_msg) {
- sh->rx_msg = msgb_alloc(SERIAL_ALLOC_SIZE);
+ sh->rx_msg = msgb_alloc(SERIAL_ALLOC_SIZE, "RS232 Rx");
sh->rx_msg->l2h = NULL;
sh->rx_msg->trx = sh->bts->c0;
}
diff --git a/openbsc/src/trau_mux.c b/openbsc/src/trau_mux.c
index 7615b6294..04febbd63 100644
--- a/openbsc/src/trau_mux.c
+++ b/openbsc/src/trau_mux.c
@@ -170,7 +170,8 @@ int trau_mux_input(struct gsm_e1_subslot *src_e1_ss,
return -EINVAL;
if (!ue->callref)
return -EINVAL;
- msg = msgb_alloc(sizeof(struct gsm_trau_frame) + sizeof(tf));
+ msg = msgb_alloc(sizeof(struct gsm_trau_frame) + sizeof(tf),
+ "TRAU");
if (!msg)
return -ENOMEM;
frame = (struct gsm_trau_frame *)msg->data;