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-08-03 02:19:58 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             :  */
       4             : #include "mac_learning_init.h"
       5             : #include "mac_learning_proto.h"
       6             : #include "mac_ip_learning_proto_handler.h"
       7             : 
       8           0 : MacIpLearningProtoHandler::MacIpLearningProtoHandler(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 MacIpLearningProtoHandler::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_IP_LEARNING_TRACE(MacLearningTraceBuf, vrf, pkt_info_->ip_saddr.to_string(),
      28             :                         pkt_info_->smac.ToString(), intf, msg);
      29           0 : }
      30             : 
      31           0 : bool MacIpLearningProtoHandler::Run() {
      32           0 :     intf_ = agent()->interface_table()->
      33           0 :                 FindInterface(pkt_info_->agent_hdr.ifindex);
      34           0 :     if (intf_ == NULL) {
      35           0 :         Log("Invalid interface");
      36           0 :         return true;
      37             :     }
      38             : 
      39           0 :     vrf_ = agent()->vrf_table()->FindVrfFromId(pkt_info_->agent_hdr.vrf);
      40           0 :     if (vrf_ == NULL) {
      41           0 :         Log("Invalid VRF");
      42           0 :         return true;
      43             :     }
      44             : 
      45           0 :     const VmInterface *vm_intf = dynamic_cast<const VmInterface *>(intf_);
      46           0 :     if (vm_intf == NULL) {
      47           0 :         Log("Ingress packet on non-VMI interface");
      48           0 :         return true;
      49             :     }
      50           0 :     uint32_t vrf_id = 0;
      51           0 :     if (pkt_info_->agent_hdr.vrf == 0) {
      52           0 :         vrf_id = vm_intf->vrf_id();
      53             :     } else {
      54           0 :         vrf_id = pkt_info_->agent_hdr.vrf;
      55             :     }
      56           0 :     table_= agent()->mac_learning_proto()->GetMacIpLearningTable();
      57           0 :     entry_.reset(new MacIpLearningEntry(table_, vrf_id,
      58           0 :                                            pkt_info_->ip_saddr,
      59           0 :                                            pkt_info_->smac,
      60           0 :                                            intf_));
      61           0 :     if (entry_.get()) {
      62           0 :         agent()->mac_learning_proto()->GetMacIpLearningTable()->Add(entry_);
      63           0 :         Log("Mac entry added");
      64             :     }
      65             : 
      66           0 :     return true;
      67             : }

Generated by: LCOV version 1.14