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

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #include <oper/interface.h>
       6             : #include <oper/vm_interface.h>
       7             : #include <oper/physical_interface.h>
       8             : #include <oper/packet_interface.h>
       9             : 
      10           0 : void Interface::ObtainOsSpecificParams(const std::string &name, Agent *agent) {
      11           0 :     os_params_.os_oper_state_ = false;
      12             : 
      13             :     struct ifreq ifr;
      14           0 :     memset(&ifr, 0, sizeof(ifr));
      15           0 :     strncpy(ifr.ifr_name, name.c_str(), IF_NAMESIZE-1);
      16           0 :     int fd = socket(AF_LOCAL, SOCK_STREAM, 0);
      17           0 :     assert(fd >= 0);
      18           0 :     if (ioctl(fd, SIOCGIFHWADDR, (void *)&ifr) < 0) {
      19           0 :         LOG(ERROR, "Error <" << errno << ": " << strerror(errno) <<
      20             :             "> querying mac-address for interface <" << name << "> " <<
      21             :             "Agent-index <" << id_ << ">");
      22           0 :         close(fd);
      23           0 :         return;
      24             :     }
      25             : 
      26           0 :     if (ioctl(fd, SIOCGIFFLAGS, (void *)&ifr) < 0) {
      27           0 :         LOG(ERROR, "Error <" << errno << ": " << strerror(errno) <<
      28             :             "> querying flags for interface <" << name << "> " <<
      29             :             "Agent-index <" << id_ << ">");
      30           0 :         close(fd);
      31           0 :         return;
      32             :     }
      33             : 
      34           0 :     if ((ifr.ifr_flags & (IFF_UP | IFF_RUNNING)) == (IFF_UP | IFF_RUNNING)) {
      35           0 :         os_params_.os_oper_state_ = true;
      36             :     }
      37           0 :     close(fd);
      38             : #if defined(__linux__)
      39           0 :     os_params_.mac_ = ifr.ifr_hwaddr;
      40             :     /* FIXME: Hack till priovisioing code changes for vhost0 */
      41           0 :     if (agent->is_l3mh() && name.compare("vhost0") == 0) {
      42           0 :         os_params_.mac_ = MacAddress::FromString("00:00:5e:00:01:00");
      43             :     }
      44             : #endif
      45             : 
      46           0 :     int idx = if_nametoindex(name.c_str());
      47           0 :     if (idx)
      48           0 :         os_params_.os_index_ = idx;
      49             : }
      50             : 
      51           0 : void VmInterface::ObtainOsSpecificParams(const std::string &name, Agent *agent) {
      52           0 :     Interface::ObtainOsSpecificParams(name, agent);
      53           0 : }
      54             : 
      55           0 : void PhysicalInterface::ObtainOsSpecificParams(const std::string &name, Agent *agent) {
      56           0 :     Interface::ObtainOsSpecificParams(name, agent);
      57           0 : }
      58             : 
      59           0 : void PacketInterface::ObtainOsSpecificParams(const std::string &name, Agent *agent) {
      60           0 :     Interface::ObtainOsSpecificParams(name, agent);
      61           0 : }

Generated by: LCOV version 1.14