LCOV - code coverage report
Current view: top level - vnsw/agent/uve - vm_uve_entry.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 19 47 40.4 %
Date: 2026-11-09 02:10:49 Functions: 4 7 57.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #include <uve/vm_uve_entry.h>
       7             : #include <uve/interface_uve_stats_table.h>
       8             : #include <uve/agent_uve.h>
       9             : 
      10             : using namespace std;
      11             : 
      12         332 : VmUveEntry::VmUveEntry(Agent *agent, const string &vm_name)
      13         332 :     : VmUveEntryBase(agent, vm_name), port_bitmap_() {
      14         332 : }
      15             : 
      16         332 : VmUveEntry::~VmUveEntry() {
      17         332 : }
      18             : 
      19         142 : void VmUveEntry::UpdatePortBitmap(uint8_t proto, uint16_t sport,
      20             :                                   uint16_t dport) {
      21         142 :     std::scoped_lock lock(mutex_);
      22         142 :     if (deleted_ && !renewed_) {
      23             :         /* Skip updates on VmUveEntry if it is marked for delete */
      24           0 :         return;
      25             :     }
      26             :     //Update VM bitmap
      27         142 :     port_bitmap_.AddPort(proto, sport, dport);
      28             : 
      29             :     InterfaceUveStatsTable *table = static_cast<InterfaceUveStatsTable *>
      30         142 :         (agent_->uve()->interface_uve_table());
      31             :     //Update vm interfaces bitmap
      32         142 :     InterfaceSet::iterator it = interface_tree_.begin();
      33         292 :     while(it != interface_tree_.end()) {
      34         150 :         table->UpdatePortBitmap(*it, proto, sport, dport);
      35         150 :         ++it;
      36             :     }
      37         142 : }
      38             : 
      39           0 : bool VmUveEntry::SetVmPortBitmap(UveVirtualMachineAgent *uve) {
      40           0 :     bool changed = false;
      41           0 :     std::scoped_lock lock(mutex_);
      42             : 
      43           0 :     vector<uint32_t> tcp_sport;
      44           0 :     if (port_bitmap_.tcp_sport_.Sync(tcp_sport)) {
      45           0 :         uve->set_tcp_sport_bitmap(tcp_sport);
      46           0 :         changed = true;
      47             :     }
      48             : 
      49           0 :     vector<uint32_t> tcp_dport;
      50           0 :     if (port_bitmap_.tcp_dport_.Sync(tcp_dport)) {
      51           0 :         uve->set_tcp_dport_bitmap(tcp_dport);
      52           0 :         changed = true;
      53             :     }
      54             : 
      55           0 :     vector<uint32_t> udp_sport;
      56           0 :     if (port_bitmap_.udp_sport_.Sync(udp_sport)) {
      57           0 :         uve->set_udp_sport_bitmap(udp_sport);
      58           0 :         changed = true;
      59             :     }
      60             : 
      61           0 :     vector<uint32_t> udp_dport;
      62           0 :     if (port_bitmap_.udp_dport_.Sync(udp_dport)) {
      63           0 :         uve->set_udp_dport_bitmap(udp_dport);
      64           0 :         changed = true;
      65             :     }
      66           0 :     return changed;
      67           0 : }
      68             : 
      69           0 : bool VmUveEntry::FrameVmStatsMsg(UveVirtualMachineAgent *uve) {
      70           0 :     bool changed = false;
      71           0 :     uve->set_name(vm_config_name());
      72             : 
      73           0 :     if (SetVmPortBitmap(uve)) {
      74           0 :         changed = true;
      75             :     }
      76             : 
      77           0 :     return changed;
      78             : }
      79             : 
      80         165 : void VmUveEntry::Reset() {
      81         165 :     VmUveEntryBase::Reset();
      82         165 :     port_bitmap_.Reset();
      83         165 : }

Generated by: LCOV version 1.14