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