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
diff --git a/openbsc/include/openbsc/msgb.h b/openbsc/include/openbsc/msgb.h
index 2c31d15..5ecac45 100644
--- a/openbsc/include/openbsc/msgb.h
+++ b/openbsc/include/openbsc/msgb.h
@@ -47,7 +47,7 @@
 	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 @@
 	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 6b1fc54..4a73930 100644
--- a/openbsc/src/abis_nm.c
+++ b/openbsc/src/abis_nm.c
@@ -423,7 +423,8 @@
 
 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 b8990c7..0488b9d 100644
--- a/openbsc/src/abis_rsl.c
+++ b/openbsc/src/abis_rsl.c
@@ -293,7 +293,8 @@
 
 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 84dde90..9de6b01 100644
--- a/openbsc/src/e1_input.c
+++ b/openbsc/src/e1_input.c
@@ -458,7 +458,7 @@
 		}
 		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 c081b45..56db654 100644
--- a/openbsc/src/gsm_04_08.c
+++ b/openbsc/src/gsm_04_08.c
@@ -975,7 +975,8 @@
 
 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 @@
 
 	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 571da4c..1b622b1 100644
--- a/openbsc/src/gsm_04_11.c
+++ b/openbsc/src/gsm_04_11.c
@@ -51,7 +51,8 @@
 
 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 b76629e..cee53cc 100644
--- a/openbsc/src/input/ipaccess.c
+++ b/openbsc/src/input/ipaccess.c
@@ -244,7 +244,7 @@
 	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 44f0964..367d8e4 100644
--- a/openbsc/src/input/misdn.c
+++ b/openbsc/src/input/misdn.c
@@ -96,7 +96,7 @@
 	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 @@
 	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 8bdc9aa..ae13346 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 2a64de5..a584723 100644
--- a/openbsc/src/rs232.c
+++ b/openbsc/src/rs232.c
@@ -127,7 +127,7 @@
 	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 7615b62..04febbd 100644
--- a/openbsc/src/trau_mux.c
+++ b/openbsc/src/trau_mux.c
@@ -170,7 +170,8 @@
 			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;