LCOV - code coverage report
Current view: top level - vnsw/agent/pkt - pkt_init.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 50 54 92.6 %
Date: 2026-11-30 02:00:48 Functions: 10 11 90.9 %
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 <io/event_manager.h>
       7             : #include <cmn/agent_cmn.h>
       8             : #include <cmn/agent_factory.h>
       9             : #include "sandesh/sandesh_trace.h"
      10             : #include "pkt/pkt_init.h"
      11             : #include "pkt/pkt_handler.h"
      12             : #include "pkt/proto.h"
      13             : #include "pkt/proto_handler.h"
      14             : #include "pkt/flow_proto.h"
      15             : #include "pkt/flow_table.h"
      16             : #include "pkt/packet_buffer.h"
      17             : #include "pkt/control_interface.h"
      18             : #include "pkt/flow_mgmt.h"
      19             : 
      20             : SandeshTraceBufferPtr PacketTraceBuf(SandeshTraceBufferCreate("Packet", 1000));
      21             : 
      22           1 : PktModule::PktModule(Agent *agent) :
      23           1 :     agent_(agent), control_interface_(NULL),
      24           1 :     pkt_handler_(NULL), flow_proto_(NULL),
      25           2 :     packet_buffer_manager_(new PacketBufferManager(this)) {
      26           1 : }
      27             : 
      28           2 : PktModule::~PktModule() {
      29           2 : }
      30             : 
      31           1 : void PktModule::Init(bool run_with_vrouter) {
      32           1 :     boost::asio::io_context &io = *agent_->event_manager()->io_service();
      33             : 
      34           1 :     pkt_handler_.reset(new PktHandler(agent_, this));
      35             : 
      36           1 :     if (control_interface_) {
      37           1 :         control_interface_->Init(pkt_handler_.get());
      38             :     }
      39             : 
      40           1 :     flow_proto_.reset(new FlowProto(agent_, io));
      41           1 :     flow_proto_->Init();
      42             : 
      43           1 :     uint16_t table_count = agent_->flow_thread_count();
      44           2 :     for (uint8_t i = 0; i < table_count; i++) {
      45           1 :         flow_mgmt_manager_list_.push_back(new FlowMgmtManager(agent_, i));
      46           1 :         flow_mgmt_manager_list_[i]->Init();
      47             :     }
      48           1 :     FlowMgmtManager::InitLogQueue(agent_);
      49           1 : }
      50             : 
      51           1 : void PktModule::InitDone() {
      52           1 :     flow_proto_->InitDone();
      53           1 : }
      54             : 
      55           1 : void PktModule::set_control_interface(ControlInterface *intf) {
      56           1 :     control_interface_ = intf;
      57           1 : }
      58             : 
      59           1 : void PktModule::Shutdown() {
      60           1 :     flow_proto_->Shutdown();
      61           1 :     flow_proto_.reset(NULL);
      62             : 
      63           1 :     control_interface_->Shutdown();
      64           1 :     control_interface_ = NULL;
      65             : 
      66           1 :     FlowMgmtManagerList::iterator it = flow_mgmt_manager_list_.begin();
      67           2 :     while (it != flow_mgmt_manager_list_.end()) {
      68           1 :         (*it)->Shutdown();
      69           1 :         it++;
      70             :     }
      71             : 
      72           1 :     STLDeleteValues(&flow_mgmt_manager_list_);
      73           1 :     FlowMgmtManager::ShutdownLogQueue();
      74           1 : }
      75             : 
      76           1 : void PktModule::IoShutdown() {
      77           1 :     control_interface_->IoShutdown();
      78           1 : }
      79             : 
      80           1 : void PktModule::FlushFlows() {
      81           1 :     flow_proto_->FlushFlows();
      82           1 : }
      83             : 
      84           1 : void PktModule::CreateInterfaces() {
      85           1 :     if (control_interface_ == NULL)
      86           0 :         return;
      87             : 
      88           1 :     Interface::Transport transport = Interface::TRANSPORT_ETHERNET;
      89           1 :     if (agent_->vrouter_on_host_dpdk()) {
      90           0 :         transport = Interface::TRANSPORT_SOCKET;
      91             :     }
      92             : 
      93           1 :     PacketInterface::Create(agent_->interface_table(),
      94           1 :                             control_interface_->Name(),
      95             :                             transport);
      96             : }
      97             : 
      98           0 : FlowTable *PktModule::flow_table(uint16_t index) const {
      99           0 :     return flow_proto_->GetTable(index);
     100             : }

Generated by: LCOV version 1.14