mac_nr: add various safety/length checks

master
Andre Puschmann 4 years ago
parent b1aaadb51c
commit d1ad315969

@ -128,7 +128,8 @@ void mac_nr::update_buffer_states()
mac_buffer_states.lcid_buffer_size[channel.lcid] += buffer_len; mac_buffer_states.lcid_buffer_size[channel.lcid] += buffer_len;
mac_buffer_states.lcg_buffer_size[channel.lcg] += buffer_len; mac_buffer_states.lcg_buffer_size[channel.lcg] += buffer_len;
} }
logger.info("%s", mac_buffer_states.to_string()); logger.debug("%s", mac_buffer_states.to_string());
// Count TTI for metrics // Count TTI for metrics
for (uint32_t i = 0; i < SRSRAN_MAX_CARRIERS; ++i) { for (uint32_t i = 0; i < SRSRAN_MAX_CARRIERS; ++i) {
metrics[i].nof_tti++; metrics[i].nof_tti++;
@ -286,11 +287,15 @@ void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant,
ul_harq_buffer = mux.get_pdu(grant.tbs); ul_harq_buffer = mux.get_pdu(grant.tbs);
// fill TB action (goes into UL harq eventually) // fill TB action (goes into UL harq eventually)
action->tb.payload = ul_harq_buffer.get(); // pass handle to PDU to PHY if (ul_harq_buffer != nullptr) {
action->tb.enabled = true; action->tb.payload = ul_harq_buffer.get(); // pass handle to PDU to PHY
action->tb.rv = 0; action->tb.enabled = true;
action->tb.softbuffer = &softbuffer_tx; action->tb.rv = 0;
srsran_softbuffer_tx_reset(&softbuffer_tx); action->tb.softbuffer = &softbuffer_tx;
srsran_softbuffer_tx_reset(&softbuffer_tx);
} else {
action->tb.enabled = false;
}
// store PCAP // store PCAP
if (pcap) { if (pcap) {

@ -49,6 +49,12 @@ srsran::unique_byte_buffer_t mux_nr::get_pdu(uint32_t max_pdu_len)
return nullptr; return nullptr;
} }
// verify buffer is large enough for UL grant
if (phy_tx_pdu->get_tailroom() < max_pdu_len) {
logger.error("Can't provide MAC PDU. Grant too big (%d < %d).", phy_tx_pdu->get_tailroom(), max_pdu_len);
return nullptr;
}
logger.debug("Building new MAC PDU (%d B)", max_pdu_len); logger.debug("Building new MAC PDU (%d B)", max_pdu_len);
tx_pdu.init_tx(phy_tx_pdu.get(), max_pdu_len, true); tx_pdu.init_tx(phy_tx_pdu.get(), max_pdu_len, true);

@ -199,8 +199,10 @@ bool proc_bsr_nr::check_new_data(const mac_buffer_states_t& new_buffer_state)
srsran::mac_sch_subpdu_nr::lcg_bsr_t proc_bsr_nr::generate_sbsr() srsran::mac_sch_subpdu_nr::lcg_bsr_t proc_bsr_nr::generate_sbsr()
{ {
srsran::mac_sch_subpdu_nr::lcg_bsr_t sbsr = {}; srsran::mac_sch_subpdu_nr::lcg_bsr_t sbsr = {};
sbsr.lcg_id = buffer_state.last_non_zero_lcg; if (buffer_state.nof_lcgs_with_data > 0) {
sbsr.buffer_size = buff_size_bytes_to_field(buffer_state.lcg_buffer_size.at(sbsr.lcg_id), SHORT_BSR); sbsr.lcg_id = buffer_state.last_non_zero_lcg;
sbsr.buffer_size = buff_size_bytes_to_field(buffer_state.lcg_buffer_size.at(sbsr.lcg_id), SHORT_BSR);
}
triggered_bsr_type = NONE; triggered_bsr_type = NONE;
return sbsr; return sbsr;
} }

Loading…
Cancel
Save