@@ -41,6 +41,9 @@ const char* LABEL_DIRECTION = "direction";
4141const char * DIRECTION_UP = " up" ;
4242const char * DIRECTION_DOWN = " down" ;
4343const char * LABEL_SESSION_ID = " session_id" ;
44+ // TODO(@themarwhal): SessionD should own the naming of the drop all rule so
45+ // that we never regress here
46+ const char * DROP_ALL_RULE = " internal_default_drop_flow_rule" ;
4447} // namespace
4548
4649using magma::service303::increment_counter;
@@ -477,42 +480,50 @@ optional<RuleStats> SessionState::get_rule_delta(
477480 const std::string& rule_id, uint64_t rule_version, uint64_t used_tx,
478481 uint64_t used_rx, uint64_t dropped_tx, uint64_t dropped_rx,
479482 SessionStateUpdateCriteria* session_uc) {
480- auto it = policy_version_and_stats_.find (rule_id);
481- if (it == policy_version_and_stats_.end ()) {
482- MLOG (MERROR) << " Reported rule (" << rule_id << " ) not found, ignoring" ;
483+ // TODO(@koolzz): Handle drop all stats properly GH7143
484+ if (policy_version_and_stats_.find (rule_id) ==
485+ policy_version_and_stats_.end ()) {
486+ if (rule_id.compare (DROP_ALL_RULE)) {
487+ // Only log if it's not the drop all rule
488+ MLOG (MERROR) << " Reported rule (" << rule_id << " ) not found in "
489+ << session_id_ << " , ignoring" ;
490+ }
483491 return {};
484492 }
485493
486- RuleStats ret = RuleStats ();
494+ RuleStats ret = RuleStats ();
495+ StatsPerPolicy& stats = policy_version_and_stats_[rule_id];
487496 // Only accept rule reports for current_version or last_reported_version
488497 // ignore other reports as they shoudn't be sent
489- auto last_reported_version = it-> second .last_reported_version ;
490- if (rule_version > it-> second .current_version ) {
491- MLOG (MERROR ) << " Reported version higher than tracked one("
492- << it-> second .current_version << " ) for "
493- << " Rule_id : " << rule_id << " version: " << rule_version;
498+ auto last_reported_version = stats .last_reported_version ;
499+ if (rule_version > stats .current_version ) {
500+ MLOG (MWARNING ) << " Reported version higher than tracked one("
501+ << stats .current_version << " ) for " << session_id_
502+ << " , rule_id : " << rule_id << " , version: " << rule_version;
494503 return ret;
495504 }
496505
497506 if (rule_version < last_reported_version) {
498- MLOG (MERROR ) << " Reported rule version too old, current one("
499- << it-> second .current_version << " ) for "
500- << " Rule_id : " << rule_id << " version: " << rule_version;
507+ MLOG (MWARNING ) << " Reported rule version too old, current one("
508+ << stats .current_version << " ) for " << session_id_
509+ << " , rule_id : " << rule_id << " , version: " << rule_version;
501510 return ret;
502511 }
503512
504- auto last_tracked =
505- policy_version_and_stats_[rule_id].stats_map .find (last_reported_version);
506-
507- RuleStats prev_usage = last_tracked->second ;
508-
513+ RuleStats prev_usage = stats.stats_map [last_reported_version];
509514 if (rule_version == last_reported_version) {
510515 if (prev_usage.tx != 0 && prev_usage.tx > used_tx) {
511- MLOG (MERROR) << " Reported stat used_tx less than the current tracked one" ;
516+ MLOG (MWARNING)
517+ << " Reported stat used_tx is less than the current tracked one for "
518+ << session_id_ << " , rule_id: " << rule_id
519+ << " , version: " << rule_version;
512520 return ret;
513521 }
514522 if (prev_usage.rx != 0 && prev_usage.rx > used_rx) {
515- MLOG (MERROR) << " Reported stat used_rx less than the current tracked one" ;
523+ MLOG (MWARNING)
524+ << " Reported stat used_rx is less than the current tracked one for "
525+ << session_id_ << " , rule_id: " << rule_id
526+ << " , version: " << rule_version;
516527 return ret;
517528 }
518529
0 commit comments