Skip to content

Commit

Permalink
Workaround for division by zero crash (omec-project#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccascone committed Dec 15, 2021
1 parent b5898ed commit 103b198
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions core/modules/qos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,27 @@ void Qos::ProcessBatch(Context *ctx, bess::PacketBatch *batch) {

// meter if ogate is 0
if (ogate == METER_GATE) {
uint64_t time = rte_rdtsc();
uint32_t pkt_len = pkt->total_len() - val[j]->deduct_len;
uint8_t color = rte_meter_trtcm_color_blind_check(&val[j]->m, val[j]->p,
time, pkt_len);

DLOG(INFO) << "color : " << color << std::endl;
// update ogate to color specific gate
if (color == RTE_COLOR_GREEN) {
if (val[j]->p->cir_period == 0 || val[j]->p->pir_period == 0) {
// FIXME: https://github.com/omec-project/upf-epc/issues/376
DLOG(INFO) << "Detected pir/cir_period zero in rte_meter_trtcm_profile,"
<< " BUG? Setting METER_GREEN_GATE to prevent crash"
<< std::endl;
ogate = METER_GREEN_GATE;
} else if (color == RTE_COLOR_YELLOW) {
ogate = METER_YELLOW_GATE;
} else if (color == RTE_COLOR_RED) {
ogate = METER_RED_GATE;
} else {
uint64_t time = rte_rdtsc();
uint32_t pkt_len = pkt->total_len() - val[j]->deduct_len;
uint8_t color = rte_meter_trtcm_color_blind_check(&val[j]->m, val[j]->p,
time, pkt_len);

DLOG(INFO) << "color : " << color << std::endl;
// update ogate to color specific gate
if (color == RTE_COLOR_GREEN) {
ogate = METER_GREEN_GATE;
} else if (color == RTE_COLOR_YELLOW) {
ogate = METER_YELLOW_GATE;
} else if (color == RTE_COLOR_RED) {
ogate = METER_RED_GATE;
}
}
}

Expand Down

0 comments on commit 103b198

Please sign in to comment.