ms: Store references to replaced TBFs in the MS object

Currently when calling GprsMs::attach_tbf and a TBF of the same
direction already exists, the old TBF gets detached from the MS
object.

Therefore that TBF object loses access to that MS object including
for instance TLLI and IMSI.

This leads to failing DL TBF reuses, since the downlink assigment
cannot be sent on the PACCH later on because that must be sent on the
old DL TBF which ms() is NULL and the new DL TBF cannot be retrieved.

This commit fixes this bug by changing the GprsMs implementation to
keep a list of replaced (old) TBFs. TBFs are only removed when they
are being detached explicitely (see tbf_free and set_ms).

Addresses:
tbf.cpp:741 We have a schedule for downlink assignment at uplink
TBF(TFI=1 TLLI=0xf35a680e DIR=UL STATE=RELEASING), but there is no
downlink TBF

Sponsored-by: On-Waves ehf
diff --git a/src/gprs_ms.h b/src/gprs_ms.h
index c490e7a..1f080ff 100644
--- a/src/gprs_ms.h
+++ b/src/gprs_ms.h
@@ -109,13 +109,14 @@
 
 	void update_error_rate(gprs_rlcmac_tbf *tbf, int percent);
 
-	bool is_idle() const {return !m_ul_tbf && !m_dl_tbf && !m_ref;}
+	bool is_idle() const;
 
 	void* operator new(size_t num);
 	void operator delete(void* p);
 
 	LListHead<GprsMs>& list() {return this->m_list;}
 	const LListHead<GprsMs>& list() const {return this->m_list;}
+	const LListHead<gprs_rlcmac_tbf>& old_tbfs() const {return m_old_tbfs;}
 
 	void update_l1_meas(const pcu_l1_meas *meas);
 	const pcu_l1_meas* l1_meas() const {return &m_l1_meas;};
@@ -136,6 +137,8 @@
 	Callback * m_cb;
 	gprs_rlcmac_ul_tbf *m_ul_tbf;
 	gprs_rlcmac_dl_tbf *m_dl_tbf;
+	LListHead<gprs_rlcmac_tbf> m_old_tbfs;
+
 	uint32_t m_tlli;
 	uint32_t m_new_ul_tlli;
 	uint32_t m_new_dl_tlli;
@@ -167,6 +170,11 @@
 	struct gprs_codel *m_codel_state;
 };
 
+inline bool GprsMs::is_idle() const
+{
+	return !m_ul_tbf && !m_dl_tbf && !m_ref && llist_empty(&m_old_tbfs);
+}
+
 inline uint32_t GprsMs::tlli() const
 {
 	return m_new_ul_tlli ? m_new_ul_tlli :