LCOV - code coverage report
Current view: top level - vnsw/agent/oper - vm_interface.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 213 307 69.4 %
Date: 2026-06-04 02:06:09 Functions: 129 185 69.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #ifndef vnsw_agent_vm_interface_hpp
       6             : #define vnsw_agent_vm_interface_hpp
       7             : 
       8             : #include <atomic>
       9             : 
      10             : #include <oper/oper_dhcp_options.h>
      11             : #include <oper/audit_list.h>
      12             : #include <oper/ecmp_load_balance.h>
      13             : /////////////////////////////////////////////////////////////////////////////
      14             : // VmInterface is implementation of VM Port interfaces
      15             : //
      16             : // All modification to an VmInterface is done only thru the DBTable Request
      17             : // handling.
      18             : //
      19             : // The DBTable request can be generated from multiple events.
      20             : // Example : Config update, link-state change, port-ipc message etc.
      21             : //
      22             : // Only two types of DBTable request can create/delete a VmInterface
      23             : // - VmInterfaceConfigData :
      24             : //   This request type is generated from config processing
      25             : //   Request of this type of mandatory for all interfaces
      26             : // - VmInterfaceNovaData :
      27             : //   This request type is generated from port-ipc messages to agent
      28             : //   Request of this type are optional
      29             : //
      30             : // An VmInterface can be of many types. Different type of VmInterfaces with
      31             : // corresponding values of DeviceType and VmiType are given below,
      32             : //
      33             : // DeviceType = VM_ON_TAP, VmiType = INSTANCE
      34             : //   Typically represents an interface inside a VM/Container.
      35             : //   Examples:QEMU VM, Containers, Service-Chain interface etc.
      36             : //   It will have a TAP interface associated with it. The interface be
      37             : //   created only by port-ipc message. The config message only updates the
      38             : //   attributes and does not create interface of this type
      39             : //
      40             : // DeviceType = VM_PHYSICAL_VLAN, VmiType = INTANCE
      41             : //   This configuration is used in case of VmWare ESXi.
      42             : //   Each ESXi VM is assigned a VLAN (by nova-compute). The compute node has
      43             : //   an uplink port that is member of all VLANs. Agent/VRouter can identify
      44             : //   VmInterface by tuple <uplink-port, vlan>. The uplink port is seen as a
      45             : //   phyiscal port on compute node
      46             : //   The agent->hypervisor_mode_ is also set to ESXi in this case
      47             : //
      48             : // DeviceType = VM_PHYSICAL_MAC, VmiType = INTANCE and
      49             : //   This configuration is used in VmWare VCenter
      50             : //   VCenter:
      51             : //     Contrail uses distributed vswitch to support VCenter. Each VN is
      52             : //     allocated a PVLAN. The port on compute node is member of primary-vlan
      53             : //     and VMs are member of secondary-vlans. Packets from all VMs are
      54             : //     received on primary-vlan on compute node, hence they are classified
      55             : //     using source-mac address (which is unique to every VM)
      56             : //     agent->hypervisor_mode_ is set to VCENTER
      57             : // DeviceType = LOCAL_DEVICE, VmiType = GATEWAY
      58             : //   This configuraiton is used in case of Gateway interfaces connected locally
      59             : //
      60             : // DeviceType = REMOTE_VM_VLAN_ON_VMI, VmiType = REMOTE_VM
      61             : //   This configuration is used to model an end-point connected on local
      62             : //   interface
      63             : //   The VmInterface is classified based on vlan-tag of packet
      64             : //
      65             : // DeviceType = TOR, VmiType = BAREMETAL
      66             : //   This configuration is used to model ToR ports managed with OVS
      67             : //
      68             : // DeviceType = VM_VLAN_ON_VMI, VmiType = INSTANCE
      69             : //   This configuration is used to model vlan sub-interfaces and
      70             : //   Nested Containers (both K8S and Mesos)
      71             : //   Sub-Interfaces:
      72             : //     Typically, the sub-interfaces are created over other VmInterfaces with
      73             : //     DeviceType = VM_ON_TAP
      74             : //     The VmInterface is classified based on vlan-tag
      75             : //
      76             : //   Nested Containers:
      77             : //     In case of nested-containers, the first level Container ports are
      78             : //     created as regular tap-interfaces. The second level containers are
      79             : //     created as MAC-VLAN ports. Since all second level containers share same
      80             : //     tap-interface, they are classified using vlan-tag
      81             : //
      82             : // DBRequest Handling
      83             : // ------------------
      84             : // All DBRequest are handed off to VmInterface module via methods
      85             : // VmInterface::Add() and VmInterface::Delete(). VmInterface modules processes
      86             : // request in following stages,
      87             : // 1. Config Processing
      88             : //    This stage is responsible to update VmInterface fields with latest
      89             : //    information according. The fields updated will depend on type of
      90             : //    request.
      91             : //
      92             : //    Every DBRequest type implements a method "OnResync". This method must
      93             : //    update VmInterface fields according to the request
      94             : //    The same OnResync() is called for both "Add", "Change" and "Resync"
      95             : //    operation
      96             : //
      97             : // 2. Apply Config
      98             : //    This stage is responsible to generated other oper-db states including
      99             : //    MPLS Labels, NextHops, Routes etc... based on the latest configuration
     100             : //    It must also take care of removing derived states based on old-state
     101             : //
     102             : //    VmInterfaceState() class is responsible to manage derived states
     103             : //    such as routes, nexthops, labels etc...).
     104             : //    old states and create new states based on latest interface configuration
     105             : /////////////////////////////////////////////////////////////////////////////
     106             : 
     107             : typedef std::vector<boost::uuids::uuid> SgUuidList;
     108             : typedef std::vector<SgEntryRef> SgList;
     109             : typedef std::vector<AclDBEntryConstRef> FirewallPolicyList;
     110             : struct VmInterfaceData;
     111             : struct VmInterfaceConfigData;
     112             : struct VmInterfaceNovaData;
     113             : struct VmInterfaceIpAddressData;
     114             : struct VmInterfaceOsOperStateData;
     115             : struct VmInterfaceMirrorData;
     116             : class OperDhcpOptions;
     117             : class PathPreference;
     118             : class MetaDataIp;
     119             : class HealthCheckInstanceBase;
     120             : struct VmInterfaceLearntMacIpData;
     121             : 
     122             : class LocalVmPortPeer;
     123             : class VmInterface;
     124             : 
     125             : /////////////////////////////////////////////////////////////////////////////
     126             : // VmInterfaceState manages dervied states from VmInterface. On any config
     127             : // change to interface, this VmInterfaceState gets invoked after modifying
     128             : // VmInterface with latest configuration. Each VmInterfaceState must be
     129             : // self-contained and idempotent. The class must store old variables it needs.
     130             : //
     131             : // There are 2 type of states managed by the class L2-State (EVPN-Route,
     132             : // L2-NextHop etc..) and L3-State(inet-route, l3-nexthop etc...). The class
     133             : // assumes each both L2 and L3 states are managed by each attribute. However,
     134             : // one of them can be dummy as necessary
     135             : //
     136             : // The class supports 3 different operations,
     137             : // - ADD : Must Add state resulting from this attribute
     138             : // - DEL : Must Delete state resulting from this attribute
     139             : // - DEL_ADD :
     140             : //   DEL_ADD operation results if there is change in key for the state
     141             : //   resulting from the attribute. In this case, the old state must be
     142             : //   Delete and then followed by Addd of state
     143             : //
     144             : // Guildelines for GetOpL2 and GetOpL3:
     145             : // - Compute DEL cases
     146             : // - Compute DEL_ADD cases next
     147             : // - Compute ADD cases last
     148             : // - Return INVALID to ignore the operation
     149             : //
     150             : // The DEL operation must be based on latest configuration on interface
     151             : // The ADD operation must be based on latest configuration on interface
     152             : // The DEL_ADD operation must be based on old values stored in the class and
     153             : // latest value in the interface
     154             : /////////////////////////////////////////////////////////////////////////////
     155             : struct VmInterfaceState {
     156             :     // Keep order of Operation in enum sorted. RecomputeOp relies on it
     157             :     enum Op {
     158             :         INVALID,
     159             :         ADD,
     160             :         DEL_ADD,
     161             :         DEL
     162             :     };
     163             : 
     164       30290 :     explicit VmInterfaceState() :
     165       30290 :         l2_installed_(false), l3_installed_(false) {
     166       30290 :     }
     167         428 :     VmInterfaceState(bool l2_installed, bool l3_installed) :
     168         428 :         l2_installed_(l2_installed), l3_installed_(l3_installed) {
     169         428 :     }
     170       30718 :     virtual ~VmInterfaceState() {
     171       30718 :     }
     172             : 
     173           0 :     bool Installed() const {
     174           0 :         return l3_installed_ || l2_installed_;
     175             :     }
     176             : 
     177             :     virtual bool Update(const Agent *agent, VmInterface *vmi,
     178             :                         Op l2_force_op, Op l3_force_op) const;
     179             : 
     180             :     // Update Operation. In cases where operations are computed in stages,
     181             :     // computes operation based on old value and new value
     182             :     static Op RecomputeOp(Op old_op, Op new_op);
     183             : 
     184             :     // Get operation for Layer-2 state. Generally,
     185             :     // ADD/DEL operaton are based on current state of VmInterface
     186             :     // ADD_DEL operation is based on old-value and new value in VmInterface
     187         454 :     virtual Op GetOpL2(const Agent *agent, const VmInterface *vmi) const {
     188         454 :         return INVALID;
     189             :     }
     190             : 
     191             :     // Get operation for Layer-3 state. Generally,
     192             :     // ADD/DEL operaton are based on current state of VmInterface
     193             :     // ADD_DEL operation is based on old-value and new value in VmInterface
     194           0 :     virtual Op GetOpL3(const Agent *agent, const VmInterface *vmi) const {
     195           0 :         return INVALID;
     196             :     }
     197             : 
     198             :     // Copy attributes from VmInterface to local copy
     199         446 :     virtual void Copy(const Agent *agent, const VmInterface *vmi) const {
     200         446 :         return;
     201             :     }
     202             : 
     203           0 :     virtual bool AddL2(const Agent *agent, VmInterface *vmi) const {
     204           0 :         assert(0);
     205             :         return false;
     206             :     }
     207             : 
     208           0 :     virtual bool DeleteL2(const Agent *agent, VmInterface *vmi) const {
     209           0 :         assert(0);
     210             :         return false;
     211             :     }
     212             : 
     213           0 :     virtual bool AddL3(const Agent *agent, VmInterface *vmi) const {
     214           0 :         assert(0);
     215             :         return false;
     216             :     }
     217             : 
     218           0 :     virtual bool DeleteL3(const Agent *agent, VmInterface *vmi) const {
     219           0 :         assert(0);
     220             :         return false;
     221             :     }
     222             : 
     223             :     mutable bool l2_installed_;
     224             :     mutable bool l3_installed_;
     225             : };
     226             : 
     227             : struct MacVmBindingState : public VmInterfaceState {
     228             :     MacVmBindingState();
     229             :     virtual ~MacVmBindingState();
     230             : 
     231             :     VmInterfaceState::Op GetOpL3(const Agent *agent,
     232             :                                  const VmInterface *vmi) const;
     233             :     bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     234             :     void Copy(const Agent *agent, const VmInterface *vmi) const;
     235             :     bool AddL3(const Agent *agent, VmInterface *vmi) const;
     236             : 
     237             :     mutable const VrfEntry *vrf_;
     238             :     mutable bool dhcp_enabled_;
     239             :     mutable bool dhcp_enabled_v6_;
     240             : };
     241             : 
     242             : struct VrfTableLabelState : public VmInterfaceState {
     243             :     VrfTableLabelState();
     244             :     virtual ~VrfTableLabelState();
     245             : 
     246             :     VmInterfaceState::Op GetOpL3(const Agent *agent,
     247             :                                  const VmInterface *vmi) const;
     248             :     bool AddL3(const Agent *agent, VmInterface *vmi) const;
     249             : };
     250             : 
     251             : struct NextHopState : public VmInterfaceState {
     252             :     NextHopState();
     253             :     virtual ~NextHopState();
     254             : 
     255             :     VmInterfaceState::Op GetOpL2(const Agent *agent,
     256             :                                  const VmInterface *vmi) const;
     257             :     bool DeleteL2(const Agent *agent, VmInterface *vmi) const;
     258             :     bool AddL2(const Agent *agent, VmInterface *vmi) const;
     259             : 
     260             :     VmInterfaceState::Op GetOpL3(const Agent *agent,
     261             :                                  const VmInterface *vmi) const;
     262             :     bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     263             :     bool AddL3(const Agent *agent, VmInterface *vmi) const;
     264             : 
     265         220 :     uint32_t l2_label() const { return l2_label_; }
     266         220 :     uint32_t l3_label() const { return l3_label_; }
     267             : 
     268             :     mutable NextHopRef l2_nh_policy_;
     269             :     mutable NextHopRef l2_nh_no_policy_;
     270             :     mutable uint32_t l2_label_;
     271             : 
     272             :     mutable NextHopRef l3_nh_policy_;
     273             :     mutable NextHopRef l3_nh_no_policy_;
     274             :     mutable uint32_t l3_label_;
     275             : 
     276             :     mutable NextHopRef l3_mcast_nh_no_policy_;
     277             : 
     278             :     mutable NextHopRef receive_nh_;
     279             : };
     280             : 
     281             : struct MetaDataIpState : public VmInterfaceState {
     282             : 
     283             :     /// @brief Creates a new instance of MetaDataIpState.
     284             :     MetaDataIpState(bool ipv4 = true);
     285             :     virtual ~MetaDataIpState();
     286             : 
     287             :     VmInterfaceState::Op GetOpL3(const Agent *agent,
     288             :                                  const VmInterface *vmi) const;
     289             :     bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     290             :     bool AddL3(const Agent *agent, VmInterface *vmi) const;
     291             : 
     292             :     mutable std::unique_ptr<MetaDataIp> mdata_ip_;
     293             :     bool ipv4_;
     294             : };
     295             : 
     296             : struct ResolveRouteState : public VmInterfaceState {
     297             :     ResolveRouteState();
     298             :     virtual ~ResolveRouteState();
     299             : 
     300             :     VmInterfaceState::Op GetOpL2(const Agent *agent,
     301             :                                  const VmInterface *vmi) const;
     302             :     bool DeleteL2(const Agent *agent, VmInterface *vmi) const;
     303             :     bool AddL2(const Agent *agent, VmInterface *vmi) const;
     304             :     VmInterfaceState::Op GetOpL3(const Agent *agent,
     305             :                                  const VmInterface *vmi) const;
     306             :     bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     307             :     bool AddL3(const Agent *agent, VmInterface *vmi) const;
     308             :     void Copy(const Agent *agent, const VmInterface *vmi) const;
     309             : 
     310             :     mutable const VrfEntry *vrf_;
     311             :     mutable Ip4Address subnet_;
     312             :     mutable uint8_t plen_;
     313             : };
     314             : 
     315             : struct VmiRouteState : public VmInterfaceState {
     316             :     VmiRouteState();
     317             :     virtual ~VmiRouteState();
     318             : 
     319             :     VmInterfaceState::Op GetOpL2(const Agent *agent,
     320             :                                  const VmInterface *vmi) const;
     321             :     bool DeleteL2(const Agent *agent, VmInterface *vmi) const;
     322             :     bool AddL2(const Agent *agent, VmInterface *vmi) const;
     323             :     VmInterfaceState::Op GetOpL3(const Agent *agent,
     324             :                                  const VmInterface *vmi) const;
     325             :     bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     326             :     bool AddL3(const Agent *agent, VmInterface *vmi) const;
     327             :     void Copy(const Agent *agent, const VmInterface *vmi) const;
     328             : 
     329             :     mutable const VrfEntry *vrf_;
     330             :     mutable Ip4Address ip_;
     331             :     mutable uint32_t ethernet_tag_;
     332             :     mutable bool do_dhcp_relay_;
     333             : };
     334             : 
     335             : /////////////////////////////////////////////////////////////////////////////
     336             : // Definition for VmInterface
     337             : // Agent supports multiple type of VMInterfaces
     338             : // - VMI for a virtual-machine spawned on KVM compute node. It will have a TAP
     339             : //   interface associated with it. Agent also expects a INSTANCE_MSG from
     340             : //    nova-compute/equivalent to add this port
     341             : //    DeviceType = VM_ON_TAP, VmiType = INSTANCE
     342             : // - VMI for a virtual-machine spawned on VMware ESXi. All virtual-machines
     343             : //   are connected on a physical-port and VLAN is used to distinguish them
     344             : //   DeviceType = VM_PHYSICAL_VLAN, VmiType = INTANCE, agent->hypervisor_mode = ESXi
     345             : // - VMI for a virtual-machine spawned on VMWare VCenter . All virtual-machines
     346             : //   are connected on a physical-port and they are classified by the smac
     347             : //   DeviceType = VM_PHYSICAL_MAC, VmiType = INTANCE and
     348             : //   agent hypervisor mode = VCenter
     349             : // - VMI for service-chain virtual-machines
     350             : // - VMI for service-chain virtual-machine spawned on KVM compute node.
     351             : //   It will have a TAP interface associated with it. Agent also expects a
     352             : //   INSTANCE_MSG from interface associated with it.
     353             : //   DeviceType = VM_ON_TAP, VmiType = SERVICE_CHAIN
     354             : // - VMI for service-instances spawned by agent itself.
     355             : //   It will have a TAP interface associated with it. Agent also expects a
     356             : //   INSTANCE_MSG from interface associated with it.
     357             : //   DeviceType = VM, VmiType = SERVICE_INTANCE
     358             : //
     359             : /////////////////////////////////////////////////////////////////////////////
     360             : class VmInterface : public Interface {
     361             : public:
     362             :     static const uint32_t kInvalidVlanId = 0xFFFF;
     363             :     static const uint32_t kInvalidPmdId = 0xFFFF;
     364             :     static const uint32_t kInvalidIsid = 0xFFFFFF;
     365             :     static const uint8_t vHostUserClient = 0;
     366             :     static const uint8_t vHostUserServer = 1;
     367             :     static const uint32_t kMaxMacIpLimit = 50;
     368             : 
     369             :     // Interface route type
     370             :     static const char *kInterface;
     371             :     static const char *kServiceInterface;
     372             :     static const char *kInterfaceStatic;
     373             : 
     374             :     enum Configurer {
     375             :         INSTANCE_MSG,
     376             :         CONFIG
     377             :     };
     378             : 
     379             :     // Type of VMI Port
     380             :     enum DeviceType {
     381             :         DEVICE_TYPE_INVALID,
     382             :         VM_ON_TAP,          // VMI on TAP/physial port interface
     383             :                             // VMI is created based on the INSTANCE_MSG
     384             :         VM_VLAN_ON_VMI,     // VMI on TAP port with VLAN as classifier
     385             :                             // VMI is created based on config message
     386             :         VM_PHYSICAL_VLAN,   // VMI classified with VLAN on a physical-port
     387             :                             // (used in VMWare ESXi)
     388             :                             // VMI is created based on the INSTANCE_MSG
     389             :         VM_PHYSICAL_MAC,    // VMI classified with MAC on a physical-port
     390             :                             // (used in VMWare VCenter)
     391             :                             // VMI is created based on the INSTANCE_MSG
     392             :         TOR,                // Baremetal connected to ToR
     393             :         LOCAL_DEVICE,       // VMI on a local port. Used in GATEWAY
     394             :         REMOTE_VM_VLAN_ON_VMI, // VMI on a local phy-port with VLAN as classifier
     395             :         VM_SRIOV,           // VMI on an SRIOV VM
     396             :         VMI_ON_LR           // VMI configured on logical-router
     397             :     };
     398             : 
     399             :     // Type of VM on the VMI
     400             :     enum VmiType {
     401             :         VMI_TYPE_INVALID,
     402             :         INSTANCE,
     403             :         SERVICE_CHAIN,
     404             :         SERVICE_INSTANCE,
     405             :         BAREMETAL,
     406             :         GATEWAY,
     407             :         REMOTE_VM,
     408             :         SRIOV,
     409             :         VHOST,
     410             :         ROUTER
     411             :     };
     412             : 
     413             :     // Interface uses different type of labels. Enumeration of different
     414             :     // types is given below
     415             :     enum LabelType {
     416             :         LABEL_TYPE_INVALID = 0,
     417             :         LABEL_TYPE_L2,
     418             :         LABEL_TYPE_L3,
     419             :         LABEL_TYPE_AAP,
     420             :         LABEL_TYPE_SERVICE_VLAN,
     421             :         LABEL_TYPE_MAX
     422             :     };
     423             : 
     424             :     enum ProxyArpMode {
     425             :         PROXY_ARP_NONE,
     426             :         PROXY_ARP_UNRESTRICTED,
     427             :         PROXY_ARP_INVALID
     428             :     };
     429             : 
     430             :     /*
     431             :      * NOTE: This value should be in sync with vrouter code.
     432             :      *       THe order of elements is important since it is used
     433             :      *       while searching the rules in the set in agent.
     434             :      */
     435             :     enum FatFlowIgnoreAddressType {
     436             :         IGNORE_SOURCE = 1,
     437             :         IGNORE_ADDRESS_MIN_VAL = IGNORE_SOURCE,
     438             :         IGNORE_DESTINATION,
     439             :         IGNORE_NONE,
     440             :         IGNORE_ADDRESS_MAX_VAL = IGNORE_NONE,
     441             :     };
     442             : 
     443             :     /*
     444             :      * NOTE: This value should be in sync with vrouter code.
     445             :      *       THe order of elements is important since it is used
     446             :      *       while searching the rules in the set in agent.
     447             :      */
     448             :     enum FatFlowPrefixAggregateType {
     449             :         AGGREGATE_NONE = 0,
     450             :         AGGREGATE_PREFIX_MIN_VAL = AGGREGATE_NONE,
     451             :         AGGREGATE_DST_IPV6,
     452             :         AGGREGATE_SRC_IPV6,
     453             :         AGGREGATE_SRC_DST_IPV6,
     454             :         AGGREGATE_DST_IPV4,
     455             :         AGGREGATE_SRC_IPV4,
     456             :         AGGREGATE_SRC_DST_IPV4,
     457             :         AGGREGATE_PREFIX_MAX_VAL = AGGREGATE_SRC_DST_IPV4,
     458             :     };
     459             : 
     460             :     enum HbsIntfType {
     461             :         HBS_INTF_INVALID = 0,
     462             :         HBS_INTF_LEFT,
     463             :         HBS_INTF_RIGHT,
     464             :         HBS_INTF_MGMT,
     465             :     };
     466             : 
     467             :     typedef std::map<IpAddress, MetaDataIp*> MetaDataIpMap;
     468             :     typedef std::set<HealthCheckInstanceBase *> HealthCheckInstanceSet;
     469             : 
     470             :     struct List {
     471             :     };
     472             : 
     473             :     struct ListEntry {
     474       27864 :         ListEntry() : del_pending_(false) { }
     475         428 :         ListEntry(bool del_pending) : del_pending_(del_pending) { }
     476       28292 :         virtual ~ListEntry()  {}
     477             : 
     478         226 :         bool del_pending() const { return del_pending_; }
     479          84 :         void set_del_pending(bool val) const { del_pending_ = val; }
     480             : 
     481             :         VmInterfaceState::Op GetOp(VmInterfaceState::Op op) const;
     482             :         mutable bool del_pending_;
     483             :     };
     484             : 
     485             :     struct FloatingIpList;
     486             :     // A unified structure for storing FloatingIp information for both
     487             :     // operational and config elements
     488             :     struct FloatingIp : public ListEntry, VmInterfaceState {
     489             :         enum Direction {
     490             :             DIRECTION_BOTH,
     491             :             DIRECTION_INGRESS,
     492             :             DIRECTION_EGRESS,
     493             :             DIRECTION_INVALID
     494             :         };
     495             : 
     496             :         struct PortMapKey {
     497             :             uint8_t protocol_;
     498             :             uint16_t port_;
     499        3908 :             PortMapKey(): protocol_(0), port_(0) { }
     500           0 :             PortMapKey(uint8_t protocol, uint16_t port) :
     501           0 :                 protocol_(protocol), port_(port) { }
     502        3964 :             ~PortMapKey() { }
     503             : 
     504           0 :             bool operator()(const PortMapKey &lhs, const PortMapKey &rhs) const {
     505           0 :                 if (lhs.protocol_ != rhs.protocol_)
     506           0 :                     return lhs.protocol_ < rhs.protocol_;
     507           0 :                 return lhs.port_ < rhs.port_;
     508             :             }
     509             :         };
     510             : 
     511             :         typedef std::map<PortMapKey, uint16_t, PortMapKey> PortMap;
     512             :         typedef PortMap::iterator PortMapIterator;
     513             :         FloatingIp();
     514             :         FloatingIp(const FloatingIp &rhs);
     515             :         FloatingIp(const IpAddress &addr, const std::string &vrf,
     516             :                    const boost::uuids::uuid &vn_uuid, const IpAddress &ip,
     517             :                    Direction direction, bool port_mappng_enabled,
     518             :                    const PortMap &src_port_map, const PortMap &dst_port_map,
     519             :                    bool port_nat);
     520             :         virtual ~FloatingIp();
     521             : 
     522             :         bool operator() (const FloatingIp &lhs, const FloatingIp &rhs) const;
     523             :         bool IsLess(const FloatingIp *rhs) const;
     524             : 
     525             :         bool port_map_enabled() const;
     526           0 :         Direction direction() const { return direction_; }
     527             : 
     528             :         const IpAddress GetFixedIp(const VmInterface *) const;
     529             :         uint32_t PortMappingSize() const;
     530             :         int32_t GetSrcPortMap(uint8_t protocol, uint16_t src_port) const;
     531             :         int32_t GetDstPortMap(uint8_t protocol, uint16_t dst_port) const;
     532             :         // direction_ is based on packet direction. Allow DNAT if direction is
     533             :         // "both or ingress"
     534           0 :         bool AllowDNat() const {
     535           0 :             return (direction_ == DIRECTION_BOTH ||
     536           0 :                     direction_ == DIRECTION_INGRESS);
     537             :         }
     538             :         // direction_ is based on packet direction. Allow SNAT if direction is
     539             :         // "both or egress"
     540           0 :         bool AllowSNat() const {
     541           0 :             return (direction_ == DIRECTION_BOTH ||
     542           0 :                     direction_ == DIRECTION_EGRESS);
     543             :         }
     544             : 
     545             :         void Copy(const Agent *agent, const VmInterface *vmi) const;
     546             :         VmInterfaceState::Op GetOpL3(const Agent *agent,
     547             :                                      const VmInterface *vmi) const;
     548             :         bool AddL3(const Agent *agent, VmInterface *vmi) const;
     549             :         bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     550             :         VmInterfaceState::Op GetOpL2(const Agent *agent,
     551             :                                      const VmInterface *vmi) const;
     552             :         bool AddL2(const Agent *agent, VmInterface *vmi) const;
     553             :         bool DeleteL2(const Agent *agent, VmInterface *vmi) const;
     554             :         bool port_nat() const;
     555             : 
     556             :         IpAddress floating_ip_;
     557             :         mutable VnEntryRef vn_;
     558             :         mutable VrfEntryRef vrf_;
     559             :         std::string vrf_name_;
     560             :         boost::uuids::uuid vn_uuid_;
     561             :         mutable IpAddress fixed_ip_;
     562             :         mutable Direction direction_;
     563             :         mutable bool port_map_enabled_;
     564             :         mutable PortMap src_port_map_;
     565             :         mutable PortMap dst_port_map_;
     566             :         mutable uint32_t ethernet_tag_;
     567             :         mutable bool port_nat_;
     568             :     };
     569             :     typedef std::set<FloatingIp, FloatingIp> FloatingIpSet;
     570             : 
     571             :     struct FloatingIpList : public List {
     572        1808 :         FloatingIpList() :
     573        1808 :             List(), v4_count_(0), v6_count_(0), list_() {
     574        1808 :         }
     575        1808 :         ~FloatingIpList() { }
     576             : 
     577             :         void Insert(const FloatingIp *rhs);
     578             :         void Update(const FloatingIp *lhs, const FloatingIp *rhs);
     579             :         void Remove(FloatingIpSet::iterator &it);
     580             :         bool UpdateList(const Agent *agent, VmInterface *vmi,
     581             :                         VmInterfaceState::Op l2_force_op,
     582             :                         VmInterfaceState::Op l3_force_op);
     583             : 
     584             :         uint16_t v4_count_;
     585             :         uint16_t v6_count_;
     586             :         FloatingIpSet list_;
     587             :     };
     588             : 
     589             :     // A unified structure for storing AliasIp information for both
     590             :     // operational and config elements
     591             :     struct AliasIpList;
     592             :     struct AliasIp : public ListEntry, VmInterfaceState {
     593             :         AliasIp();
     594             :         AliasIp(const AliasIp &rhs);
     595             :         AliasIp(const IpAddress &addr, const std::string &vrf,
     596             :                 const boost::uuids::uuid &vn_uuid);
     597             :         virtual ~AliasIp();
     598             : 
     599             :         bool operator() (const AliasIp &lhs, const AliasIp &rhs) const;
     600             :         bool IsLess(const AliasIp *rhs) const;
     601             : 
     602             :         VmInterfaceState::Op GetOpL3(const Agent *agent,
     603             :                                      const VmInterface *vmi) const;
     604             :         bool AddL3(const Agent *agent, VmInterface *vmi) const;
     605             :         bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     606             :         void Copy(const Agent *agent, const VmInterface *vmi) const;
     607             : 
     608             :         IpAddress alias_ip_;
     609             :         mutable VnEntryRef vn_;
     610             :         mutable VrfEntryRef vrf_;
     611             :         std::string vrf_name_;
     612             :         boost::uuids::uuid vn_uuid_;
     613             :     };
     614             :     typedef std::set<AliasIp, AliasIp> AliasIpSet;
     615             : 
     616             :     struct AliasIpList : public List {
     617        1808 :         AliasIpList() : v4_count_(0), v6_count_(0), list_() { }
     618        1808 :         ~AliasIpList() { }
     619             : 
     620             :         void Insert(const AliasIp *rhs);
     621             :         void Update(const AliasIp *lhs, const AliasIp *rhs);
     622             :         void Remove(AliasIpSet::iterator &it);
     623             :         bool UpdateList(const Agent *agent, VmInterface *vmi,
     624             :                         VmInterfaceState::Op l2_force_op,
     625             :                         VmInterfaceState::Op l3_force_op);
     626             : 
     627             :         uint16_t v4_count_;
     628             :         uint16_t v6_count_;
     629             :         AliasIpSet list_;
     630             :     };
     631             : 
     632             :     struct ServiceVlan : ListEntry {
     633             :         ServiceVlan();
     634             :         ServiceVlan(const ServiceVlan &rhs);
     635             :         ServiceVlan(uint16_t tag, const std::string &vrf_name,
     636             :                     const Ip4Address &addr, const Ip6Address &addr6,
     637             :                     const MacAddress &smac, const MacAddress &dmac);
     638             :         virtual ~ServiceVlan();
     639             : 
     640             :         bool operator() (const ServiceVlan &lhs, const ServiceVlan &rhs) const;
     641             :         bool IsLess(const ServiceVlan *rhs) const;
     642             :         void Update(const Agent *agent, VmInterface *vmi) const;
     643             :         void DeleteCommon(const VmInterface *vmi) const;
     644             :         void AddCommon(const Agent *agent, const VmInterface *vmi) const;
     645             : 
     646             :         void Copy(const Agent *agent, const VmInterface *vmi) const;
     647             :         VmInterfaceState::Op GetOpL3(const Agent *agent,
     648             :                                      const VmInterface *vmi) const;
     649             :         bool AddL3(const Agent *agent, VmInterface *vmi) const;
     650             :         bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     651             : 
     652             :         uint16_t tag_;
     653             :         mutable std::string vrf_name_;
     654             :         mutable Ip4Address addr_;
     655             :         mutable Ip4Address old_addr_;
     656             :         mutable Ip6Address addr6_;
     657             :         mutable Ip6Address old_addr6_;
     658             :         mutable MacAddress smac_;
     659             :         mutable MacAddress dmac_;
     660             :         mutable VrfEntryRef vrf_;
     661             :         mutable uint32_t label_;
     662             :         mutable bool v4_rt_installed_;
     663             :         mutable bool v6_rt_installed_;
     664             :         mutable bool del_add_;
     665             :     };
     666             :     typedef std::set<ServiceVlan, ServiceVlan> ServiceVlanSet;
     667             : 
     668             :     struct ServiceVlanList : List {
     669        1808 :         ServiceVlanList() : List(), list_() { }
     670        1808 :         ~ServiceVlanList() { }
     671             :         void Insert(const ServiceVlan *rhs);
     672             :         void Update(const ServiceVlan *lhs, const ServiceVlan *rhs);
     673             :         void Remove(ServiceVlanSet::iterator &it);
     674             :         bool UpdateList(const Agent *agent, VmInterface *vmi,
     675             :                         VmInterfaceState::Op l2_force_op,
     676             :                         VmInterfaceState::Op l3_force_op);
     677             : 
     678             :         ServiceVlanSet list_;
     679             :     };
     680             : 
     681             :     struct StaticRoute : ListEntry, VmInterfaceState {
     682             :         StaticRoute();
     683             :         StaticRoute(const StaticRoute &rhs);
     684             :         StaticRoute(const IpAddress &addr, uint32_t plen, const AddressList &gw_list,
     685             :                     const CommunityList &communities);
     686             :         virtual ~StaticRoute();
     687             : 
     688             :         bool operator() (const StaticRoute &lhs, const StaticRoute &rhs) const;
     689             :         bool IsLess(const StaticRoute *rhs) const;
     690             : 
     691             :         void Copy(const Agent *agent, const VmInterface *vmi) const;
     692             :         VmInterfaceState::Op GetOpL3(const Agent *agent,
     693             :                                      const VmInterface *vmi) const;
     694             :         bool AddL3(const Agent *agent, VmInterface *vmi) const;
     695             :         bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     696             : 
     697             :         mutable const VrfEntry *vrf_;
     698             :         IpAddress  addr_;
     699             :         uint32_t    plen_;
     700             :         AddressList gw_list_;
     701             :         CommunityList communities_;
     702             :     };
     703             :     typedef std::set<StaticRoute, StaticRoute> StaticRouteSet;
     704             : 
     705             :     struct StaticRouteList : List {
     706        1808 :         StaticRouteList() : List(), list_() { }
     707        1808 :         ~StaticRouteList() { }
     708             :         void Insert(const StaticRoute *rhs);
     709             :         void Update(const StaticRoute *lhs, const StaticRoute *rhs);
     710             :         void Remove(StaticRouteSet::iterator &it);
     711             : 
     712             :         bool UpdateList(const Agent *agent, VmInterface *vmi,
     713             :                         VmInterfaceState::Op l2_force_op,
     714             :                         VmInterfaceState::Op l3_force_op);
     715             :         StaticRouteSet list_;
     716             :     };
     717             : 
     718             :     struct AllowedAddressPair : ListEntry, VmInterfaceState {
     719             :         AllowedAddressPair();
     720             :         AllowedAddressPair(const AllowedAddressPair &rhs);
     721             :         AllowedAddressPair(const IpAddress &addr, uint32_t plen, bool ecmp,
     722             :                            const MacAddress &mac);
     723             :         virtual ~AllowedAddressPair();
     724             : 
     725             :         bool operator() (const AllowedAddressPair &lhs,
     726             :                          const AllowedAddressPair &rhs) const;
     727             :         bool operator == (const  AllowedAddressPair &rhs) const {
     728             :             return ((mac_ == rhs.mac_) && (addr_ == rhs.addr_) &&
     729             :                     (plen_ == rhs.plen_));
     730             :         }
     731             :         bool IsLess(const AllowedAddressPair *rhs) const;
     732             : 
     733             :         void Copy(const Agent *agent, const VmInterface *vmi) const;
     734             :         VmInterfaceState::Op GetOpL3(const Agent *agent,
     735             :                                      const VmInterface *vmi) const;
     736             :         bool AddL3(const Agent *agent, VmInterface *vmi) const;
     737             :         bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     738             :         VmInterfaceState::Op GetOpL2(const Agent *agent,
     739             :                                      const VmInterface *vmi) const;
     740             :         bool AddL2(const Agent *agent, VmInterface *vmi) const;
     741             :         bool DeleteL2(const Agent *agent, VmInterface *vmi) const;
     742             : 
     743             :         IpAddress   addr_;
     744             :         uint32_t    plen_;
     745             :         mutable bool ecmp_;
     746             :         MacAddress  mac_;
     747             :         mutable bool        ecmp_config_changed_;
     748             :         mutable IpAddress  service_ip_;
     749             :         mutable uint32_t label_;
     750             :         mutable NextHopRef policy_enabled_nh_;
     751             :         mutable NextHopRef policy_disabled_nh_;
     752             :         mutable VrfEntry *vrf_;
     753             :         mutable uint32_t ethernet_tag_;
     754             :     };
     755             :     typedef std::set<AllowedAddressPair, AllowedAddressPair>
     756             :         AllowedAddressPairSet;
     757             : 
     758             :     struct AllowedAddressPairList : public List {
     759        1808 :         AllowedAddressPairList() : List(), list_() { }
     760        1808 :         ~AllowedAddressPairList() { }
     761             :         void Insert(const AllowedAddressPair *rhs);
     762             :         void Update(const AllowedAddressPair *lhs,
     763             :                     const AllowedAddressPair *rhs);
     764             :         void Remove(AllowedAddressPairSet::iterator &it);
     765             : 
     766             :         bool UpdateList(const Agent *agent, VmInterface *vmi,
     767             :                         VmInterfaceState::Op l2_force_op,
     768             :                         VmInterfaceState::Op l3_force_op);
     769             : 
     770             :         AllowedAddressPairSet list_;
     771             :     };
     772             : 
     773             :     struct SecurityGroupEntry : ListEntry, VmInterfaceState {
     774             :         SecurityGroupEntry();
     775             :         SecurityGroupEntry(const SecurityGroupEntry &rhs);
     776             :         SecurityGroupEntry(const boost::uuids::uuid &uuid);
     777             :         virtual ~SecurityGroupEntry();
     778             : 
     779             :         bool operator == (const SecurityGroupEntry &rhs) const;
     780             :         bool operator() (const SecurityGroupEntry &lhs,
     781             :                          const SecurityGroupEntry &rhs) const;
     782             :         bool IsLess(const SecurityGroupEntry *rhs) const;
     783             : 
     784             :         VmInterfaceState::Op GetOpL3(const Agent *agent,
     785             :                                      const VmInterface *vmi) const;
     786             :         bool AddL3(const Agent *agent, VmInterface *vmi) const;
     787             :         bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     788             : 
     789             :         mutable SgEntryRef sg_;
     790             :         boost::uuids::uuid uuid_;
     791             :     };
     792             :     typedef std::set<SecurityGroupEntry, SecurityGroupEntry>
     793             :         SecurityGroupEntrySet;
     794             :     typedef std::vector<boost::uuids::uuid> SecurityGroupUuidList;
     795             : 
     796             :     struct SecurityGroupEntryList {
     797        1868 :         SecurityGroupEntryList() : list_() { }
     798        1868 :         ~SecurityGroupEntryList() { }
     799             : 
     800             :         void Insert(const SecurityGroupEntry *rhs);
     801             :         void Update(const SecurityGroupEntry *lhs,
     802             :                     const SecurityGroupEntry *rhs);
     803             :         void Remove(SecurityGroupEntrySet::iterator &it);
     804             :         bool UpdateList(const Agent *agent, VmInterface *vmi,
     805             :                         VmInterfaceState::Op l2_force_op,
     806             :                         VmInterfaceState::Op l3_force_op);
     807             : 
     808             :         SecurityGroupEntrySet list_;
     809             :     };
     810             : 
     811             :     struct TagEntry : ListEntry, VmInterfaceState {
     812             :         TagEntry();
     813             :         TagEntry(const TagEntry &rhs);
     814             :         TagEntry(uint64_t tag_type, const boost::uuids::uuid &uuid);
     815             :         virtual ~TagEntry();
     816             : 
     817             :         bool operator == (const TagEntry &rhs) const;
     818             :         bool operator() (const TagEntry &lhs, const TagEntry &rhs) const;
     819             :         bool IsLess(const TagEntry *rhs) const;
     820             : 
     821             :         VmInterfaceState::Op GetOpL3(const Agent *agent,
     822             :                                      const VmInterface *vmi) const;
     823             :         bool AddL3(const Agent *agent, VmInterface *vmi) const;
     824             :         bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     825             : 
     826             :         mutable TagEntryRef tag_;
     827             :         uint64_t type_;
     828             :         mutable boost::uuids::uuid uuid_;
     829             :     };
     830             :     typedef std::set<TagEntry, TagEntry> TagEntrySet;
     831             :     typedef std::vector<boost::uuids::uuid> TagGroupUuidList;
     832             : 
     833             :     struct TagEntryList {
     834        2256 :         TagEntryList() : list_() { }
     835        2256 :         ~TagEntryList() { }
     836             : 
     837             :         void Insert(const TagEntry *rhs);
     838             :         void Update(const TagEntry *lhs,
     839             :                     const TagEntry *rhs);
     840             :         void Remove(TagEntrySet::iterator &it);
     841             :         bool UpdateList(const Agent *agent, VmInterface *vmi,
     842             :                         VmInterfaceState::Op l2_force_op,
     843             :                         VmInterfaceState::Op l3_force_op);
     844             : 
     845             :         TagEntrySet list_;
     846             :     };
     847             : 
     848             :     struct VrfAssignRule : ListEntry {
     849             :         VrfAssignRule();
     850             :         VrfAssignRule(const VrfAssignRule &rhs);
     851             :         VrfAssignRule(uint32_t id,
     852             :                       const autogen::MatchConditionType &match_condition_,
     853             :                       const std::string &vrf_name, bool ignore_acl);
     854             :         ~VrfAssignRule();
     855             :         bool operator == (const VrfAssignRule &rhs) const;
     856             :         bool operator() (const VrfAssignRule &lhs,
     857             :                          const VrfAssignRule &rhs) const;
     858             :         bool IsLess(const VrfAssignRule *rhs) const;
     859             :         void Update(const Agent *agent, VmInterface *vmi);
     860             : 
     861             :         const uint32_t id_;
     862             :         mutable std::string vrf_name_;
     863             :         mutable bool ignore_acl_;
     864             :         mutable autogen::MatchConditionType match_condition_;
     865             :     };
     866             :     typedef std::set<VrfAssignRule, VrfAssignRule> VrfAssignRuleSet;
     867             : 
     868             :     struct VrfAssignRuleList : public List {
     869        1808 :         VrfAssignRuleList() :
     870        1808 :             List(), list_(), vrf_assign_acl_(NULL) {
     871        1808 :         }
     872        1808 :         ~VrfAssignRuleList() { }
     873             :         void Insert(const VrfAssignRule *rhs);
     874             :         void Update(const VrfAssignRule *lhs, const VrfAssignRule *rhs);
     875             :         void Remove(VrfAssignRuleSet::iterator &it);
     876             :         bool UpdateList(const Agent *agent, VmInterface *vmi,
     877             :                         VmInterfaceState::Op l2_force_op,
     878             :                         VmInterfaceState::Op l3_force_op);
     879             : 
     880             :         VrfAssignRuleSet list_;
     881             :         AclDBEntryRef vrf_assign_acl_;
     882             :     };
     883             : 
     884             :     struct InstanceIpList;
     885             :     struct InstanceIp : ListEntry, VmInterfaceState {
     886             :         InstanceIp();
     887             :         InstanceIp(const InstanceIp &rhs);
     888             :         InstanceIp(const IpAddress &ip, uint8_t plen, bool ecmp,
     889             :                    bool is_primary, bool is_service_ip,
     890             :                    bool is_service_health_check_ip,
     891             :                    bool is_local, const IpAddress &tracking_ip);
     892             :         ~InstanceIp();
     893             :         bool operator == (const InstanceIp &rhs) const;
     894             :         bool operator() (const InstanceIp &lhs,
     895             :                          const InstanceIp &rhs) const;
     896           0 :         InstanceIp operator = (const InstanceIp &rhs) const {
     897           0 :             InstanceIp ret(rhs);
     898           0 :             return ret;
     899             :         }
     900             :         bool IsLess(const InstanceIp *rhs) const;
     901             : 
     902             :         void Update(const Agent *agent, VmInterface *vmi,
     903             :                     const VmInterface::InstanceIpList *list) const;
     904             :         void SetPrefixForAllocUnitIpam(VmInterface *intrface) const;
     905             : 
     906             :         VmInterfaceState::Op GetOpL3(const Agent *agent,
     907             :                                      const VmInterface *vmi) const;
     908             :         bool AddL3(const Agent *agent, VmInterface *vmi) const;
     909             :         bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     910             :         VmInterfaceState::Op GetOpL2(const Agent *agent,
     911             :                                      const VmInterface *vmi) const;
     912             :         bool AddL2(const Agent *agent, VmInterface *vmi) const;
     913             :         bool DeleteL2(const Agent *agent, VmInterface *vmi) const;
     914             :         void Copy(const Agent *agent, const VmInterface *vmi) const;
     915             : 
     916          41 :         bool is_force_policy() const {
     917          41 :             return is_service_health_check_ip_;
     918             :         }
     919             : 
     920          41 :         bool IsL3Only() const {
     921          41 :             return is_service_health_check_ip_;
     922             :         }
     923             : 
     924             :         const IpAddress ip_;
     925             :         mutable uint8_t plen_;
     926             :         mutable bool ecmp_;
     927             :         mutable bool is_primary_;
     928             :         mutable bool is_service_ip_;  // used for service chain nexthop
     929             :         mutable bool is_service_health_check_ip_;
     930             :         mutable bool is_local_;
     931             :         mutable IpAddress tracking_ip_;
     932             :         mutable const VrfEntry *vrf_;
     933             :         mutable uint32_t ethernet_tag_;
     934             :     };
     935             :     typedef std::set<InstanceIp, InstanceIp> InstanceIpSet;
     936             : 
     937             :     struct InstanceIpList : public List {
     938        3616 :         InstanceIpList(bool is_ipv4) :
     939        3616 :             List(), is_ipv4_(is_ipv4), list_() {
     940        3616 :         }
     941        3616 :         ~InstanceIpList() { }
     942             :         void Insert(const InstanceIp *rhs);
     943             :         void Update(const InstanceIp *lhs, const InstanceIp *rhs);
     944             :         void Remove(InstanceIpSet::iterator &it);
     945             : 
     946             :         virtual bool UpdateList(const Agent *agent, VmInterface *vmi,
     947             :                                 VmInterfaceState::Op l2_force_op,
     948             :                                 VmInterfaceState::Op l3_force_op);
     949             : 
     950             :         bool is_ipv4_;
     951             :         InstanceIpSet list_;
     952             :     };
     953             :     struct LearntMacIpList;
     954             :     struct LearntMacIp : ListEntry, VmInterfaceState {
     955             :         LearntMacIp();
     956             :         LearntMacIp(const LearntMacIp &rhs);
     957             :         LearntMacIp(const IpAddress &ip, const MacAddress &mac);
     958             :         ~LearntMacIp();
     959             :         bool operator == (const LearntMacIp &rhs) const;
     960             :         bool operator() (const LearntMacIp &lhs,
     961             :                          const LearntMacIp &rhs) const;
     962             :         LearntMacIp operator = (const LearntMacIp &rhs) const {
     963             :             LearntMacIp ret(rhs);
     964             :             return ret;
     965             :         }
     966             :         bool IsLess(const LearntMacIp *rhs) const;
     967             : 
     968             :         void Update(const Agent *agent, VmInterface *vmi,
     969             :                     const VmInterface::InstanceIpList *list) const;
     970             :         VmInterfaceState::Op GetOpL3(const Agent *agent,
     971             :                                      const VmInterface *vmi) const;
     972             :         bool AddL3(const Agent *agent, VmInterface *vmi) const;
     973             :         bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
     974             :         VmInterfaceState::Op GetOpL2(const Agent *agent,
     975             :                                      const VmInterface *vmi) const;
     976             :         bool AddL2(const Agent *agent, VmInterface *vmi) const;
     977             :         bool DeleteL2(const Agent *agent, VmInterface *vmi) const;
     978             :         void Copy(const Agent *agent, const VmInterface *vmi) const;
     979             : 
     980             :         const IpAddress ip_;
     981             :         const MacAddress mac_;
     982             :         mutable const VrfEntry *vrf_;
     983             :         mutable uint32_t ethernet_tag_;
     984             :         mutable NextHopRef l2_nh_policy_;
     985             :         mutable NextHopRef l2_nh_no_policy_;
     986             :         mutable uint32_t l2_label_;
     987             :         mutable NextHopRef l3_nh_policy_;
     988             :         mutable NextHopRef l3_nh_no_policy_;
     989             :         mutable uint32_t l3_label_;
     990             :     };
     991             :     typedef std::set<LearntMacIp, LearntMacIp> LearntMacIpSet;
     992             : 
     993             :     struct LearntMacIpList : public List {
     994        1657 :         LearntMacIpList() :
     995        1657 :             List(), list_() {
     996        1657 :         }
     997        1657 :         ~LearntMacIpList() { }
     998             :         void Insert(const LearntMacIp *rhs);
     999             :         void Update(const LearntMacIp *lhs, const LearntMacIp *rhs);
    1000             :         void Remove(const LearntMacIp *rhs);
    1001             : 
    1002             :         virtual bool UpdateList(const Agent *agent, VmInterface *vmi,
    1003             :                                 VmInterfaceState::Op l2_force_op,
    1004             :                                 VmInterfaceState::Op l3_force_op);
    1005             : 
    1006             :         LearntMacIpSet list_;
    1007             :     };
    1008             : 
    1009             :     typedef std::map<std::string, FatFlowIgnoreAddressType> IgnoreAddressMap;
    1010             : 
    1011             :     struct FatFlowEntry : ListEntry {
    1012             : 
    1013             : #define FAT_FLOW_ENTRY_MIN_PREFIX_LEN  8
    1014             : 
    1015        7214 :         FatFlowEntry(): protocol(0), port(0),
    1016        3607 :             ignore_address(IGNORE_NONE), prefix_aggregate(AGGREGATE_NONE),
    1017        7214 :             src_prefix(), src_prefix_mask(0), src_aggregate_plen(0),
    1018        3607 :             dst_prefix(), dst_prefix_mask(0), dst_aggregate_plen(0) {}
    1019             : 
    1020          15 :         FatFlowEntry(const FatFlowEntry &rhs):
    1021          15 :             protocol(rhs.protocol), port(rhs.port),
    1022          15 :             ignore_address(rhs.ignore_address), prefix_aggregate(rhs.prefix_aggregate),
    1023          30 :             src_prefix(rhs.src_prefix), src_prefix_mask(rhs.src_prefix_mask), src_aggregate_plen(rhs.src_aggregate_plen),
    1024          15 :             dst_prefix(rhs.dst_prefix), dst_prefix_mask(rhs.dst_prefix_mask), dst_aggregate_plen(rhs.dst_aggregate_plen) {}
    1025             : 
    1026             :         FatFlowEntry(const uint8_t proto, const uint16_t p) :
    1027             :                 protocol(proto), port(p),
    1028             :                 ignore_address(IGNORE_NONE),
    1029             :                 prefix_aggregate(AGGREGATE_NONE),
    1030             :                 src_prefix(), src_prefix_mask(0), src_aggregate_plen(0),
    1031             :                 dst_prefix(), dst_prefix_mask(0), dst_aggregate_plen(0) { }
    1032             : 
    1033           6 :         FatFlowEntry(const uint8_t proto, const uint16_t p,
    1034             :                      FatFlowIgnoreAddressType ignore_addr,
    1035           6 :                      FatFlowPrefixAggregateType prefix_aggr) :
    1036           6 :                 protocol(proto), port(p),
    1037           6 :                 ignore_address(ignore_addr),
    1038           6 :                 prefix_aggregate(prefix_aggr),
    1039          12 :                 src_prefix(), src_prefix_mask(0), src_aggregate_plen(0),
    1040           6 :                 dst_prefix(), dst_prefix_mask(0), dst_aggregate_plen(0) { }
    1041             : 
    1042             :         FatFlowEntry(const uint8_t proto, const uint16_t p,
    1043             :             std::string ignore_addr, FatFlowPrefixAggregateType prefix_aggregate,
    1044             :             IpAddress src_prefix, uint8_t src_prefix_mask, uint8_t src_aggregate_plen,
    1045             :             IpAddress dst_prefix, uint8_t dst_prefix_mask, uint8_t dst_aggregate_plen);
    1046             : 
    1047             :         static FatFlowEntry MakeFatFlowEntry(const std::string &protocol, const int &port,
    1048             :                                              const std::string &ignore_addr_str,
    1049             :                                              const std::string &src_prefix_str, const int &src_prefix_mask,
    1050             :                                              const int &src_aggregate_plen,
    1051             :                                              const std::string &dst_prefix_str, const int &dst_prefix_mask,
    1052             :                                              const int &dst_aggregate_plen);
    1053             : 
    1054        3637 :         virtual ~FatFlowEntry(){}
    1055           6 :         bool operator == (const FatFlowEntry &rhs) const {
    1056           6 :             return (rhs.protocol == protocol && rhs.port == port &&
    1057          12 :                     rhs.ignore_address == ignore_address && rhs.prefix_aggregate == prefix_aggregate &&
    1058          12 :                     rhs.src_prefix == src_prefix && rhs.src_prefix_mask == src_prefix_mask &&
    1059          12 :                     rhs.src_aggregate_plen == src_aggregate_plen &&
    1060          24 :                     rhs.dst_prefix == dst_prefix && rhs.dst_prefix_mask == dst_prefix_mask &&
    1061          12 :                     rhs.dst_aggregate_plen == dst_aggregate_plen);
    1062             :         }
    1063             : 
    1064          18 :         bool operator() (const FatFlowEntry  &lhs,
    1065             :                          const FatFlowEntry &rhs) const {
    1066          18 :             return lhs.IsLess(&rhs);
    1067             :         }
    1068             : 
    1069          30 :         bool IsLess(const FatFlowEntry *rhs) const {
    1070          30 :             if (protocol != rhs->protocol) {
    1071           0 :                 return protocol < rhs->protocol;
    1072             :             }
    1073          30 :             if (port != rhs->port) {
    1074          12 :                 return port < rhs->port;
    1075             :             }
    1076          18 :             if (ignore_address != rhs->ignore_address) {
    1077           3 :                 return ignore_address < rhs->ignore_address;
    1078             :             }
    1079          15 :             if (prefix_aggregate != rhs->prefix_aggregate) {
    1080           0 :                 return prefix_aggregate < rhs->prefix_aggregate;
    1081             :             }
    1082          15 :             if (src_prefix != rhs->src_prefix) {
    1083           0 :                 return src_prefix < rhs->src_prefix;
    1084             :             }
    1085          15 :             if (src_prefix_mask != rhs->src_prefix_mask) {
    1086           0 :                 return src_prefix_mask < rhs->src_prefix_mask;
    1087             :             }
    1088          15 :             if (src_aggregate_plen != rhs->src_aggregate_plen) {
    1089           0 :                 return src_aggregate_plen < rhs->src_aggregate_plen;
    1090             :             }
    1091          15 :             if (dst_prefix != rhs->dst_prefix) {
    1092           0 :                 return dst_prefix < rhs->dst_prefix;
    1093             :             }
    1094          15 :             if (dst_prefix_mask != rhs->dst_prefix_mask) {
    1095           0 :                 return dst_prefix_mask < rhs->dst_prefix_mask;
    1096             :             }
    1097          15 :             return dst_aggregate_plen < rhs->dst_aggregate_plen;
    1098             :         }
    1099             :         void print(void) const;
    1100             : 
    1101             :         uint8_t protocol;
    1102             :         uint16_t port;
    1103             :         mutable FatFlowIgnoreAddressType ignore_address;
    1104             :         mutable FatFlowPrefixAggregateType prefix_aggregate;
    1105             :         mutable IpAddress src_prefix;
    1106             :         mutable uint8_t src_prefix_mask;
    1107             :         mutable uint8_t src_aggregate_plen;
    1108             :         mutable IpAddress dst_prefix;
    1109             :         mutable uint8_t dst_prefix_mask;
    1110             :         mutable uint8_t dst_aggregate_plen;
    1111             :     };
    1112             :     /* All the fields in FatFlowEntry are considered as part of key */
    1113             :     typedef std::set<FatFlowEntry, FatFlowEntry> FatFlowEntrySet;
    1114             : 
    1115             :     struct FatFlowList {
    1116        3607 :         FatFlowList(): list_() {}
    1117        3607 :         ~FatFlowList() {}
    1118             :         void Insert(const FatFlowEntry *rhs);
    1119             :         void Update(const FatFlowEntry *lhs, const FatFlowEntry *rhs);
    1120             :         void Remove(FatFlowEntrySet::iterator &it);
    1121             :         bool UpdateList(const Agent *agent, VmInterface *vmi);
    1122             :         void DumpList() const;
    1123             : 
    1124             :         FatFlowEntrySet list_;
    1125             :     };
    1126             : 
    1127             :     struct FatFlowExcludeList {
    1128             :         std::vector<uint64_t> fat_flow_v4_exclude_list_;
    1129             :         std::vector<uint64_t> fat_flow_v6_exclude_upper_list_;
    1130             :         std::vector<uint64_t> fat_flow_v6_exclude_lower_list_;
    1131             :         std::vector<uint16_t> fat_flow_v6_exclude_plen_list_;
    1132          95 :         void Clear() {
    1133          95 :             fat_flow_v4_exclude_list_.clear();
    1134          95 :             fat_flow_v6_exclude_upper_list_.clear();
    1135          95 :             fat_flow_v6_exclude_lower_list_.clear();
    1136          95 :             fat_flow_v6_exclude_plen_list_.clear();
    1137          95 :         }
    1138             :     };
    1139             :     struct BridgeDomain : ListEntry {
    1140        5424 :         BridgeDomain(): uuid_(boost::uuids::nil_uuid()), vlan_tag_(0),
    1141        1808 :             bridge_domain_(NULL) {}
    1142           0 :         BridgeDomain(const BridgeDomain &rhs):
    1143           0 :             uuid_(rhs.uuid_), vlan_tag_(rhs.vlan_tag_),
    1144           0 :             bridge_domain_(rhs.bridge_domain_) {}
    1145           0 :         BridgeDomain(const boost::uuids::uuid &uuid, uint32_t vlan_tag):
    1146           0 :             uuid_(uuid), vlan_tag_(vlan_tag), bridge_domain_(NULL) {}
    1147        1808 :         virtual ~BridgeDomain(){}
    1148             :         bool operator == (const BridgeDomain &rhs) const {
    1149             :             return (uuid_ == rhs.uuid_);
    1150             :         }
    1151             : 
    1152           0 :         bool operator() (const BridgeDomain &lhs,
    1153             :                          const BridgeDomain &rhs) const {
    1154           0 :             return lhs.IsLess(&rhs);
    1155             :         }
    1156             : 
    1157           0 :         bool IsLess(const BridgeDomain *rhs) const {
    1158           0 :             return uuid_ < rhs->uuid_;
    1159             :         }
    1160             : 
    1161             :         boost::uuids::uuid uuid_;
    1162             :         uint32_t vlan_tag_;
    1163             :         mutable BridgeDomainConstRef bridge_domain_;
    1164             :     };
    1165             :     typedef std::set<BridgeDomain, BridgeDomain> BridgeDomainEntrySet;
    1166             : 
    1167             :     struct BridgeDomainList {
    1168        1808 :         BridgeDomainList(): list_() {}
    1169        1808 :         ~BridgeDomainList() {}
    1170             :         void Insert(const BridgeDomain *rhs);
    1171             :         void Update(const BridgeDomain *lhs, const BridgeDomain *rhs);
    1172             :         void Remove(BridgeDomainEntrySet::iterator &it);
    1173             : 
    1174             :         bool Update(const Agent *agent, VmInterface *vmi);
    1175             :         BridgeDomainEntrySet list_;
    1176             :     };
    1177             : 
    1178             :     struct VmiReceiveRoute : ListEntry, VmInterfaceState {
    1179             :         VmiReceiveRoute();
    1180             :         VmiReceiveRoute(const VmiReceiveRoute &rhs);
    1181             :         VmiReceiveRoute(const IpAddress &addr, uint32_t plen, bool add_l2);
    1182        1828 :         virtual ~VmiReceiveRoute() {}
    1183             : 
    1184             :         bool operator() (const VmiReceiveRoute &lhs,
    1185             :                          const VmiReceiveRoute &rhs) const;
    1186             :         bool IsLess(const VmiReceiveRoute *rhs) const;
    1187             : 
    1188             :         VmInterfaceState::Op GetOpL2(const Agent *agent,
    1189             :                 const VmInterface *vmi) const;
    1190             :         bool DeleteL2(const Agent *agent, VmInterface *vmi) const;
    1191             :         bool AddL2(const Agent *agent, VmInterface *vmi) const;
    1192             : 
    1193             :         void Copy(const Agent *agent, const VmInterface *vmi) const;
    1194             :         VmInterfaceState::Op GetOpL3(const Agent *agent,
    1195             :                                      const VmInterface *vmi) const;
    1196             :         bool AddL3(const Agent *agent, VmInterface *vmi) const;
    1197             :         bool DeleteL3(const Agent *agent, VmInterface *vmi) const;
    1198             : 
    1199             :         IpAddress  addr_;
    1200             :         uint32_t   plen_;
    1201             :         bool       add_l2_; //Pick mac from interface and then add l2 route
    1202             :         mutable VrfEntryRef vrf_;
    1203             :     };
    1204             : 
    1205             :     typedef std::set<VmiReceiveRoute, VmiReceiveRoute> VmiReceiveRouteSet;
    1206             : 
    1207             :     struct VmiReceiveRouteList : List {
    1208        1808 :         VmiReceiveRouteList() : List(), list_() { }
    1209        1808 :         ~VmiReceiveRouteList() { }
    1210             :         void Insert(const VmiReceiveRoute *rhs);
    1211             :         void Update(const VmiReceiveRoute *lhs, const VmiReceiveRoute *rhs);
    1212             :         void Remove(VmiReceiveRouteSet::iterator &it);
    1213             : 
    1214             :         bool UpdateList(const Agent *agent, VmInterface *vmi,
    1215             :                         VmInterfaceState::Op l2_force_op,
    1216             :                         VmInterfaceState::Op l3_force_op);
    1217             :         VmiReceiveRouteSet list_;
    1218             :     };
    1219             : 
    1220             :     enum Trace {
    1221             :         ADD,
    1222             :         DEL,
    1223             :         ACTIVATED_IPV4,
    1224             :         ACTIVATED_IPV6,
    1225             :         ACTIVATED_L2,
    1226             :         DEACTIVATED_IPV4,
    1227             :         DEACTIVATED_IPV6,
    1228             :         DEACTIVATED_L2,
    1229             :         FLOATING_IP_CHANGE,
    1230             :         SERVICE_CHANGE,
    1231             :         VMI_REUSE,
    1232             :         VRF_REUSE,
    1233             :     };
    1234             : 
    1235             :     VmInterface(const boost::uuids::uuid &uuid,
    1236             :                 const std::string &name,
    1237             :                 bool os_oper_state,
    1238             :                 const boost::uuids::uuid &logical_router_uuid);
    1239             :     VmInterface(const boost::uuids::uuid &uuid, const std::string &name,
    1240             :                 const Ip4Address &addr, const MacAddress &mac,
    1241             :                 const std::string &vm_name,
    1242             :                 const boost::uuids::uuid &vm_project_uuid, uint16_t tx_vlan_id,
    1243             :                 uint16_t rx_vlan_id, Interface *parent,
    1244             :                 const Ip6Address &addr6, DeviceType dev_type, VmiType vmi_type,
    1245             :                 uint8_t vhostuser_mode, bool os_oper_state,
    1246             :                 const boost::uuids::uuid &logical_router_uuid);
    1247             :     virtual ~VmInterface();
    1248             : 
    1249             :     virtual bool CmpInterface(const DBEntry &rhs) const;
    1250             :     virtual void GetOsParams(Agent *agent);
    1251             :     void SendTrace(const AgentDBTable *table, Trace event) const;
    1252             :     bool Delete(const DBRequest *req);
    1253             :     void Add();
    1254             : 
    1255             :     // DBEntry virtual methods
    1256             :     KeyPtr GetDBRequestKey() const;
    1257             :     std::string ToString() const;
    1258             :     bool Resync(const InterfaceTable *table, const VmInterfaceData *data);
    1259             :     bool OnChange(VmInterfaceData *data);
    1260             :     void PostAdd();
    1261             : 
    1262             :     // get/set accessor functions
    1263         377 :     const VmEntry *vm() const { return vm_.get(); }
    1264        1994 :     const VnEntry *vn() const { return vn_.get(); }
    1265         125 :     VnEntry *GetNonConstVn() const { return vn_.get(); }
    1266        1731 :     const Ip4Address &primary_ip_addr() const { return primary_ip_addr_; }
    1267             :     void set_primary_ip_addr(const Ip4Address &addr) { primary_ip_addr_ = addr; }
    1268             : 
    1269         922 :     bool policy_enabled() const { return policy_enabled_; }
    1270             :     const Ip4Address &subnet_bcast_addr() const { return subnet_bcast_addr_; }
    1271           0 :     const Ip4Address &vm_ip_service_addr() const { return vm_ip_service_addr_; }
    1272        1380 :     const Ip6Address &primary_ip6_addr() const { return primary_ip6_addr_; }
    1273         898 :     const MacAddress &vm_mac() const { return vm_mac_; }
    1274           2 :     void set_vm_mac(const MacAddress &mac) { vm_mac_ = mac; }
    1275           0 :     bool fabric_port() const { return fabric_port_; }
    1276         298 :     bool need_linklocal_ip() const { return  need_linklocal_ip_; }
    1277          95 :     bool drop_new_flows() const { return drop_new_flows_; }
    1278             :     void set_device_type(VmInterface::DeviceType type) {device_type_ = type;}
    1279             :     void set_vmi_type(VmInterface::VmiType type) {vmi_type_ = type;}
    1280        2319 :     VmInterface::DeviceType device_type() const {return device_type_;}
    1281        2321 :     VmInterface::VmiType vmi_type() const {return vmi_type_;}
    1282        1404 :     VmInterface::HbsIntfType hbs_intf_type() const {return hbs_intf_type_;}
    1283           0 :     bool admin_state() const { return admin_state_; }
    1284         151 :     const AclDBEntry* vrf_assign_acl() const {
    1285         151 :         return vrf_assign_rule_list_.vrf_assign_acl_.get();
    1286             :     }
    1287             :     const Peer *peer() const;
    1288         267 :     uint32_t ethernet_tag() const {return ethernet_tag_;}
    1289          14 :     Ip4Address dhcp_addr() const { return dhcp_addr_; }
    1290           0 :     IpAddress service_health_check_ip() const { return service_health_check_ip_; }
    1291           0 :     const VmiEcmpLoadBalance &ecmp_load_balance() const {return ecmp_load_balance_;}
    1292          95 :     bool is_vn_qos_config() const { return is_vn_qos_config_; }
    1293             : 
    1294         272 :     bool learning_enabled() const { return learning_enabled_; }
    1295             :     void set_learning_enabled(bool val) { learning_enabled_ = val; }
    1296             : 
    1297         136 :     bool etree_leaf() const { return etree_leaf_; }
    1298             :     void set_etree_leaf(bool val) { etree_leaf_ = val; }
    1299             : 
    1300           4 :     void set_hbs_intf_type(VmInterface::HbsIntfType val) { hbs_intf_type_ = val ;}
    1301         175 :     bool pbb_interface() const { return pbb_interface_; }
    1302           1 :     void set_pbb_interface(bool val) { pbb_interface_= val;}
    1303             : 
    1304          41 :     bool layer2_control_word() const { return layer2_control_word_; }
    1305             :     void set_layer2_control_word(bool val) { layer2_control_word_ = val; }
    1306             : 
    1307             :     const NextHop* l3_interface_nh_no_policy() const;
    1308             :     const NextHop* l2_interface_nh_no_policy() const;
    1309             :     const NextHop* l2_interface_nh_policy() const;
    1310             : 
    1311         843 :     const std::string &cfg_name() const { return cfg_name_; }
    1312        2422 :     uint16_t tx_vlan_id() const { return tx_vlan_id_; }
    1313        1249 :     uint16_t rx_vlan_id() const { return rx_vlan_id_; }
    1314        1154 :     uint8_t vhostuser_mode() const { return vhostuser_mode_; }
    1315        2797 :     const Interface *parent() const {
    1316        2797 :         if (agent()->is_l3mh() == false &&
    1317        3632 :             vmi_type_ == VHOST &&
    1318         835 :             parent_list_.empty() == false) {
    1319         835 :             return parent_list_[0];
    1320             :         }
    1321        1962 :         return parent_.get();
    1322             :     }
    1323           0 :     bool ecmp() const { return ecmp_;}
    1324           0 :     bool ecmp6() const { return ecmp6_;}
    1325             :     Ip4Address service_ip() { return service_ip_;}
    1326             :     bool service_ip_ecmp() const { return service_ip_ecmp_;}
    1327             :     Ip6Address service_ip6() { return service_ip6_;}
    1328             :     bool service_ip_ecmp6() const { return service_ip_ecmp6_;}
    1329          97 :     bool flood_unknown_unicast() const { return flood_unknown_unicast_; }
    1330         517 :     bool bridging() const { return bridging_; }
    1331         770 :     bool layer3_forwarding() const { return layer3_forwarding_; }
    1332           3 :     void set_layer3_forwarding(bool val) { layer3_forwarding_ = val; }
    1333         169 :     const std::string &vm_name() const { return vm_name_; }
    1334           0 :     const std::string &vrf_name() const { return vrf_name_; }
    1335           0 :     const boost::uuids::uuid &vm_project_uuid() const {return vm_project_uuid_;}
    1336             : 
    1337           6 :     uint32_t local_preference() const { return local_preference_; }
    1338             :     void SetPathPreference(PathPreference *pref, bool ecmp,
    1339             :                            const IpAddress &dependent_ip) const;
    1340             : 
    1341           0 :     const OperDhcpOptions &oper_dhcp_options() const {
    1342           0 :         return oper_dhcp_options_;
    1343             :     }
    1344         157 :     bool dhcp_enable_config() const { return dhcp_enable_; }
    1345           2 :     void set_dhcp_enable_config(bool dhcp_enable) {dhcp_enable_= dhcp_enable;}
    1346           5 :     bool dhcp_enable_v6_config() const { return dhcp_enable_v6_; }
    1347           4 :     void set_dhcp_enable_v6_config(bool dhcp_enable_v6) {dhcp_enable_v6_= dhcp_enable_v6;}
    1348         124 :     bool do_dhcp_relay() const { return do_dhcp_relay_; }
    1349             : 
    1350           0 :     bool cfg_igmp_enable() const { return cfg_igmp_enable_; }
    1351         311 :     bool igmp_enabled() const { return igmp_enabled_; }
    1352         346 :     bool mac_ip_learning_enable() const { return mac_ip_learning_enable_; }
    1353          96 :     uint32_t max_flows() const { return max_flows_; }
    1354             :     void set_max_flows( uint32_t val) { max_flows_ = val;}
    1355         777 :     ProxyArpMode proxy_arp_mode() const { return proxy_arp_mode_; }
    1356             :     bool IsUnrestrictedProxyArp() const {
    1357             :         return proxy_arp_mode_ == PROXY_ARP_UNRESTRICTED;
    1358             :     }
    1359             : 
    1360        1201 :     int vxlan_id() const { return vxlan_id_; }
    1361             :     void set_vxlan_id(int vxlan_id) { vxlan_id_ = vxlan_id; }
    1362             :     bool IsVxlanMode() const;
    1363             : 
    1364             :     uint8_t configurer() const {return configurer_;}
    1365             :     bool IsConfigurerSet(VmInterface::Configurer type);
    1366             :     void SetConfigurer(VmInterface::Configurer type);
    1367             :     void ResetConfigurer(VmInterface::Configurer type);
    1368             :     bool CanBeDeleted() const {return (configurer_ == 0);}
    1369             : 
    1370         124 :     const Ip4Address& subnet() const { return subnet_;}
    1371         124 :     const uint8_t subnet_plen() const { return subnet_plen_;}
    1372             :     const MacAddress& GetVifMac(const Agent*) const;
    1373         194 :     const boost::uuids::uuid &logical_interface() const {
    1374         194 :         return logical_interface_;
    1375             :     }
    1376             : 
    1377          43 :     const MirrorEntry *mirror_entry() const { return mirror_entry_.get(); }
    1378             :     void set_mirror_entry (MirrorEntry *entry) { mirror_entry_ = entry; }
    1379             :     bool IsMirrorEnabled() const { return mirror_entry_.get() != NULL; }
    1380          43 :     Interface::MirrorDirection mirror_direction() const {
    1381          43 :         return mirror_direction_;
    1382             :     }
    1383             :     void set_mirror_direction(Interface::MirrorDirection mirror_direction) {
    1384             :         mirror_direction_ = mirror_direction;
    1385             :     }
    1386             : 
    1387           0 :     uint32_t FloatingIpCount() const {return floating_ip_list_.list_.size();}
    1388         211 :     const FloatingIpList &floating_ip_list() const {return floating_ip_list_;}
    1389             :     bool HasFloatingIp(Address::Family family) const;
    1390             :     bool HasFloatingIp() const;
    1391             :     bool IsFloatingIp(const IpAddress &ip) const;
    1392         534 :     size_t GetFloatingIpCount() const {return floating_ip_list_.list_.size();}
    1393             : 
    1394           0 :     const AliasIpList &alias_ip_list() const {
    1395           0 :         return alias_ip_list_;
    1396             :     }
    1397             :     VrfEntry *GetAliasIpVrf(const IpAddress &ip) const;
    1398             :     size_t GetAliasIpCount() const { return alias_ip_list_.list_.size(); }
    1399             :     void CleanupAliasIpList();
    1400             : 
    1401           0 :     const StaticRouteList &static_route_list() const {
    1402           0 :         return static_route_list_;
    1403             :     }
    1404         340 :     const SecurityGroupEntryList &sg_list() const {
    1405         340 :         return sg_list_;
    1406             :     }
    1407             :     void CopySgIdList(SecurityGroupList *sg_id_list) const;
    1408             :     void CopyTagIdList(TagList *tag_id_list) const;
    1409             : 
    1410           0 :     const TagEntryList &tag_list() const {
    1411           0 :         return tag_list_;
    1412             :     }
    1413             : 
    1414             :     const VrfAssignRuleList &vrf_assign_rule_list() const {
    1415             :         return vrf_assign_rule_list_;
    1416             :     }
    1417             : 
    1418         190 :     const AllowedAddressPairList &allowed_address_pair_list() const {
    1419         190 :         return allowed_address_pair_list_;
    1420             :     }
    1421             : 
    1422           6 :     const InstanceIpList &instance_ipv4_list() const {
    1423           6 :         return instance_ipv4_list_;
    1424             :     }
    1425             : 
    1426           2 :     const InstanceIpList &instance_ipv6_list() const {
    1427           2 :         return instance_ipv6_list_;
    1428             :     }
    1429             : 
    1430         118 :     const FatFlowList &fat_flow_list() const {
    1431         118 :         return fat_flow_list_;
    1432             :     }
    1433           0 :     const LearntMacIpList &learnt_mac_ip_list() const {
    1434           0 :         return learnt_mac_ip_list_;
    1435             :     }
    1436             :     bool IsFatFlowPortBased(uint8_t protocol, uint16_t port,
    1437             :                             FatFlowIgnoreAddressType *ignore_addr) const;
    1438             :     bool ExcludeFromFatFlow(Address::Family family, const IpAddress &sip,
    1439             :                             const IpAddress &dip) const;
    1440             :     bool MatchSrcPrefixPort(uint8_t protocol, uint16_t port, IpAddress *src_ip,
    1441             :                             FatFlowIgnoreAddressType *ignore_addr) const;
    1442             :     bool MatchSrcPrefixRule(uint8_t protocol, uint16_t *sport,
    1443             :                             uint16_t *dport, bool *same_port_num,
    1444             :                             IpAddress *SrcIP,
    1445             :                             FatFlowIgnoreAddressType *ignore_addr) const;
    1446             :     bool MatchDstPrefixPort(uint8_t protocol, uint16_t port, IpAddress *dst_ip,
    1447             :                             FatFlowIgnoreAddressType *ignore_addr) const;
    1448             :     bool MatchDstPrefixRule(uint8_t protocol, uint16_t *sport,
    1449             :                             uint16_t *dport, bool *same_port_num,
    1450             :                             IpAddress *DstIP,
    1451             :                             FatFlowIgnoreAddressType *ignore_addr) const;
    1452             :     bool MatchSrcDstPrefixPort(uint8_t protocol, uint16_t port, IpAddress *src_ip,
    1453             :                                IpAddress *dst_ip) const;
    1454             :     bool MatchSrcDstPrefixRule(uint8_t protocol, uint16_t *sport,
    1455             :                                uint16_t *dport, bool *same_port_num,
    1456             :                                IpAddress *SrcIP, IpAddress *DstIP) const;
    1457             :     bool IsFatFlowPrefixAggregation(bool ingress, uint8_t protocol, uint16_t *sport,
    1458             :                                     uint16_t *dport, bool *same_port_num,
    1459             :                                     IpAddress *SrcIP, IpAddress *DstIP,
    1460             :                                     bool *is_src_prefix, bool *is_dst_prefix,
    1461             :                                     FatFlowIgnoreAddressType *ignore_addr) const;
    1462             : 
    1463          78 :     const BridgeDomainList &bridge_domain_list() const {
    1464          78 :         return bridge_domain_list_;
    1465             :     }
    1466             : 
    1467             :     const VmiReceiveRouteList &receive_route_list() const {
    1468             :         return receive_route_list_;
    1469             :     }
    1470             : 
    1471             :     void set_subnet_bcast_addr(const Ip4Address &addr) {
    1472             :         subnet_bcast_addr_ = addr;
    1473             :     }
    1474             : 
    1475         522 :     VrfEntry *forwarding_vrf() const {
    1476         522 :         return forwarding_vrf_.get();
    1477             :     }
    1478             : 
    1479             :     Ip4Address mdata_ip_addr() const;
    1480             :     Ip6Address mdata_ip6_addr() const;
    1481             :     MetaDataIp *GetMetaDataIp(const IpAddress &ip) const;
    1482             :     void InsertMetaDataIpInfo(MetaDataIp *mip);
    1483             :     void DeleteMetaDataIpInfo(MetaDataIp *mip);
    1484             :     void UpdateMetaDataIpInfo();
    1485             : 
    1486             :     void InsertHealthCheckInstance(HealthCheckInstanceBase *hc_inst);
    1487             :     void DeleteHealthCheckInstance(HealthCheckInstanceBase *hc_inst);
    1488             :     const HealthCheckInstanceSet &hc_instance_set() const;
    1489             :     bool IsHealthCheckEnabled() const;
    1490             :     void UpdateInterfaceHealthCheckService();
    1491             : 
    1492           0 :     const ServiceVlanList &service_vlan_list() const {
    1493           0 :         return service_vlan_list_;
    1494             :     }
    1495         325 :     bool HasServiceVlan() const { return service_vlan_list_.list_.size() != 0; }
    1496             : 
    1497        3635 :     Agent *agent() const {
    1498        3635 :         return (static_cast<InterfaceTable *>(get_table()))->agent();
    1499             :     }
    1500             :     uint32_t GetServiceVlanLabel(const VrfEntry *vrf) const;
    1501             :     const VrfEntry* GetServiceVlanVrf(uint16_t vlan_tag) const;
    1502             :     bool OnResyncServiceVlan(VmInterfaceConfigData *data);
    1503             :     void SetServiceVlanPathPreference(PathPreference *pref,
    1504             :                                       const IpAddress &service_ip) const;
    1505             : 
    1506          41 :     const UuidList &slo_list() const {
    1507          41 :         return slo_list_;
    1508             :     }
    1509             : 
    1510             :     const std::string GetAnalyzer() const;
    1511             :     bool IsL2Active() const;
    1512             :     bool IsIpv6Active() const;
    1513             : 
    1514             :     bool WaitForTraffic() const;
    1515             :     bool GetInterfaceDhcpOptions(
    1516             :             std::vector<autogen::DhcpOptionType> *options) const;
    1517             :     bool GetSubnetDhcpOptions(
    1518             :             std::vector<autogen::DhcpOptionType> *options, bool ipv6) const;
    1519             :     bool GetIpamDhcpOptions(
    1520             :             std::vector<autogen::DhcpOptionType> *options, bool ipv6) const;
    1521             :     IpAddress GetServiceIp(const IpAddress &ip) const;
    1522             :     IpAddress GetGatewayIp(const IpAddress &ip) const;
    1523             : 
    1524             :     bool NeedDevice() const;
    1525             :     bool NeedOsStateWithoutDevice() const;
    1526             :     bool IsActive() const;
    1527             :     bool InstallBridgeRoutes() const;
    1528             :     bool IsBareMetal() const {return (vmi_type_ == BAREMETAL);}
    1529             : 
    1530             :     bool NeedMplsLabel() const;
    1531             :     bool SgExists(const boost::uuids::uuid &id, const SgList &sg_l);
    1532             :     const MacAddress& GetIpMac(const IpAddress &,
    1533             :                               const uint8_t plen) const;
    1534             :     bool MatchAapIp(const IpAddress &ip, uint8_t plen) const;
    1535             :     void BuildIpStringList(Address::Family family,
    1536             :                            std::vector<std::string> *vect) const;
    1537             : 
    1538             :     uint32_t GetIsid() const;
    1539             :     uint32_t GetPbbVrf() const;
    1540             :     uint32_t GetPbbLabel() const;
    1541             : 
    1542             :     // Label for opposite policy mode (old label before toggling policy mode)
    1543             :     uint32_t label_op() const;
    1544             : 
    1545             :     void GetNextHopInfo();
    1546             :     bool UpdatePolicySet(const Agent *agent);
    1547         213 :     const FirewallPolicyList& fw_policy_list() const {
    1548         213 :         return fw_policy_list_;
    1549             :     }
    1550         213 :     const FirewallPolicyList& fwaas_fw_policy_list() const {
    1551         213 :         return fwaas_fw_policy_list_;
    1552             :     }
    1553          94 :     const boost::uuids::uuid& vmi_cfg_uuid() const {
    1554          94 :         return vmi_cfg_uuid_;
    1555             :     }
    1556             : 
    1557           8 :     bool is_left_si() const { return is_left_si_; }
    1558             :     enum ServiceMode{
    1559             :         BRIDGE_MODE,
    1560             :         ROUTED_MODE,
    1561             :         ROUTED_NAT_MODE,
    1562             :         SERVICE_MODE_ERROR,
    1563             :     };
    1564           0 :     uint32_t service_mode() {
    1565           0 :         return service_mode_;
    1566             :     }
    1567           0 :     const boost::uuids::uuid &si_other_end_vmi() const {
    1568           0 :         return si_other_end_vmi_;
    1569             :     }
    1570         100 :     const std::string &service_intf_type() const { return service_intf_type_; }
    1571           4 :     void set_service_intf_type(std::string type) { service_intf_type_ = type; }
    1572             :     VmInterface * PortTuplePairedInterface() const;
    1573             :     void BuildFatFlowExcludeList(FatFlowExcludeList *list) const;
    1574             :     bool IsMaxMacIpLearnt() const;
    1575             : 
    1576             :     // Static methods
    1577             :     // Add a vm-interface
    1578             :     static void NovaAdd(InterfaceTable *table,
    1579             :                         const boost::uuids::uuid &intf_uuid,
    1580             :                         const std::string &os_name, const Ip4Address &addr,
    1581             :                         const std::string &mac, const std::string &vn_name,
    1582             :                         const boost::uuids::uuid &vm_project_uuid,
    1583             :                         uint16_t tx_vlan_id, uint16_t rx_vlan_id,
    1584             :                         const std::string &parent, const Ip6Address &ipv6,
    1585             :                         uint8_t vhostuser_mode,
    1586             :                         Interface::Transport transport, uint8_t link_state);
    1587             :     // Del a vm-interface
    1588             :     static void Delete(InterfaceTable *table,
    1589             :                        const boost::uuids::uuid &intf_uuid,
    1590             :                        VmInterface::Configurer configurer);
    1591             :     static void SetIfNameReq(InterfaceTable *table,
    1592             :                              const boost::uuids::uuid &uuid,
    1593             :                              const std::string &ifname);
    1594             :     static void DeleteIfNameReq(InterfaceTable *table,
    1595             :                                 const boost::uuids::uuid &uuid);
    1596             :     void update_flow_count(int val) const;
    1597           0 :     uint32_t flow_count() const { return flow_count_; }
    1598         896 :     InterfaceList parent_list() const { return parent_list_; }
    1599           0 :     const bool &contains_new_tags() const { return contains_new_tags_; }
    1600             : 
    1601             : 
    1602             : private:
    1603             :     friend struct VmInterfaceConfigData;
    1604             :     friend struct VmInterfaceNovaData;
    1605             :     friend struct VmInterfaceIpAddressData;
    1606             :     friend struct VmInterfaceOsOperStateData;
    1607             :     friend struct VmInterfaceMirrorData;
    1608             :     friend struct VmInterfaceGlobalVrouterData;
    1609             :     friend struct VmInterfaceHealthCheckData;
    1610             :     friend struct VmInterfaceNewFlowDropData;
    1611             :     friend struct ResolveRouteState;
    1612             :     friend struct VmiRouteState;
    1613             :     friend struct VmInterfaceLearntMacIpData;
    1614             : 
    1615             :     virtual void ObtainOsSpecificParams(const std::string &name, Agent *agent);
    1616             : 
    1617             :     bool IsMetaDataL2Active() const;
    1618             :     bool IsMetaDataIPActive() const;
    1619             :     bool IsIpv4Active() const;
    1620             :     bool PolicyEnabled() const;
    1621             :     void FillV4ExcludeIp(uint64_t plen, const Ip4Address &ip,
    1622             :                          FatFlowExcludeList *list) const;
    1623             :     void FillV6ExcludeIp(uint16_t plen, const IpAddress &ip,
    1624             :                          FatFlowExcludeList *list) const;
    1625             : 
    1626             :     bool CopyConfig(const InterfaceTable *table,
    1627             :                     const VmInterfaceConfigData *data, bool *sg_changed,
    1628             :                     bool *ecmp_changed, bool *local_pref_changed,
    1629             :                     bool *ecmp_load_balance_changed,
    1630             :                     bool *static_route_config_changed,
    1631             :                     bool *etree_leaf_mode_changed,
    1632             :                     bool *tag_changed);
    1633             :     void ApplyConfig(bool old_ipv4_active,bool old_l2_active,
    1634             :                      bool old_ipv6_active,
    1635             :                      const Ip4Address &old_subnet,
    1636             :                      const uint8_t old_subnet_plen);
    1637             : 
    1638             :     void UpdateL2();
    1639             :     void DeleteL2();
    1640             : 
    1641             :     void AddRoute(const std::string &vrf_name, const IpAddress &ip,
    1642             :                   uint32_t plen, const std::string &vn_name, bool force_policy,
    1643             :                   bool ecmp, bool is_local, bool proxy_arp,
    1644             :                   const IpAddress &service_ip, const IpAddress &dependent_ip,
    1645             :                   const CommunityList &communties, uint32_t label,
    1646             :                   const string &intf_route_type, bool is_learnt_route = false);
    1647             :     void DeleteRoute(const std::string &vrf_name, const IpAddress &ip,
    1648             :                      uint32_t plen);
    1649             : 
    1650             :     bool OnResyncSecurityGroupList(VmInterfaceConfigData *data,
    1651             :                                    bool new_ipv4_active);
    1652             :     bool ResyncIpAddress(const VmInterfaceIpAddressData *data);
    1653             :     bool ResyncOsOperState(const VmInterfaceOsOperStateData *data);
    1654             :     bool ResyncConfig(VmInterfaceConfigData *data);
    1655             :     bool CopyIpAddress(Ip4Address &addr);
    1656             :     bool CopyIp6Address(const Ip6Address &addr);
    1657             :     bool ResetVrfDelete(const InterfaceTable *table, const std::string &vrf_name);
    1658             : 
    1659             :     void CleanupFloatingIpList();
    1660             : 
    1661             :     bool OnResyncStaticRoute(VmInterfaceConfigData *data, bool new_ipv4_active);
    1662             : 
    1663             :     void AddL2InterfaceRoute(const IpAddress &ip, const MacAddress &mac,
    1664             :                              const IpAddress &dependent_ip) const;
    1665             :     void DeleteL2InterfaceRoute(const VrfEntry *vrf, uint32_t ethernet_tag,
    1666             :                                 const IpAddress &ip,
    1667             :                                 const MacAddress &mac) const;
    1668             : 
    1669             :     bool UpdateIsHealthCheckActive();
    1670             :     void CopyEcmpLoadBalance(EcmpLoadBalance &ecmp_load_balance);
    1671             : 
    1672             :     bool UpdateState(const VmInterfaceState *attr,
    1673             :                      VmInterfaceState::Op l2_force_op,
    1674             :                      VmInterfaceState::Op l3_force_op);
    1675             :     bool DeleteState(VmInterfaceState *attr);
    1676           2 :     static IgnoreAddressMap InitIgnoreAddressMap() {
    1677           2 :         IgnoreAddressMap value;
    1678           2 :         value[""] = IGNORE_NONE;
    1679           2 :         value["none"] = IGNORE_NONE;
    1680           2 :         value["source"] = IGNORE_SOURCE;
    1681           2 :         value["destination"] = IGNORE_DESTINATION;
    1682           2 :         return value;
    1683           0 :     }
    1684             : 
    1685             :     void SetInterfacesDropNewFlows(bool drop_new_flows) const;
    1686             :     bool copyMacIpData(const VmInterfaceLearntMacIpData *data);
    1687             : 
    1688             : private:
    1689             :     static IgnoreAddressMap fatflow_ignore_addr_map_;
    1690             :     VmEntryBackRef vm_;
    1691             :     VnEntryRef vn_;
    1692             :     Ip4Address primary_ip_addr_;
    1693             :     Ip4Address subnet_bcast_addr_;
    1694             :     Ip6Address primary_ip6_addr_;
    1695             :     MacAddress vm_mac_;
    1696             :     bool policy_enabled_;
    1697             :     MirrorEntryRef mirror_entry_;
    1698             :     Interface::MirrorDirection mirror_direction_;
    1699             :     std::string cfg_name_;
    1700             :     bool fabric_port_;
    1701             :     bool need_linklocal_ip_;
    1702             :     bool drop_new_flows_;
    1703             :     mutable bool drop_new_flows_vmi_;
    1704             :     // DHCP flag - set according to the dhcp option in the ifmap subnet object.
    1705             :     // It controls whether the vrouter sends the DHCP requests from VM interface
    1706             :     // to agent or if it would flood the request in the VN.
    1707             :     bool dhcp_enable_;
    1708             :     bool dhcp_enable_v6_;
    1709             :     // true if IP is to be obtained from DHCP Relay and not learnt from fabric
    1710             :     bool do_dhcp_relay_;
    1711             :     // Proxy ARP mode for interface
    1712             :     ProxyArpMode proxy_arp_mode_;
    1713             :     // VM-Name. Used by DNS
    1714             :     std::string vm_name_;
    1715             :     std::string vrf_name_;
    1716             :     // project uuid of the vm to which the interface belongs
    1717             :     boost::uuids::uuid vm_project_uuid_;
    1718             :     int vxlan_id_;
    1719             :     bool bridging_;
    1720             :     bool layer3_forwarding_;
    1721             :     bool flood_unknown_unicast_;
    1722             :     bool mac_set_;
    1723             :     bool ecmp_;
    1724             :     bool ecmp6_;
    1725             :     Ip4Address service_ip_;
    1726             :     bool service_ip_ecmp_;
    1727             :     Ip6Address service_ip6_;
    1728             :     bool service_ip_ecmp6_;
    1729             :     // disable-policy configuration on VMI. When this is configured, policy
    1730             :     // dependent features like flows, floating-IP and SG will not work on this
    1731             :     // VMI. However metadata-services will work because metadata route will
    1732             :     // still point to policy enabled NH.
    1733             :     bool disable_policy_;
    1734             :     // VLAN Tag and the parent interface when VLAN is enabled
    1735             :     uint16_t tx_vlan_id_;
    1736             :     uint16_t rx_vlan_id_;
    1737             :     InterfaceBackRef parent_;
    1738             :     uint32_t local_preference_;
    1739             :     // DHCP options defined for the interface
    1740             :     OperDhcpOptions oper_dhcp_options_;
    1741             :     // IGMP Configuration
    1742             :     bool cfg_igmp_enable_;
    1743             :     bool igmp_enabled_;
    1744             :     bool mac_ip_learning_enable_;
    1745             :     // Max flows for VMI
    1746             :     uint32_t max_flows_;
    1747             :     mutable std::atomic<int> flow_count_;
    1748             : 
    1749             :     // Attributes
    1750             :     std::unique_ptr<MacVmBindingState> mac_vm_binding_state_;
    1751             :     std::unique_ptr<NextHopState> nexthop_state_;
    1752             :     std::unique_ptr<VrfTableLabelState> vrf_table_label_state_;
    1753             :     std::unique_ptr<MetaDataIpState> metadata_ip_state_;
    1754             :     std::unique_ptr<MetaDataIpState> metadata_ip6_state_;
    1755             :     std::unique_ptr<ResolveRouteState> resolve_route_state_;
    1756             :     std::unique_ptr<VmiRouteState> interface_route_state_;
    1757             : 
    1758             :     // Lists
    1759             :     SecurityGroupEntryList sg_list_;
    1760             :     TagEntryList tag_list_;
    1761             :     FloatingIpList floating_ip_list_;
    1762             :     AliasIpList alias_ip_list_;
    1763             :     ServiceVlanList service_vlan_list_;
    1764             :     StaticRouteList static_route_list_;
    1765             :     AllowedAddressPairList allowed_address_pair_list_;
    1766             :     InstanceIpList instance_ipv4_list_;
    1767             :     InstanceIpList instance_ipv6_list_;
    1768             :     FatFlowList fat_flow_list_;
    1769             :     BridgeDomainList bridge_domain_list_;
    1770             :     VrfAssignRuleList vrf_assign_rule_list_;
    1771             :     VmiReceiveRouteList receive_route_list_;
    1772             :     LearntMacIpList learnt_mac_ip_list_;
    1773             : 
    1774             :     // Peer for interface routes
    1775             :     std::unique_ptr<LocalVmPortPeer> peer_;
    1776             :     Ip4Address vm_ip_service_addr_;
    1777             :     VmInterface::DeviceType device_type_;
    1778             :     VmInterface::VmiType vmi_type_;
    1779             :     VmInterface::HbsIntfType hbs_intf_type_;
    1780             :     uint8_t configurer_;
    1781             :     Ip4Address subnet_;
    1782             :     uint8_t subnet_plen_;
    1783             :     int ethernet_tag_;
    1784             :     // Logical interface uuid to which the interface belongs
    1785             :     boost::uuids::uuid logical_interface_;
    1786             :     Ip4Address nova_ip_addr_;
    1787             :     Ip6Address nova_ip6_addr_;
    1788             :     Ip4Address dhcp_addr_;
    1789             :     MetaDataIpMap metadata_ip_map_;
    1790             :     HealthCheckInstanceSet hc_instance_set_;
    1791             :     VmiEcmpLoadBalance ecmp_load_balance_;
    1792             :     IpAddress service_health_check_ip_;
    1793             :     bool is_vn_qos_config_;
    1794             :     bool learning_enabled_;
    1795             :     bool etree_leaf_;
    1796             :     bool pbb_interface_;
    1797             :     bool layer2_control_word_;
    1798             :     //Includes global policy apply and application policy set
    1799             :     FirewallPolicyList fw_policy_list_;
    1800             :     FirewallPolicyList fwaas_fw_policy_list_;
    1801             :     UuidList slo_list_;
    1802             :     VrfEntryRef forwarding_vrf_;
    1803             :     // vhostuser mode
    1804             :     uint8_t vhostuser_mode_;
    1805             :     // indicates if the VMI is the left interface of a service instance
    1806             :     bool is_left_si_;
    1807             :     uint32_t service_mode_;
    1808             :     /* If current interface is SI VMI, then the below field indicates the VMI
    1809             :      * uuid of the other end of SI. If current VMI is left VMI of SI si1, then
    1810             :      * below field indicates right VMI of SI si1 and vice versa. This will have
    1811             :      * nil_uuid if current VMI is not SI VMI.
    1812             :      */
    1813             :     boost::uuids::uuid si_other_end_vmi_;
    1814             :     //In case Vhost interface, uuid_ is stored here
    1815             :     boost::uuids::uuid vmi_cfg_uuid_;
    1816             :     std::string service_intf_type_;
    1817             :     InterfaceList parent_list_;
    1818             :     bool contains_new_tags_;
    1819             :     DISALLOW_COPY_AND_ASSIGN(VmInterface);
    1820             : };
    1821             : 
    1822             : /////////////////////////////////////////////////////////////////////////////
    1823             : // Key for VM Interfaces
    1824             : /////////////////////////////////////////////////////////////////////////////
    1825             : struct VmInterfaceKey : public InterfaceKey {
    1826             :     VmInterfaceKey(AgentKey::DBSubOperation sub_op,
    1827             :                    const boost::uuids::uuid &uuid, const std::string &name);
    1828       34076 :     virtual ~VmInterfaceKey() { }
    1829             : 
    1830             :     Interface *AllocEntry(const InterfaceTable *table) const;
    1831             :     Interface *AllocEntry(const InterfaceTable *table,
    1832             :                           const InterfaceData *data) const;
    1833             :     InterfaceKey *Clone() const;
    1834             : };
    1835             : 
    1836             : /////////////////////////////////////////////////////////////////////////////
    1837             : // The base class for different type of InterfaceData used for VmInterfaces.
    1838             : //
    1839             : // Request for VM-Interface data are of 3 types
    1840             : // - ADD_DEL_CHANGE
    1841             : //   Message for ADD/DEL/CHANGE of an interface
    1842             : // - MIRROR
    1843             : //   Data for mirror enable/disable
    1844             : // - IP_ADDR
    1845             : //   In one of the modes, the IP address for an interface is not got from IFMap
    1846             : //   or Nova. Agent will relay DHCP Request in such cases to IP Fabric network.
    1847             : //   The IP address learnt with DHCP in this case is confgured with this type
    1848             : // - OS_OPER_STATE
    1849             : //   Update to oper state of the interface
    1850             : /////////////////////////////////////////////////////////////////////////////
    1851             : struct VmInterfaceData : public InterfaceData {
    1852             :     enum Type {
    1853             :         CONFIG,
    1854             :         INSTANCE_MSG,
    1855             :         MIRROR,
    1856             :         IP_ADDR,
    1857             :         OS_OPER_STATE,
    1858             :         GLOBAL_VROUTER,
    1859             :         HEALTH_CHECK,
    1860             :         DROP_NEW_FLOWS
    1861             :     };
    1862             : 
    1863         203 :     VmInterfaceData(Agent *agent, IFMapNode *node, Type type,
    1864         203 :             Interface::Transport transport) :
    1865         203 :         InterfaceData(agent, node, transport), type_(type) {
    1866         203 :         VmPortInit();
    1867         203 :     }
    1868         203 :     virtual ~VmInterfaceData() { }
    1869             : 
    1870           0 :     virtual VmInterface *OnAdd(const InterfaceTable *table,
    1871             :                                const VmInterfaceKey *key) const {
    1872           0 :         return NULL;
    1873             :     }
    1874           0 :     virtual bool OnDelete(const InterfaceTable *table,
    1875             :                           VmInterface *entry) const {
    1876           0 :         return true;
    1877             :     }
    1878             :     virtual bool OnResync(const InterfaceTable *table, VmInterface *vmi,
    1879             :                           bool *force_update) const = 0;
    1880             : 
    1881             :     Type type_;
    1882             : };
    1883             : 
    1884             : // Structure used when type=IP_ADDR. Used to update IP-Address of VM-Interface
    1885             : // The IP Address is picked up from the DHCP Snoop table
    1886             : struct VmInterfaceIpAddressData : public VmInterfaceData {
    1887           2 :     VmInterfaceIpAddressData() : VmInterfaceData(NULL, NULL, IP_ADDR,
    1888           2 :                                      Interface::TRANSPORT_INVALID) { }
    1889           0 :     virtual ~VmInterfaceIpAddressData() { }
    1890             :     virtual bool OnResync(const InterfaceTable *table, VmInterface *vmi,
    1891             :                           bool *force_update) const;
    1892             : };
    1893             : 
    1894             : // Structure used when type=OS_OPER_STATE Used to update interface os oper-state
    1895             : // The current oper-state is got by querying the device
    1896             : struct VmInterfaceOsOperStateData : public VmInterfaceData {
    1897           0 :     VmInterfaceOsOperStateData(bool status) :
    1898             :         VmInterfaceData(NULL, NULL, OS_OPER_STATE,
    1899           0 :                         Interface::TRANSPORT_INVALID), oper_state_(status) { }
    1900           0 :     virtual ~VmInterfaceOsOperStateData() { }
    1901             :     virtual bool OnResync(const InterfaceTable *table, VmInterface *vmi,
    1902             :                           bool *force_update) const;
    1903             :     bool oper_state_;
    1904             : };
    1905             : 
    1906             : // Structure used when type=MIRROR. Used to update IP-Address of VM-Interface
    1907             : struct VmInterfaceMirrorData : public VmInterfaceData {
    1908           0 :     VmInterfaceMirrorData(bool mirror_enable, const std::string &analyzer_name):
    1909             :         VmInterfaceData(NULL, NULL, MIRROR, Interface::TRANSPORT_INVALID),
    1910           0 :         mirror_enable_(mirror_enable),
    1911           0 :         analyzer_name_(analyzer_name) {
    1912           0 :     }
    1913           0 :     virtual ~VmInterfaceMirrorData() { }
    1914             :     virtual bool OnResync(const InterfaceTable *table, VmInterface *vmi,
    1915             :                           bool *force_update) const;
    1916             : 
    1917             :     bool mirror_enable_;
    1918             :     std::string analyzer_name_;
    1919             : };
    1920             : 
    1921             : // Definition for structures when request queued from IFMap config.
    1922             : struct VmInterfaceConfigData : public VmInterfaceData {
    1923             :     VmInterfaceConfigData(Agent *agent, IFMapNode *node);
    1924         272 :     virtual ~VmInterfaceConfigData() { }
    1925             :     virtual VmInterface *OnAdd(const InterfaceTable *table,
    1926             :                                const VmInterfaceKey *key) const;
    1927             :     virtual bool OnDelete(const InterfaceTable *table,
    1928             :                           VmInterface *entry) const;
    1929             :     virtual bool OnResync(const InterfaceTable *table, VmInterface *vmi,
    1930             :                           bool *force_update) const;
    1931             :     autogen::VirtualMachineInterface *GetVmiCfg() const;
    1932             :     void CopyVhostData(const Agent *agent);
    1933             : 
    1934             :     Ip4Address addr_;
    1935             :     Ip6Address ip6_addr_;
    1936             :     std::string vm_mac_;
    1937             :     std::string cfg_name_;
    1938             :     boost::uuids::uuid vm_uuid_;
    1939             :     std::string vm_name_;
    1940             :     boost::uuids::uuid vn_uuid_;
    1941             :     std::string vrf_name_;
    1942             : 
    1943             :     // Is this port on IP Fabric
    1944             :     bool fabric_port_;
    1945             :     // Does the port need link-local IP to be allocated
    1946             :     bool need_linklocal_ip_;
    1947             :     bool bridging_;
    1948             :     bool layer3_forwarding_;
    1949             :     bool mirror_enable_;
    1950             :     //Is interface in active-active mode or active-backup mode
    1951             :     bool ecmp_;
    1952             :     bool ecmp6_;
    1953             :     bool dhcp_enable_; // is DHCP enabled for the interface (from subnet config)
    1954             :     bool dhcp_enable_v6_; 
    1955             :     VmInterface::ProxyArpMode proxy_arp_mode_;
    1956             :     bool admin_state_;
    1957             :     bool disable_policy_;
    1958             :     std::string analyzer_name_;
    1959             :     uint32_t local_preference_;
    1960             :     OperDhcpOptions oper_dhcp_options_;
    1961             :     Interface::MirrorDirection mirror_direction_;
    1962             :     // IGMP Configuration
    1963             :     bool cfg_igmp_enable_;
    1964             :     bool igmp_enabled_;
    1965             :     bool mac_ip_learning_enable_;
    1966             :     uint32_t max_flows_;
    1967             : 
    1968             :     VmInterface::SecurityGroupEntryList sg_list_;
    1969             :     VmInterface::TagEntryList tag_list_;
    1970             :     VmInterface::FloatingIpList floating_ip_list_;
    1971             :     VmInterface::AliasIpList alias_ip_list_;
    1972             :     VmInterface::ServiceVlanList service_vlan_list_;
    1973             :     VmInterface::StaticRouteList static_route_list_;
    1974             :     VmInterface::VrfAssignRuleList vrf_assign_rule_list_;
    1975             :     VmInterface::AllowedAddressPairList allowed_address_pair_list_;
    1976             :     VmInterface::InstanceIpList instance_ipv4_list_;
    1977             :     VmInterface::InstanceIpList instance_ipv6_list_;
    1978             :     VmInterface::FatFlowList fat_flow_list_;
    1979             :     VmInterface::BridgeDomainList bridge_domain_list_;
    1980             :     VmInterface::VmiReceiveRouteList receive_route_list_;
    1981             :     VmInterface::DeviceType device_type_;
    1982             :     VmInterface::VmiType vmi_type_;
    1983             :     VmInterface::HbsIntfType hbs_intf_type_;
    1984             :     // Parent physical-interface. Used in VMWare/ ToR logical-interface
    1985             :     std::string physical_interface_;
    1986             :     // Parent VMI. Set only for VM_VLAN_ON_VMI
    1987             :     boost::uuids::uuid parent_vmi_;
    1988             :     Ip4Address subnet_;
    1989             :     uint8_t subnet_plen_;
    1990             :     uint16_t rx_vlan_id_;
    1991             :     uint16_t tx_vlan_id_;
    1992             :     boost::uuids::uuid logical_interface_;
    1993             :     VmiEcmpLoadBalance ecmp_load_balance_;
    1994             :     IpAddress service_health_check_ip_;
    1995             :     Ip4Address service_ip_;
    1996             :     bool service_ip_ecmp_;
    1997             :     Ip6Address service_ip6_;
    1998             :     bool service_ip_ecmp6_;
    1999             :     boost::uuids::uuid qos_config_uuid_;
    2000             :     bool learning_enabled_;
    2001             :     UuidList slo_list_;
    2002             :     uint8_t vhostuser_mode_;
    2003             :     bool is_left_si_;
    2004             :     uint32_t service_mode_;
    2005             :     boost::uuids::uuid si_other_end_vmi_;
    2006             :     boost::uuids::uuid vmi_cfg_uuid_;
    2007             :     std::string service_intf_type_;
    2008             :     // Parent physical-interface-list. Used in case of l3mh Vhost0
    2009             :     std::vector<std::string> physical_interface_list_;
    2010             : };
    2011             : 
    2012             : // Definition for structures when request queued from Nova
    2013             : struct VmInterfaceNovaData : public VmInterfaceData {
    2014             :     VmInterfaceNovaData();
    2015             :     VmInterfaceNovaData(const Ip4Address &ipv4_addr,
    2016             :                         const Ip6Address &ipv6_addr,
    2017             :                         const std::string &mac_addr,
    2018             :                         const std::string vm_name,
    2019             :                         boost::uuids::uuid vm_uuid,
    2020             :                         boost::uuids::uuid vm_project_uuid,
    2021             :                         const std::string &parent,
    2022             :                         uint16_t tx_vlan_id,
    2023             :                         uint16_t rx_vlan_id,
    2024             :                         VmInterface::DeviceType device_type,
    2025             :                         VmInterface::VmiType vmi_type,
    2026             :                         uint8_t vhostuser_mode,
    2027             :                         Interface::Transport transport,
    2028             :                         uint8_t link_state);
    2029             :     virtual ~VmInterfaceNovaData();
    2030             :     virtual VmInterface *OnAdd(const InterfaceTable *table,
    2031             :                                const VmInterfaceKey *key) const;
    2032             :     virtual bool OnDelete(const InterfaceTable *table,
    2033             :                           VmInterface *entry) const;
    2034             :     virtual bool OnResync(const InterfaceTable *table, VmInterface *vmi,
    2035             :                           bool *force_update) const;
    2036             : 
    2037             :     Ip4Address ipv4_addr_;
    2038             :     Ip6Address ipv6_addr_;
    2039             :     std::string mac_addr_;
    2040             :     std::string vm_name_;
    2041             :     boost::uuids::uuid vm_uuid_;
    2042             :     boost::uuids::uuid vm_project_uuid_;
    2043             :     std::string physical_interface_;
    2044             :     uint16_t tx_vlan_id_;
    2045             :     uint16_t rx_vlan_id_;
    2046             :     VmInterface::DeviceType device_type_;
    2047             :     VmInterface::VmiType vmi_type_;
    2048             :     uint8_t vhostuser_mode_;
    2049             :     uint8_t link_state_;
    2050             : };
    2051             : 
    2052             : struct VmInterfaceGlobalVrouterData : public VmInterfaceData {
    2053           0 :     VmInterfaceGlobalVrouterData(bool bridging,
    2054             :                                  bool layer3_forwarding,
    2055           0 :                                  int vxlan_id) :
    2056             :         VmInterfaceData(NULL, NULL, GLOBAL_VROUTER, Interface::TRANSPORT_INVALID),
    2057           0 :         bridging_(bridging),
    2058           0 :         layer3_forwarding_(layer3_forwarding),
    2059           0 :         vxlan_id_(vxlan_id) {
    2060           0 :     }
    2061           0 :     virtual ~VmInterfaceGlobalVrouterData() { }
    2062             :     virtual bool OnResync(const InterfaceTable *table, VmInterface *vmi,
    2063             :                           bool *force_update) const;
    2064             : 
    2065             :     bool bridging_;
    2066             :     bool layer3_forwarding_;
    2067             :     int vxlan_id_;
    2068             : };
    2069             : 
    2070             : struct VmInterfaceHealthCheckData : public VmInterfaceData {
    2071             :     VmInterfaceHealthCheckData();
    2072             :     virtual ~VmInterfaceHealthCheckData();
    2073             :     virtual bool OnResync(const InterfaceTable *table, VmInterface *vmi,
    2074             :                           bool *force_update) const;
    2075             : };
    2076             : 
    2077             : struct VmInterfaceNewFlowDropData : public VmInterfaceData {
    2078             :     VmInterfaceNewFlowDropData(bool drop_new_flows);
    2079             :     virtual ~VmInterfaceNewFlowDropData();
    2080             :     virtual bool OnResync(const InterfaceTable *table, VmInterface *vmi,
    2081             :                           bool *force_update) const;
    2082             : 
    2083             :     bool drop_new_flows_;
    2084             : };
    2085             : 
    2086             : // Data used when interface added with only ifname in data
    2087             : struct VmInterfaceIfNameData : public VmInterfaceData {
    2088             :     VmInterfaceIfNameData();
    2089             :     VmInterfaceIfNameData(const std::string &ifname);
    2090             :     virtual ~VmInterfaceIfNameData();
    2091             : 
    2092             :     virtual VmInterface *OnAdd(const InterfaceTable *table,
    2093             :                                const VmInterfaceKey *key) const;
    2094             :     virtual bool OnDelete(const InterfaceTable *table, VmInterface *vmi) const;
    2095             :     virtual bool OnResync(const InterfaceTable *table, VmInterface *vmi,
    2096             :                           bool *force_update) const;
    2097             : 
    2098             :     std::string ifname_;
    2099             : };
    2100             : struct VmInterfaceLearntMacIpData : public VmInterfaceData {
    2101             :     VmInterfaceLearntMacIpData();
    2102             :     virtual ~VmInterfaceLearntMacIpData();
    2103             :     virtual bool OnResync(const InterfaceTable *table, VmInterface *vmi,
    2104             :                           bool *force_update) const;
    2105             :     bool is_add;
    2106             :     VmInterface::LearntMacIpList mac_ip_list_;
    2107             :  
    2108             : };
    2109             : #endif // vnsw_agent_vm_interface_hpp

Generated by: LCOV version 1.14