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

Generated by: LCOV version 1.14