LCOV - code coverage report
Current view: top level - vnsw/agent/mac_learning - mac_learning_proto_handler.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 62 0.0 %
Date: 2026-08-03 02:19:58 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : #include "mac_learning_init.h"
       5             : #include "mac_learning_proto.h"
       6             : #include "mac_learning_proto_handler.h"
       7             : 
       8           0 : MacLearningProtoHandler::MacLearningProtoHandler(Agent *agent,
       9             :                                                  boost::shared_ptr<PktInfo> info,
      10           0 :                                                  boost::asio::io_context &io):
      11           0 :     ProtoHandler(agent, info, io), intf_(NULL), vrf_(NULL), table_(NULL),
      12           0 :     entry_() {
      13           0 : }
      14             : 
      15           0 : void MacLearningProtoHandler::Log(std::string msg) {
      16             : 
      17           0 :     std::string vrf = "";
      18           0 :     std::string intf = "";
      19           0 :     if (vrf_ != NULL) {
      20           0 :         vrf = vrf_->GetName();
      21             :     }
      22             : 
      23           0 :     if (intf_ != NULL) {
      24           0 :         intf = intf_->name();
      25             :     }
      26             : 
      27           0 :     MAC_LEARNING_TRACE(MacLearningTraceBuf, vrf, pkt_info_->smac.ToString(), intf, msg);
      28           0 : }
      29             : 
      30           0 : void MacLearningProtoHandler::IngressPktHandler() {
      31           0 :     const VmInterface *vm_intf = dynamic_cast<const VmInterface *>(intf_);
      32           0 :     if (vm_intf == NULL) {
      33           0 :         Log("Ingress packet on non-VMI interface");
      34           0 :         return;
      35             :     }
      36             : 
      37           0 :     entry_.reset(new MacLearningEntryLocal(table_, pkt_info_->agent_hdr.vrf,
      38           0 :                                            pkt_info_->smac,
      39           0 :                                            pkt_info_->agent_hdr.cmd_param,
      40           0 :                                            intf_));
      41             : }
      42             : 
      43           0 : void MacLearningProtoHandler::EgressPktHandler() {
      44             :     const PhysicalInterface *p_intf =
      45           0 :         dynamic_cast<const PhysicalInterface *>(intf_);
      46           0 :     if (p_intf == NULL) {
      47           0 :         Log("Invalid packet on physical interface");
      48           0 :         return;
      49             :     }
      50             : 
      51           0 :    if (pkt_info_->pbb_header == NULL) {
      52           0 :         Log("Non PBB packet on physical interface");
      53           0 :         return;
      54             :     }
      55             : 
      56           0 :    std::string bmac_vrf = Agent::NullString();
      57           0 :    if (vrf_->vn() && vrf_->vn()->GetVrf()) {
      58           0 :        bmac_vrf = vrf_->vn()->GetVrf()->GetName();
      59             :    }
      60             : 
      61           0 :     entry_.reset(new MacLearningEntryPBB(table_, pkt_info_->agent_hdr.vrf,
      62           0 :                                          pkt_info_->smac,
      63           0 :                                          pkt_info_->agent_hdr.cmd_param,
      64           0 :                                          pkt_info_->b_smac));
      65           0 : }
      66             : 
      67           0 : bool MacLearningProtoHandler::Run() {
      68           0 :     intf_ = agent()->interface_table()->
      69           0 :                 FindInterface(pkt_info_->agent_hdr.ifindex);
      70           0 :     if (intf_ == NULL) {
      71           0 :         Log("Invalid interface");
      72           0 :         return true;
      73             :     }
      74             : 
      75           0 :     vrf_ = agent()->vrf_table()->FindVrfFromId(pkt_info_->agent_hdr.vrf);
      76           0 :     if (vrf_ == NULL) {
      77           0 :         Log("Invalid VRF");
      78           0 :         return true;
      79             :     }
      80             : 
      81           0 :     uint32_t table_index = agent()->mac_learning_proto()->Hash(
      82           0 :                                pkt_info_->agent_hdr.vrf, pkt_info_->smac);
      83           0 :     table_ = agent()->mac_learning_proto()->Find(table_index);
      84           0 :     if (table_ == NULL) {
      85           0 :         Log("Mac learning table not found");
      86           0 :         return true;
      87             :     }
      88             : 
      89           0 :     if (intf_->type() == Interface::PHYSICAL) {
      90           0 :         EgressPktHandler();
      91             :     } else {
      92           0 :         IngressPktHandler();
      93             :     }
      94             : 
      95           0 :     if (entry_.get()) {
      96           0 :         table_->Add(entry_);
      97           0 :         Log("Mac entry added");
      98             :     }
      99             : 
     100           0 :     return true;
     101             : }

Generated by: LCOV version 1.14