LCOV - code coverage report
Current view: top level - vnsw/agent/mac_learning - mac_ip_learning_proto_handler.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 41 0.0 %
Date: 2026-11-09 02:10:49 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2020 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : #include "mac_learning_init.h"
       6             : #include "mac_learning_proto.h"
       7             : #include "mac_ip_learning_proto_handler.h"
       8             : 
       9           0 : MacIpLearningProtoHandler::MacIpLearningProtoHandler(Agent *agent,
      10             :                                                  boost::shared_ptr<PktInfo> info,
      11           0 :                                                  boost::asio::io_context &io):
      12           0 :     ProtoHandler(agent, info, io), intf_(NULL), vrf_(NULL), table_(NULL),
      13           0 :     entry_() {
      14           0 : }
      15             : 
      16           0 : void MacIpLearningProtoHandler::Log(std::string msg) {
      17             : 
      18           0 :     std::string vrf = "";
      19           0 :     std::string intf = "";
      20           0 :     if (vrf_ != NULL) {
      21           0 :         vrf = vrf_->GetName();
      22             :     }
      23             : 
      24           0 :     if (intf_ != NULL) {
      25           0 :         intf = intf_->name();
      26             :     }
      27             : 
      28           0 :     MAC_IP_LEARNING_TRACE(MacLearningTraceBuf, vrf, pkt_info_->ip_saddr.to_string(),
      29             :                         pkt_info_->smac.ToString(), intf, msg);
      30           0 : }
      31             : 
      32           0 : bool MacIpLearningProtoHandler::Run() {
      33           0 :     intf_ = agent()->interface_table()->
      34           0 :                 FindInterface(pkt_info_->agent_hdr.ifindex);
      35           0 :     if (intf_ == NULL) {
      36           0 :         Log("Invalid interface");
      37           0 :         return true;
      38             :     }
      39             : 
      40           0 :     vrf_ = agent()->vrf_table()->FindVrfFromId(pkt_info_->agent_hdr.vrf);
      41           0 :     if (vrf_ == NULL) {
      42           0 :         Log("Invalid VRF");
      43           0 :         return true;
      44             :     }
      45             : 
      46           0 :     const VmInterface *vm_intf = dynamic_cast<const VmInterface *>(intf_);
      47           0 :     if (vm_intf == NULL) {
      48           0 :         Log("Ingress packet on non-VMI interface");
      49           0 :         return true;
      50             :     }
      51           0 :     uint32_t vrf_id = 0;
      52           0 :     if (pkt_info_->agent_hdr.vrf == 0) {
      53           0 :         vrf_id = vm_intf->vrf_id();
      54             :     } else {
      55           0 :         vrf_id = pkt_info_->agent_hdr.vrf;
      56             :     }
      57           0 :     table_= agent()->mac_learning_proto()->GetMacIpLearningTable();
      58           0 :     entry_.reset(new MacIpLearningEntry(table_, vrf_id,
      59           0 :                                            pkt_info_->ip_saddr,
      60           0 :                                            pkt_info_->smac,
      61           0 :                                            intf_));
      62           0 :     if (entry_.get()) {
      63           0 :         agent()->mac_learning_proto()->GetMacIpLearningTable()->Add(entry_);
      64           0 :         Log("Mac entry added");
      65             :     }
      66             : 
      67           0 :     return true;
      68             : }

Generated by: LCOV version 1.14