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-09 02:10:49 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           2 : PktModule::PktModule(Agent *agent) :
      23           2 :     agent_(agent), control_interface_(NULL),
      24           2 :     pkt_handler_(NULL), flow_proto_(NULL),
      25           4 :     packet_buffer_manager_(new PacketBufferManager(this)) {
      26           2 : }
      27             : 
      28           4 : PktModule::~PktModule() {
      29           4 : }
      30             : 
      31           2 : void PktModule::Init(bool run_with_vrouter) {
      32           2 :     boost::asio::io_context &io = *agent_->event_manager()->io_service();
      33             : 
      34           2 :     pkt_handler_.reset(new PktHandler(agent_, this));
      35             : 
      36           2 :     if (control_interface_) {
      37           2 :         control_interface_->Init(pkt_handler_.get());
      38             :     }
      39             : 
      40           2 :     flow_proto_.reset(new FlowProto(agent_, io));
      41           2 :     flow_proto_->Init();
      42             : 
      43           2 :     uint16_t table_count = agent_->flow_thread_count();
      44           4 :     for (uint8_t i = 0; i < table_count; i++) {
      45           2 :         flow_mgmt_manager_list_.push_back(new FlowMgmtManager(agent_, i));
      46           2 :         flow_mgmt_manager_list_[i]->Init();
      47             :     }
      48           2 :     FlowMgmtManager::InitLogQueue(agent_);
      49           2 : }
      50             : 
      51           2 : void PktModule::InitDone() {
      52           2 :     flow_proto_->InitDone();
      53           2 : }
      54             : 
      55           2 : void PktModule::set_control_interface(ControlInterface *intf) {
      56           2 :     control_interface_ = intf;
      57           2 : }
      58             : 
      59           2 : void PktModule::Shutdown() {
      60           2 :     flow_proto_->Shutdown();
      61           2 :     flow_proto_.reset(NULL);
      62             : 
      63           2 :     control_interface_->Shutdown();
      64           2 :     control_interface_ = NULL;
      65             : 
      66           2 :     FlowMgmtManagerList::iterator it = flow_mgmt_manager_list_.begin();
      67           4 :     while (it != flow_mgmt_manager_list_.end()) {
      68           2 :         (*it)->Shutdown();
      69           2 :         it++;
      70             :     }
      71             : 
      72           2 :     STLDeleteValues(&flow_mgmt_manager_list_);
      73           2 :     FlowMgmtManager::ShutdownLogQueue();
      74           2 : }
      75             : 
      76           2 : void PktModule::IoShutdown() {
      77           2 :     control_interface_->IoShutdown();
      78           2 : }
      79             : 
      80           2 : void PktModule::FlushFlows() {
      81           2 :     flow_proto_->FlushFlows();
      82           2 : }
      83             : 
      84           2 : void PktModule::CreateInterfaces() {
      85           2 :     if (control_interface_ == NULL)
      86           0 :         return;
      87             : 
      88           2 :     Interface::Transport transport = Interface::TRANSPORT_ETHERNET;
      89           2 :     if (agent_->vrouter_on_host_dpdk()) {
      90           0 :         transport = Interface::TRANSPORT_SOCKET;
      91             :     }
      92             : 
      93           2 :     PacketInterface::Create(agent_->interface_table(),
      94           2 :                             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