OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vm_interface.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 #include <cmn/agent_cmn.h>
5 #include <init/agent_param.h>
6 #include <oper/operdb_init.h>
7 #include <oper/route_common.h>
8 #include <oper/vm.h>
9 #include <oper/vn.h>
10 #include <oper/vrf.h>
11 #include <oper/nexthop.h>
12 #include <oper/mpls.h>
13 #include <oper/mirror_table.h>
14 #include <oper/metadata_ip.h>
15 #include <oper/interface_common.h>
16 #include <oper/health_check.h>
17 #include <oper/vrf_assign.h>
18 #include <oper/vxlan.h>
19 #include <oper/oper_dhcp_options.h>
21 #include <oper/global_vrouter.h>
22 #include <oper/qos_config.h>
23 #include <oper/bridge_domain.h>
24 #include <oper/sg.h>
25 #include <oper/tag.h>
26 #include <base/address_util.h>
27 #include <filter/acl.h>
28 #include <filter/policy_set.h>
34 
35 using namespace std;
36 using namespace boost::uuids;
37 using namespace autogen;
39  InitIgnoreAddressMap();
40 
41 const char *VmInterface::kInterface = "interface";
42 const char *VmInterface::kServiceInterface = "service-interface";
43 const char *VmInterface::kInterfaceStatic = "interface-static";
44 
46 // VM-Interface entry routines
49  const std::string &name,
50  bool os_oper_state,
51  const boost::uuids::uuid &logical_router_uuid) :
52  Interface(Interface::VM_INTERFACE, uuid, name, NULL, os_oper_state,
53  logical_router_uuid),
54  vm_(NULL, this), vn_(NULL), primary_ip_addr_(0), subnet_bcast_addr_(0),
55  primary_ip6_addr_(), vm_mac_(MacAddress::kZeroMac), policy_enabled_(false),
56  mirror_entry_(NULL), mirror_direction_(MIRROR_RX_TX), cfg_name_(""),
57  fabric_port_(true), need_linklocal_ip_(false), drop_new_flows_(false),
58  dhcp_enable_(true), dhcp_enable_v6_(false), do_dhcp_relay_(false), proxy_arp_mode_(PROXY_ARP_NONE),
59  vm_name_(), vm_project_uuid_(nil_uuid()), vxlan_id_(0), bridging_(false),
60  layer3_forwarding_(true), flood_unknown_unicast_(false),
61  mac_set_(false), ecmp_(false), ecmp6_(false), disable_policy_(false),
62  tx_vlan_id_(kInvalidVlanId), rx_vlan_id_(kInvalidVlanId), parent_(NULL, this),
63  local_preference_(0), oper_dhcp_options_(),
64  cfg_igmp_enable_(false), igmp_enabled_(false),
65  mac_ip_learning_enable_(false), max_flows_(0),
66  mac_vm_binding_state_(new MacVmBindingState()),
67  nexthop_state_(new NextHopState()),
68  vrf_table_label_state_(new VrfTableLabelState()),
69  metadata_ip_state_(new MetaDataIpState()),
70  metadata_ip6_state_(new MetaDataIpState(false)),
71  resolve_route_state_(new ResolveRouteState()),
72  interface_route_state_(new VmiRouteState()),
73  sg_list_(), tag_list_(), floating_ip_list_(), alias_ip_list_(), service_vlan_list_(),
74  static_route_list_(), allowed_address_pair_list_(),
75  instance_ipv4_list_(true), instance_ipv6_list_(false), fat_flow_list_(),
76  vrf_assign_rule_list_(), vm_ip_service_addr_(0),
77  device_type_(VmInterface::DEVICE_TYPE_INVALID),
78  vmi_type_(VmInterface::VMI_TYPE_INVALID),
79  hbs_intf_type_(VmInterface::HBS_INTF_INVALID),
80  configurer_(0), subnet_(0), subnet_plen_(0), ethernet_tag_(0),
81  logical_interface_(nil_uuid()), nova_ip_addr_(0), nova_ip6_addr_(),
82  dhcp_addr_(0), metadata_ip_map_(), hc_instance_set_(),
83  ecmp_load_balance_(), service_health_check_ip_(), is_vn_qos_config_(false),
84  learning_enabled_(false), etree_leaf_(false), layer2_control_word_(false),
85  slo_list_(), forwarding_vrf_(NULL), vhostuser_mode_(vHostUserClient),
86  is_left_si_(false),
87  service_mode_(VmInterface::SERVICE_MODE_ERROR),
88  service_intf_type_(""),
89  parent_list_() {
90  metadata_ip_active_ = false;
91  metadata_l2_active_ = false;
92  ipv4_active_ = false;
93  ipv6_active_ = false;
94  l2_active_ = false;
95  flow_count_ = 0;
96  vrf_name_ = "";
97 }
98 
100  const std::string &name,
101  const Ip4Address &addr, const MacAddress &mac,
102  const std::string &vm_name,
103  const boost::uuids::uuid &vm_project_uuid,
104  uint16_t tx_vlan_id, uint16_t rx_vlan_id,
105  Interface *parent, const Ip6Address &a6,
106  DeviceType device_type, VmiType vmi_type,
107  uint8_t vhostuser_mode, bool os_oper_state,
108  const boost::uuids::uuid &logical_router_uuid) :
109  Interface(Interface::VM_INTERFACE, uuid, name, NULL, os_oper_state,
110  logical_router_uuid),
111  vm_(NULL, this), vn_(NULL), primary_ip_addr_(addr), subnet_bcast_addr_(0),
112  primary_ip6_addr_(a6), vm_mac_(mac), policy_enabled_(false),
113  mirror_entry_(NULL), mirror_direction_(MIRROR_RX_TX), cfg_name_(""),
114  fabric_port_(true), need_linklocal_ip_(false), drop_new_flows_(false),
115  dhcp_enable_(true), dhcp_enable_v6_(false), do_dhcp_relay_(false), proxy_arp_mode_(PROXY_ARP_NONE),
116  vm_name_(vm_name), vm_project_uuid_(vm_project_uuid), vxlan_id_(0),
117  bridging_(false), layer3_forwarding_(true),
118  flood_unknown_unicast_(false), mac_set_(false),
119  ecmp_(false), ecmp6_(false), disable_policy_(false),
120  tx_vlan_id_(tx_vlan_id), rx_vlan_id_(rx_vlan_id), parent_(parent, this),
121  local_preference_(0), oper_dhcp_options_(),
122  cfg_igmp_enable_(false), igmp_enabled_(false),
123  mac_ip_learning_enable_(false), max_flows_(0),
124  mac_vm_binding_state_(new MacVmBindingState()),
125  nexthop_state_(new NextHopState()),
126  vrf_table_label_state_(new VrfTableLabelState()),
127  metadata_ip_state_(new MetaDataIpState()),
128  metadata_ip6_state_(new MetaDataIpState(false)),
129  resolve_route_state_(new ResolveRouteState()),
130  interface_route_state_(new VmiRouteState()),
131  sg_list_(), tag_list_(),
132  floating_ip_list_(), alias_ip_list_(), service_vlan_list_(),
133  static_route_list_(), allowed_address_pair_list_(),
134  instance_ipv4_list_(true), instance_ipv6_list_(false), fat_flow_list_(),
135  vrf_assign_rule_list_(), device_type_(device_type),
136  vmi_type_(vmi_type), hbs_intf_type_(VmInterface::HBS_INTF_INVALID),
137  configurer_(0), subnet_(0),
138  subnet_plen_(0), ethernet_tag_(0), logical_interface_(nil_uuid()),
139  nova_ip_addr_(0), nova_ip6_addr_(), dhcp_addr_(0), metadata_ip_map_(),
140  hc_instance_set_(), service_health_check_ip_(), is_vn_qos_config_(false),
141  learning_enabled_(false), etree_leaf_(false), layer2_control_word_(false),
142  slo_list_(), forwarding_vrf_(NULL), vhostuser_mode_(vhostuser_mode),
143  is_left_si_(false),
144  service_mode_(VmInterface::SERVICE_MODE_ERROR),
145  service_intf_type_(""),
146  parent_list_() {
147  metadata_ip_active_ = false;
148  metadata_l2_active_ = false;
149  ipv4_active_ = false;
150  ipv6_active_ = false;
151  l2_active_ = false;
152  flow_count_ = 0;
153  vrf_name_ = "";
154 }
155 
157  // Release metadata first to ensure metadata_ip_map_ is empty
158  metadata_ip_state_.reset(NULL);
159  metadata_ip6_state_.reset(NULL);
160  assert(metadata_ip_map_.empty());
161  assert(hc_instance_set_.empty());
162 }
163 
165  configurer_ |= (1 << type);
166 }
167 
169  configurer_ &= ~(1 << type);
170 }
171 
173  return ((configurer_ & (1 << type)) != 0);
174 }
175 
176 bool VmInterface::CmpInterface(const DBEntry &rhs) const {
177  const VmInterface &intf=static_cast<const VmInterface &>(rhs);
178  if (uuid_ == nil_uuid() && intf.uuid_ == nil_uuid()) {
179  return name() < intf.name();
180  }
181 
182  return uuid_ < intf.uuid_;
183 }
184 
185 string VmInterface::ToString() const {
186  return "VM-PORT <" + name() + ">";
187 }
188 
191  return DBEntryBase::KeyPtr(key);
192 }
193 
196 }
197 
198 bool VmInterface::Delete(const DBRequest *req) {
199  InterfaceTable *table = static_cast<InterfaceTable *>(get_table());
200  const VmInterfaceData *vm_data = static_cast<const VmInterfaceData *>
201  (req->data.get());
202  if (vrf_ && vrf_->GetName() != "") {
203  vrf_name_ = vrf_->GetName();
204  }
205  vm_data->OnDelete(table, this);
206  if (configurer_) {
207  return false;
208  }
209  table->DeleteDhcpSnoopEntry(name());
210  return true;
211 }
212 
213 // When VMInterface is added from Config (sub-interface, gateway interface etc.)
214 // the RESYNC is not called and some of the config like VN and VRF are not
215 // applied on the interface (See Add() API above). Force change to ensure
216 // RESYNC is called
218  InterfaceTable *table = static_cast<InterfaceTable *>(get_table());
219  IFMapNode *node = ifmap_node();
220  if (node == NULL) {
221  PortSubscribeTable *subscribe_table =
223  if (subscribe_table)
224  node = subscribe_table->UuidToIFNode(GetUuid());
225  if (node == NULL)
226  return;
227  }
228 
229  // Config notification would have been ignored till Nova message is
230  // received. Update config now
231  IFMapAgentTable *ifmap_table =
232  static_cast<IFMapAgentTable *>(node->table());
234  req.key = node->GetDBRequestKey();
236  dynamic_cast<IFMapTable::RequestKey *>(req.key.get());
237  key->id_type = "virtual-machine-interface";
238  ifmap_table->Enqueue(&req);
239 }
240 
242  const std::string &vrf_name) {
243  Agent *agent = table->agent();
244  VrfKey vrf_key(vrf_name);
245  VrfEntry *vrf = static_cast<VrfEntry *>(
246  agent->vrf_table()->Find(&vrf_key, true));
247  if (vrf && vrf->IsDeleted()) {
248  SendTrace(table, VRF_REUSE);
249  return vrf->ResetVrfDelete();
250  }
251  return true;
252 }
253 
255  InterfaceTable *table = static_cast<InterfaceTable *>(get_table());
256  if (IsDeleted()) {
257  SendTrace(table, VMI_REUSE);
258  ResetVrfDelete(table, vrf_name());
259  }
260  return Resync(table, data);
261 }
262 
263 // Handle RESYNC DB Request. Handles multiple sub-types,
264 // - CONFIG : RESYNC from config message
265 // - IP_ADDR: RESYNC due to learning IP from DHCP
266 // - MIRROR : RESYNC due to change in mirror config
268  const VmInterfaceData *data) {
269  bool ret = false;
270 
271  // Copy old values used to update config below
272  bool old_ipv4_active = ipv4_active_;
273  bool old_ipv6_active = ipv6_active_;
274  bool old_l2_active = l2_active_;
275  bool old_policy = policy_enabled_;
276  VrfEntryRef old_vrf = vrf_;
277  bool force_update = false;
278  Ip4Address old_subnet = subnet_;
279  uint8_t old_subnet_plen = subnet_plen_;
280  bool old_metadata_ip_active = metadata_ip_active_;
281  bool old_metadata_l2_active = metadata_l2_active_;
282 
283  if (data) {
284  ret = data->OnResync(table, this, &force_update);
285  std::string ri_name = "";
286  if (data->vrf_name_ == "" && vrf_name_ == "") {
287  if (vn()) {
288  std::string fqdn_name = vn()->GetName();
289  size_t pos = fqdn_name.rfind(":");
290  if (pos != std::string::npos)
291  pos = pos + 1;
292  else
293  pos = 0;
294  ri_name = fqdn_name + ":" + fqdn_name.substr(pos, fqdn_name.length());
295  }
296  } else {
297  ri_name = data->vrf_name_;
298  }
299  if (ri_name != "" && ri_name != vrf_name_) {
300  if (ResetVrfDelete(table, ri_name))
301  vrf_name_ = ri_name;
302  }
303  }
304 
310 
311  if (metadata_ip_active_ != old_metadata_ip_active) {
312  ret = true;
313  }
314 
315  if (metadata_l2_active_ != old_metadata_l2_active) {
316  ret = true;
317  }
318 
319  if (ipv4_active_ != old_ipv4_active) {
320  InterfaceTable *intf_table = static_cast<InterfaceTable *>(get_table());
321  if (ipv4_active_)
322  intf_table->incr_active_vmi_count();
323  else
324  intf_table->decr_active_vmi_count();
325  ret = true;
326  }
327 
328  if (ipv6_active_ != old_ipv6_active) {
329  ret = true;
330  }
331 
332  if (l2_active_ != old_l2_active) {
333  ret = true;
334  }
335 
337  if (policy_enabled_ != old_policy) {
338  ret = true;
339  }
340 
341  //Update DHCP and DNS flag in Interface Class.
342  if (dhcp_enable_) {
343  dhcp_enabled_ = true;
344  } else {
345  dhcp_enabled_ = false;
346  }
347 
348  //Update DHCP and DNS flag for v6 in Interface Class.
349  if (dhcp_enable_v6_) {
350  dhcp_enabled_v6_ = true;
351  }else {
352  dhcp_enabled_v6_ = false;
353  }
354 
356  dns_enabled_ = true;
357  else
358  dns_enabled_ = false;
359 
360  // Compute service-ip for the interface
362 
363  // Add/Update L2
364  if (l2_active_) {
365  UpdateL2();
366  }
367 
368  // Apply config based on old and new values
369  ApplyConfig(old_ipv4_active, old_l2_active, old_ipv6_active,
370  old_subnet, old_subnet_plen);
371 
372  // Check if Healthcheck service resync is required
374  return ret;
375 }
376 
377 
378 // Apply the latest configuration
379 void VmInterface::ApplyConfig(bool old_ipv4_active, bool old_l2_active,
380  bool old_ipv6_active,
381  const Ip4Address &old_subnet,
382  uint8_t old_subnet_plen) {
385 
386  // For following intf type we dont generate any things like l2 routes,
387  // l3 routes etc
388  // VM_SRIOV, VMI_ON_LR
391  l2_force_op = VmInterfaceState::DEL;
392  l3_force_op = VmInterfaceState::DEL;
393  }
394 
396  // PHASE-1 Updates follows.
397  //
398  // Changes independnt of any state
399  // NOTE: Dont move updates below across PHASE-1 block
401 
402  // DHCP MAC IP binding
403  UpdateState(mac_vm_binding_state_.get(), l2_force_op, l3_force_op);
404 
405  Agent *agent = static_cast<InterfaceTable *>(get_table())->agent();
406  //Update security group and tag list first so that route can
407  //build the tag list and security group list
408  sg_list_.UpdateList(agent, this, l2_force_op, l3_force_op);
409  tag_list_.UpdateList(agent, this, l2_force_op, l3_force_op);
410 
411  // Fat flow configuration
412  fat_flow_list_.UpdateList(agent, this);
413 
414  // Bridge Domain configuration
415  bridge_domain_list_.Update(agent, this);
416  if (bridge_domain_list_.list_.size() == 0) {
417  pbb_interface_ = false;
418  }
419 
420  // NOTE : The updates are independnt of any state and agent-mode. They
421  // must not move beyond this part
422 
423  // Need not apply config for TOR VMI as it is more of an inidicative
424  // interface. No route addition or NH addition happens for this interface.
425  // Also, when parent is not updated for a non-Nova interface, device type
426  // remains invalid.
427  if ((device_type_ == VmInterface::TOR ||
429  (old_subnet.is_unspecified() && old_subnet_plen == 0)) {
430  // TODO : Should force_op be set to VmInterfaceState::DEL instead?
431  return;
432  }
433 
435  // PHASE-2 Updates follows.
436  //
437  // Appy changes independent of L2/L3 modes first
438  // NOTE: Dont move updates below across PHASE-2 block
440 
441  // Update VRF Table Label
442  UpdateState(vrf_table_label_state_.get(), l2_force_op, l3_force_op);
443 
444  // Update NextHop parameters
445  UpdateState(nexthop_state_.get(), l2_force_op, l3_force_op);
446  GetNextHopInfo();
447 
448  // Add/Update L3 Metadata for v4 and v6 standards
449  UpdateState(metadata_ip_state_.get(), l2_force_op, l3_force_op);
450  UpdateState(metadata_ip6_state_.get(), l2_force_op, l3_force_op);
451 
453  // PHASE-3 Updates follows.
454  //
455  // Updates dependent on l2-active state and healtch-check-state
456  // NOTE : Dont move updates below across PHASE-3
458 
459  // Dont add any l2-states if l2 is not active
460  if (device_type() == VmInterface::TOR ||
462  l2_force_op = VmInterfaceState::DEL;
463  }
464  if (l2_active_ == false || is_hc_active_ == false) {
465  l2_force_op = VmInterfaceState::DEL;
466  }
467 
468  // Add EVPN and L3 route for do_dhcp_relay_ before instance-ip routes
469  UpdateState(interface_route_state_.get(), l2_force_op, l3_force_op);
470 
471  // Add/Update L3/L2 routes routes resulting from instance-ip
472  instance_ipv4_list_.UpdateList(agent, this, l2_force_op, l3_force_op);
473 
474  // Add/Update L3/L2 routes routes resulting from instance-ip
475  instance_ipv6_list_.UpdateList(agent, this, l2_force_op, l3_force_op);
476 
477  // Update floating-ip related configuration
478  floating_ip_list_.UpdateList(agent, this, l2_force_op, l3_force_op);
479 
480  alias_ip_list_.UpdateList(agent, this, l2_force_op, l3_force_op);
481 
482  UpdateState(resolve_route_state_.get(), l2_force_op, l3_force_op);
483 
484  static_route_list_.UpdateList(agent, this, l2_force_op, l3_force_op);
485 
486  service_vlan_list_.UpdateList(agent, this, l2_force_op, l3_force_op);
487 
488  vrf_assign_rule_list_.UpdateList(agent, this, l2_force_op, l3_force_op);
489 
490  allowed_address_pair_list_.UpdateList(agent, this, l2_force_op,
491  l3_force_op);
492  receive_route_list_.UpdateList(agent, this, l2_force_op, l3_force_op);
493  learnt_mac_ip_list_.UpdateList(agent, this, l2_force_op, l3_force_op);
494 
496  // PHASE-3 Updates follows.
497  // Only cleanup and deletes follow below
498  //
499  // NOTE : Dont move updates below across PHASE-3
501 
502  // Delete NextHop if inactive
504  GetNextHopInfo();
505 
506  // Del L3 Metadata after deleting L3 information
509 
510  // Remove floating-ip entries marked for deletion
512 
513  // Remove Alias-ip entries marked for deletion
515 
516  InterfaceTable *table = static_cast<InterfaceTable *>(get_table());
517  if (old_l2_active != l2_active_) {
518  if (l2_active_) {
519  SendTrace(table, ACTIVATED_L2);
520  } else {
521  SendTrace(table, DEACTIVATED_L2);
522  }
523  }
524 
525  if (old_ipv4_active != ipv4_active_) {
526  if (ipv4_active_) {
527  SendTrace(table, ACTIVATED_IPV4);
528  } else {
529  SendTrace(table, DEACTIVATED_IPV4);
530  }
531  }
532 
533  if (old_ipv6_active != ipv6_active_) {
534  if (ipv6_active_) {
535  SendTrace(table, ACTIVATED_IPV6);
536  } else {
537  SendTrace(table, DEACTIVATED_IPV6);
538  }
539  }
540 }
541 
543  if (device_type() == VmInterface::TOR ||
545  return;
546 
547  int new_vxlan_id = vn_.get() ? vn_->GetVxLanId() : 0;
548  if (l2_active_ && ((vxlan_id_ == 0) ||
549  (vxlan_id_ != new_vxlan_id))) {
550  vxlan_id_ = new_vxlan_id;
551  }
553 }
554 
556 // VmInterface attribute methods
559  VmInterfaceState::Op l2_force_op,
560  VmInterfaceState::Op l3_force_op) {
561  Agent *agent = static_cast<InterfaceTable *>(get_table())->agent();
562  return state->Update(agent, this, l2_force_op, l3_force_op);
563 }
564 
566  Agent *agent = static_cast<InterfaceTable *>(get_table())->agent();
567  bool ret = true;
568  if (state->l2_installed_) {
569  if (state->DeleteL2(agent, this))
570  state->l2_installed_ = false;
571  else
572  ret = false;
573  }
574  if (state->l3_installed_) {
575  if (state->DeleteL3(agent, this))
576  state->l3_installed_ = false;
577  else
578  ret = false;
579  }
580  return ret;
581 }
582 
584 // VmInterfaceAttr basic routines
587  return (new_op > old_op) ? new_op : old_op;
588 }
589 
591  Op l2_force_op, Op l3_force_op) const {
592  Op l2_op = RecomputeOp(l2_force_op, GetOpL2(agent, vmi));
593  Op l3_op = RecomputeOp(l3_force_op, GetOpL3(agent, vmi));
594 
595  if ((l2_op == DEL || l2_op == DEL_ADD) && l2_installed_) {
596  DeleteL2(agent, vmi);
597  l2_installed_ = false;
598  }
599  if ((l3_op == DEL || l3_op == DEL_ADD) && l3_installed_) {
600  DeleteL3(agent, vmi);
601  l3_installed_ = false;
602  }
603 
604  Copy(agent, vmi);
605 
606  if (l3_op == ADD || l3_op == DEL_ADD) {
607  if (AddL3(agent, vmi))
608  l3_installed_ = true;
609  }
610  if (l2_op == ADD || l2_op == DEL_ADD) {
611  if (AddL2(agent, vmi))
612  l2_installed_ = true;
613  }
614 
615  return true;
616 }
617 
618 // Force operation to be DEL if del_pending_ is set
620  const {
621  if (del_pending_ == false)
622  return op;
623 
625 }
626 
627 static bool GetIpActiveState(const IpAddress &ip, const VmInterface *vmi) {
628  if (ip.is_v6())
629  return vmi->ipv6_active();
630 
631  return vmi->ipv4_active();
632 }
633 
635 // MacVmBinding attribute method
636 // Adds a path to MacVmBinding is responsible to update flood-dhcp flag
639  VmInterfaceState(), vrf_(NULL), dhcp_enabled_(false), dhcp_enabled_v6_(false) {
640 }
641 
643 }
644 
646  const VmInterface *vmi) const {
647  if (vmi->IsActive() == false)
648  return VmInterfaceState::DEL;
649 
650  if (vrf_ != vmi->vrf())
652 
653  return VmInterfaceState::ADD;
654 }
655 
656 bool MacVmBindingState::DeleteL3(const Agent *agent, VmInterface *vmi) const {
657  BridgeAgentRouteTable *table =
659  // return if table is already marked for deletion, bridge route delete might
660  // already be processed in ReComputePathDeletion
661  if (table == NULL)
662  return true;
664  vrf_->GetName(), vmi->vm_mac(), vmi);
665  return true;
666 }
667 
668 void MacVmBindingState::Copy(const Agent *agent, const VmInterface *vmi) const {
669  vrf_ = vmi->vrf();
671 }
672 
673 bool MacVmBindingState::AddL3(const Agent *agent, VmInterface *vmi) const {
674  BridgeAgentRouteTable *table =
676  // flood_dhcp must be set in route if dhcp is disabled for interface
677  bool flood_dhcp = !vmi->dhcp_enable_config();
679  vmi->vm_mac(), vmi, flood_dhcp);
680  return true;
681 }
682 
684 // SecurityGroup routines
685 // Does not generate any new state. Only holds reference to SG for interface
688  (const SecurityGroupEntry *rhs) {
689  list_.insert(*rhs);
690 }
691 
693  (const SecurityGroupEntry *lhs, const SecurityGroupEntry *rhs) {
694 }
695 
697  (SecurityGroupEntrySet::iterator &it) {
698  it->set_del_pending(true);
699 }
700 
702 (const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op,
703  VmInterfaceState::Op l3_force_op) {
704  SecurityGroupEntrySet::iterator it = list_.begin();
705  while (it != list_.end()) {
706  SecurityGroupEntrySet::iterator prev = it++;
707  VmInterfaceState::Op l2_op = prev->GetOp(l2_force_op);
708  VmInterfaceState::Op l3_op = prev->GetOp(l3_force_op);
709  vmi->UpdateState(&(*prev), l2_op, l3_op);
710  if (prev->del_pending()) {
711  list_.erase(prev);
712  }
713  }
714 
715  return true;
716 }
717 
719  ListEntry(), VmInterfaceState(), uuid_(nil_uuid()) {
720 }
721 
723 (const SecurityGroupEntry &rhs) :
724  ListEntry(rhs.del_pending_),
726  uuid_(rhs.uuid_) {
727 }
728 
730  ListEntry(), VmInterfaceState(), uuid_(u) {
731 }
732 
734 }
735 
736 bool VmInterface::SecurityGroupEntry::operator ==
737  (const SecurityGroupEntry &rhs) const {
738  return uuid_ == rhs.uuid_;
739 }
740 
741 bool VmInterface::SecurityGroupEntry::operator()
742  (const SecurityGroupEntry &lhs, const SecurityGroupEntry &rhs) const {
743  return lhs.IsLess(&rhs);
744 }
745 
747  (const SecurityGroupEntry *rhs) const {
748  return uuid_ < rhs->uuid_;
749 }
750 
751 // Remove reference to SG when list entry is deleted. Note, the SG states are
752 // not dependent on any interface active state
754 (const Agent *agent, const VmInterface *vmi) const {
755  if (del_pending_)
757 
758  return VmInterfaceState::ADD;
759 }
760 
762  VmInterface *vmi) const {
763  if (sg_.get() != NULL)
764  return false;
765 
766  SgKey sg_key(uuid_);
767  sg_ = static_cast<SgEntry *>(agent->sg_table()->FindActiveEntry(&sg_key));
768  return true;
769 }
770 
772  VmInterface *vmi) const {
773  sg_ = NULL;
774  return true;
775 }
776 
778 // Fat Flow list routines
779 // Only updates fat-flow configuraion in interface
780 // NOTE: Its not derived from VmInterfaceState and also does not generate
781 // any new states
783 VmInterface::FatFlowEntry::FatFlowEntry(const uint8_t proto, const uint16_t p,
784  std::string ignore_addr_value,
785  FatFlowPrefixAggregateType in_prefix_aggregate,
786  IpAddress in_src_prefix, uint8_t in_src_prefix_mask,
787  uint8_t in_src_aggregate_plen,
788  IpAddress in_dst_prefix, uint8_t in_dst_prefix_mask,
789  uint8_t in_dst_aggregate_plen) :
790  protocol(proto), port(p) {
791  ignore_address = fatflow_ignore_addr_map_.find(ignore_addr_value)->second;
792  prefix_aggregate = in_prefix_aggregate;
793  src_prefix = in_src_prefix;
794  src_prefix_mask = in_src_prefix_mask;
795  src_aggregate_plen = in_src_aggregate_plen;
796  dst_prefix = in_dst_prefix;
797  dst_prefix_mask = in_dst_prefix_mask;
798  dst_aggregate_plen = in_dst_aggregate_plen;
799 }
800 
801 
803 VmInterface::FatFlowEntry::MakeFatFlowEntry(const std::string &proto, const int &port,
804  const std::string &ignore_addr_str,
805  const std::string &in_src_prefix_str, const int &in_src_prefix_mask,
806  const int &in_src_aggregate_plen,
807  const std::string &in_dst_prefix_str, const int &in_dst_prefix_mask,
808  const int &in_dst_aggregate_plen) {
809  uint8_t protocol = (uint8_t) Agent::ProtocolStringToInt(proto);
810  IpAddress src_prefix;
811  uint8_t src_prefix_mask = 0, src_aggregate_plen = 0;
812  IpAddress dst_prefix, empty_prefix, empty_prefix_v6 = IpAddress::from_string("0::0");
813  uint8_t dst_prefix_mask = 0, dst_aggregate_plen = 0;
814  FatFlowPrefixAggregateType prefix_aggregate = AGGREGATE_NONE;
815  FatFlowIgnoreAddressType ignore_address =
816  fatflow_ignore_addr_map_.find(ignore_addr_str)->second;
817  int port_num = port;
818 
819  /*
820  * Protocol is taken as 1 for both IPv4 & IPv6 and Port no should be 0 for ICMP/ICMPv6,
821  * override if we get something else from config
822  */
823  if ((protocol == IPPROTO_ICMP) || (protocol == IPPROTO_ICMPV6)) {
824  protocol = IPPROTO_ICMP;
825  port_num = 0;
826  }
827 
828  if (in_src_prefix_str.length() > 0) {
829 
830  src_prefix = IpAddress::from_string(in_src_prefix_str);
831  src_prefix_mask = in_src_prefix_mask;
832  src_aggregate_plen = in_src_aggregate_plen;
833  if (src_prefix.is_v4()) {
834  // convert to prefix
835  src_prefix = IpAddress(Address::GetIp4SubnetAddress(src_prefix.to_v4(),
836  src_prefix_mask));
837  prefix_aggregate = AGGREGATE_SRC_IPV4;
838  } else {
839  src_prefix = IpAddress(Address::GetIp6SubnetAddress(src_prefix.to_v6(),
840  src_prefix_mask));
841  prefix_aggregate = AGGREGATE_SRC_IPV6;
842  }
843  }
844  if (in_dst_prefix_str.length() > 0) {
845  dst_prefix = IpAddress::from_string(in_dst_prefix_str);
846  dst_prefix_mask = in_dst_prefix_mask;
847  dst_aggregate_plen = in_dst_aggregate_plen;
848  if (dst_prefix.is_v4()) {
849  dst_prefix = IpAddress(Address::GetIp4SubnetAddress(dst_prefix.to_v4(),
850  dst_prefix_mask));
851  } else {
852  dst_prefix = IpAddress(Address::GetIp6SubnetAddress(dst_prefix.to_v6(),
853  dst_prefix_mask));
854  }
855 
856  if (prefix_aggregate == AGGREGATE_NONE) {
857  if (dst_prefix.is_v4()) {
858  prefix_aggregate = AGGREGATE_DST_IPV4;
859  } else {
860  prefix_aggregate = AGGREGATE_DST_IPV6;
861  }
862  } else {
863  if (dst_prefix.is_v4()) {
864  prefix_aggregate = AGGREGATE_SRC_DST_IPV4;
865  } else {
866  prefix_aggregate = AGGREGATE_SRC_DST_IPV6;
867  }
868  }
869  }
870  if (ignore_address == IGNORE_SOURCE) {
871  if ((prefix_aggregate == AGGREGATE_SRC_IPV4) || (prefix_aggregate == AGGREGATE_SRC_IPV6)) {
872  src_prefix = empty_prefix;
873  src_prefix_mask = 0;
874  src_aggregate_plen = 0;
875  prefix_aggregate = AGGREGATE_NONE;
876  } else if (prefix_aggregate == AGGREGATE_SRC_DST_IPV4) {
877  src_prefix = empty_prefix;
878  src_prefix_mask = 0;
879  src_aggregate_plen = 0;
880  prefix_aggregate = AGGREGATE_DST_IPV4;
881  } else if (prefix_aggregate == AGGREGATE_SRC_DST_IPV6) {
882  src_prefix = empty_prefix_v6;
883  src_prefix_mask = 0;
884  src_aggregate_plen = 0;
885  prefix_aggregate = AGGREGATE_DST_IPV6;
886  }
887  } else if (ignore_address == IGNORE_DESTINATION) {
888  if ((prefix_aggregate == AGGREGATE_DST_IPV4) || (prefix_aggregate == AGGREGATE_DST_IPV6)) {
889  dst_prefix = empty_prefix;
890  dst_prefix_mask = 0;
891  dst_aggregate_plen = 0;
892  prefix_aggregate = AGGREGATE_NONE;
893  } else if (prefix_aggregate == AGGREGATE_SRC_DST_IPV4) {
894  dst_prefix = empty_prefix;
895  dst_prefix_mask = 0;
896  dst_aggregate_plen = 0;
897  prefix_aggregate = AGGREGATE_SRC_IPV4;
898  } else if (prefix_aggregate == AGGREGATE_SRC_DST_IPV6) {
899  dst_prefix = empty_prefix_v6;
900  dst_prefix_mask = 0;
901  dst_aggregate_plen = 0;
902  prefix_aggregate = AGGREGATE_SRC_IPV6;
903  }
904  }
905 
906  if ((in_src_prefix_str.length() == 0) && (prefix_aggregate == AGGREGATE_DST_IPV6)) {
907  src_prefix = empty_prefix_v6;
908  }
909  if ((in_dst_prefix_str.length() == 0) && (prefix_aggregate == AGGREGATE_SRC_IPV6)) {
910  dst_prefix = empty_prefix_v6;
911  }
912 
913  VmInterface::FatFlowEntry entry(protocol, port_num,
914  ignore_addr_str, prefix_aggregate, src_prefix, src_prefix_mask,
915  src_aggregate_plen, dst_prefix, dst_prefix_mask, dst_aggregate_plen);
916  return entry;
917 }
918 
920  LOG(ERROR, "Protocol:" << (int) protocol << " Port:" << port << " IgnoreAddr:" << ignore_address
921  << " PrefixAggr:" << prefix_aggregate << " SrcPrefix:" << src_prefix.to_string() << "/" << (int) src_prefix_mask
922  << " SrcAggrPlen:" << (int) src_aggregate_plen << " DstPrefix:" << dst_prefix.to_string() << "/" << (int) dst_prefix_mask
923  << " DstAggrPlen:" << (int) dst_aggregate_plen);
924 }
925 
927  list_.insert(*rhs);
928 }
929 
931  const FatFlowEntry *rhs) {
932  lhs->ignore_address = rhs->ignore_address;
934  lhs->src_prefix = rhs->src_prefix;
935  lhs->src_prefix_mask = rhs->src_prefix_mask;
937  lhs->dst_prefix = rhs->dst_prefix;
938  lhs->dst_prefix_mask = rhs->dst_prefix_mask;
940 }
941 
942 void VmInterface::FatFlowList::Remove(FatFlowEntrySet::iterator &it) {
943  it->set_del_pending(true);
944 }
945 
947  VmInterface *vmi) {
948  FatFlowEntrySet::iterator it = list_.begin();
949  while (it != list_.end()) {
950  FatFlowEntrySet::iterator prev = it++;
951  if (prev->del_pending_) {
952  list_.erase(prev);
953  }
954  }
955  return true;
956 }
957 
959  LOG(ERROR, "Dumping FatFlowList:\n");
960  for (FatFlowEntrySet::iterator it = list_.begin(); it != list_.end(); it++) {
961  it->print();
962  }
963 }
964 
966 // Bridge Domain List
967 // NOTE: Its not derived from VmInterfaceState and also does not generate
968 // any new states
971  list_.insert(*rhs);
972 }
973 
975  const BridgeDomain *rhs) {
976 }
977 
978 void VmInterface::BridgeDomainList::Remove(BridgeDomainEntrySet::iterator &it) {
979  it->set_del_pending(true);
980 }
981 
983  VmInterface *vmi) {
984  InterfaceTable *table = static_cast<InterfaceTable *>(vmi->get_table());
985  BridgeDomainEntrySet::iterator it = list_.begin();
986  while (it != list_.end()) {
987  BridgeDomainEntrySet::iterator prev = it++;
988  if (prev->del_pending_ == false) {
989  BridgeDomainKey key(prev->uuid_);
990  prev->bridge_domain_ = static_cast<const BridgeDomainEntry *>
991  (table->agent()->bridge_domain_table()->FindActiveEntry(&key));
992  // Ignore bridge domain without VRF
993  // Interface will get config update again when VRF is created
994  if (prev->bridge_domain_->vrf() == NULL) {
995  prev->del_pending_ = true;
996  }
997  }
998 
999  if (prev->del_pending_) {
1000  list_.erase(prev);
1001  }
1002  }
1003 
1004  return true;
1005 }
1006 
1008 // VRF Table label
1009 // Create VRF-NextHop based on interface-type. The NextHop is not explicitly
1010 // deleted. It gets deleted when reference count drops to 0
1013 }
1014 
1016 }
1017 
1019  const VmInterface *vmi) const {
1020  return VmInterfaceState::ADD;
1021 }
1022 
1023 // Take care of only adding VRF Table label. The label will be freed when
1024 // VRF is deleted
1025 bool VrfTableLabelState::AddL3(const Agent *agent, VmInterface *vmi) const {
1026  if (vmi->vrf() == NULL || vmi->vmi_type() != VmInterface::GATEWAY) {
1027  return false;
1028  }
1029 
1030  vmi->vrf()->CreateTableLabel(false, false, false, false);
1031  return false;
1032 }
1033 
1035 // NextHop attribute
1036 //
1037 // L2 nexthops:
1038 // These L2 nexthop are used by multicast and bridge. Presence of multicast
1039 // forces it to be present in ipv4 mode(l3-only).
1040 //
1041 // L3 nexthops:
1042 // Also creates L3 interface NH, if layer3_forwarding is set.
1043 // It does not depend on oper state of ip forwarding.
1044 // Needed as health check can disable oper ip_active and will result in flow
1045 // key pointing to L2 interface NH. This has to be avoided as interface still
1046 // points to l3 nh and flow should use same. For this fix it is also required
1047 // that l3 i/f nh is also created on seeing config and not oper state of l3.
1048 // Reason being if vmi(irrespective of health check) is coming up and
1049 // transitioning from ipv4_inactive to ip4_active and during this transition
1050 // a flow is added then flow_key in vmi will return null because l3 config is
1051 // set and interface nh not created yet.
1054 }
1055 
1057 }
1058 
1059 // The nexthops are deleted after all update processing by explicitly
1060 // calling delete. So, dont return DEL operation from here
1062  const VmInterface *vmi) const {
1063  if (vmi->IsActive() == false)
1065  return VmInterfaceState::ADD;
1066 }
1067 
1068 // The nexthops must be deleted after all update processing. So, dont return
1069 // DEL operation from here
1071  const VmInterface *vmi) const {
1072  if ((vmi->IsActive() == false) || (vmi->layer3_forwarding() == false))
1074 
1075  return VmInterfaceState::ADD;
1076 }
1077 
1078 bool NextHopState::AddL2(const Agent *agent, VmInterface *vmi) const {
1080  vmi->forwarding_vrf()->GetName(),
1081  vmi->learning_enabled(),
1082  vmi->etree_leaf(),
1083  vmi->layer2_control_word(),
1084  vmi->name());
1085 
1087  vmi->GetUuid(), vmi->name()),
1088  true, InterfaceNHFlags::BRIDGE, vmi->vm_mac());
1089  l2_nh_policy_ = static_cast<NextHop *>
1090  (agent->nexthop_table()->FindActiveEntry(&key1));
1091 
1093  vmi->GetUuid(), vmi->name()),
1094  false, InterfaceNHFlags::BRIDGE, vmi->vm_mac());
1095  l2_nh_no_policy_ = static_cast<NextHop *>
1096  (agent->nexthop_table()->FindActiveEntry(&key2));
1097 
1098  // Update L2 mpls label from nh entry
1099  if (vmi->policy_enabled()) {
1100  l2_label_ = l2_nh_policy_->mpls_label()->label();
1101  } else {
1102  l2_label_ = l2_nh_no_policy_->mpls_label()->label();
1103  }
1104 
1105  return true;
1106 }
1107 
1108 bool NextHopState::DeleteL2(const Agent *agent, VmInterface *vmi) const {
1109  // Delete is called independent of interface active-state.
1110  // Dont delete NH if interface is still active
1111  if (vmi->IsActive())
1112  return false;
1113 
1114  l2_nh_policy_.reset();
1115  l2_nh_no_policy_.reset();
1118  vmi->name());
1119  return true;
1120 }
1121 
1122 bool NextHopState::AddL3(const Agent *agent, VmInterface *vmi) const {
1124  vmi->forwarding_vrf()->GetName(),
1125  vmi->learning_enabled(),
1126  vmi->name());
1127 
1129  vmi->forwarding_vrf()->GetName(),
1130  vmi->name());
1131 
1133  vmi->GetUuid(), vmi->name()),
1134  true, InterfaceNHFlags::INET4, vmi->vm_mac());
1135  l3_nh_policy_ = static_cast<NextHop *>
1136  (agent->nexthop_table()->FindActiveEntry(&key1));
1137 
1139  vmi->GetUuid(), vmi->name()),
1140  false, InterfaceNHFlags::INET4, vmi->vm_mac());
1141  l3_nh_no_policy_ = static_cast<NextHop *>
1142  (agent->nexthop_table()->FindActiveEntry(&key2));
1143 
1145  vmi->GetUuid(), vmi->name()), false,
1148  vmi->vm_mac());
1149  l3_mcast_nh_no_policy_ = static_cast<NextHop *>
1150  (agent->nexthop_table()->FindActiveEntry(&key3));
1151 
1152  // Update L3 mpls label from nh entry
1153  if (vmi->policy_enabled()) {
1154  l3_label_ = l3_nh_policy_->mpls_label()->label();
1155  } else {
1156  l3_label_ = l3_nh_no_policy_->mpls_label()->label();
1157  }
1158 
1159  return true;
1160 }
1161 
1162 bool NextHopState::DeleteL3(const Agent *agent, VmInterface *vmi) const {
1163  // Delete is called independent of interface active-state.
1164  // Keep NH as long as interface is active and layer3-forwarding is enabled
1165  // TODO : It should be ok to keep the NH even if l3-forwarding is disabled?
1166  if (vmi->IsActive() && vmi->layer3_forwarding())
1167  return false;
1168 
1169  l3_mcast_nh_no_policy_.reset();
1170  l3_nh_policy_.reset();
1171  l3_nh_no_policy_.reset();
1174  vmi->name());
1175  InterfaceNH::DeleteL3InterfaceNH(vmi->GetUuid(), vmi->vm_mac(), vmi->name());
1176  return true;
1177 }
1178 
1180  return nexthop_state_->l3_nh_no_policy_.get();
1181 }
1182 
1184  return nexthop_state_->l2_nh_no_policy_.get();
1185 }
1186 
1188  return nexthop_state_->l2_nh_policy_.get();
1189 }
1190 
1191 uint32_t VmInterface::label_op() const {
1192  Agent *agent = static_cast<InterfaceTable *>(get_table())->agent();
1193  if (nexthop_state_->GetOpL3(agent, this) == VmInterfaceState::INVALID)
1194  return MplsTable::kInvalidLabel;
1195 
1196  if (policy_enabled_)
1197  return nexthop_state_->l3_nh_no_policy_->mpls_label()->label();
1198  else
1199  return nexthop_state_->l3_nh_policy_->mpls_label()->label();
1200 }
1201 
1203  l2_label_ = nexthop_state_->l2_label();
1204  label_ = nexthop_state_->l3_label();
1205  // If Layer3 forwarding is configured irrespective of ipv4/v6 status,
1206  // flow_key_nh should be l3 based.
1207  if (layer3_forwarding()) {
1208  flow_key_nh_ = nexthop_state_->l3_nh_policy_;
1209  } else {
1210  flow_key_nh_ = nexthop_state_->l2_nh_policy_;
1211  }
1212 }
1213 
1215 // MetaData Ip Routines
1218 :
1219 VmInterfaceState(), mdata_ip_(), ipv4_(ipv4) {
1220 }
1221 
1223  mdata_ip_.reset(NULL);
1224 }
1225 
1226 // metadata-ip is deleted after all update processing by explicitly
1227 // calling delete. So, dont return DEL operation from here
1229  const VmInterface *vmi) const {
1230  if (vmi->need_linklocal_ip() == false ||
1231  vmi->metadata_ip_active() == false)
1233 
1234  return VmInterfaceState::ADD;
1235 }
1236 
1237 bool MetaDataIpState::AddL3(const Agent *agent, VmInterface *vmi) const {
1238  if (mdata_ip_.get() == NULL) {
1239  mdata_ip_.reset(new MetaDataIp(
1240  ipv4_ ? agent->metadata_ip_allocator() :
1241  agent->metadata_ip6_allocator(),
1242  vmi,
1243  vmi->id(), ipv4_));
1244  }
1245  mdata_ip_->set_active(true);
1246  vmi->UpdateMetaDataIpInfo();
1247  return true;
1248 }
1249 
1250 // Delete meta-data route
1251 bool MetaDataIpState::DeleteL3(const Agent *agent, VmInterface *vmi) const {
1252  if (vmi->metadata_ip_active() && vmi->need_linklocal_ip())
1253  return false;
1254 
1255  if (mdata_ip_.get() == NULL) {
1256  return true;
1257  }
1258 
1259  // Call UpdateMetaDataIpInfo before setting mdata_ip_ state to inactive
1260  vmi->UpdateMetaDataIpInfo();
1261  mdata_ip_->set_active(false);
1262  return true;
1263 }
1264 
1266  if (metadata_ip_state_.get() == NULL)
1267  return Ip4Address(0);
1268 
1269  if (metadata_ip_state_->mdata_ip_.get() == NULL) {
1270  return Ip4Address(0);
1271  }
1272 
1273  return metadata_ip_state_->mdata_ip_->GetLinkLocalIp4();
1274 }
1275 
1277  if (metadata_ip6_state_.get() == NULL)
1278  return Ip6Address();
1279 
1280  if (metadata_ip6_state_->mdata_ip_.get() == NULL) {
1281  return Ip6Address();
1282  }
1283 
1284  return metadata_ip6_state_->mdata_ip_->GetLinkLocalIp6();
1285 }
1286 
1288 // ResolveRoute Attribute Routines
1291  VmInterfaceState(), vrf_(NULL), subnet_(), plen_(0) {
1292 }
1293 
1295 }
1296 
1297 void ResolveRouteState::Copy(const Agent *agent, const VmInterface *vmi) const {
1298  vrf_ = vmi->forwarding_vrf();
1299  subnet_ = vmi->subnet();
1300  plen_ = vmi->subnet_plen();
1301 }
1302 
1304  const VmInterface *vmi) const {
1305  if (vmi->ipv4_active() == false)
1306  return VmInterfaceState::DEL;
1307 
1308  if (vrf_ != vmi->forwarding_vrf() || subnet_ != vmi->subnet() ||
1309  plen_ != vmi->subnet_plen())
1311 
1312  return VmInterfaceState::ADD;
1313 }
1314 
1315 bool ResolveRouteState::DeleteL3(const Agent *agent, VmInterface *vmi) const {
1316  if (vrf_ == NULL)
1317  return false;
1318 
1319  vmi->DeleteRoute(vrf_->GetName(), subnet_, plen_);
1320  return true;
1321 }
1322 
1323 bool ResolveRouteState::AddL3(const Agent *agent, VmInterface *vmi) const {
1324  /* No need to add resolve route for VHOST in case of l3mh */
1325  if (agent && agent->is_l3mh() && vmi->vmi_type() == VmInterface::VHOST) {
1326  return true;
1327  }
1328 
1329  if (vrf_ == NULL || subnet_.is_unspecified())
1330  return false;
1331 
1332  if (vmi->vmi_type() != VmInterface::VHOST) {
1333  if (vmi->vn() == NULL) {
1334  return false;
1335  }
1336  }
1337 
1338  SecurityGroupList sg_id_list;
1339  vmi->CopySgIdList(&sg_id_list);
1340 
1341  TagList tag_id_list;
1342  vmi->CopyTagIdList(&tag_id_list);
1343 
1344  std::string vn_name;
1345  if (vmi->vn() != NULL) {
1346  vn_name = vmi->vn()->GetName();
1347  }
1348 
1349  bool policy = vmi->policy_enabled();
1350  if (vmi->vmi_type() == VmInterface::VHOST) {
1351  policy = false;
1352  }
1353 
1354  VmInterfaceKey key(AgentKey::ADD_DEL_CHANGE, vmi->GetUuid(), vmi->name());
1356  (vmi->peer(), vrf_->GetName(),
1358  vrf_->table_label(), policy, vn_name,
1359  sg_id_list, tag_id_list);
1360  return true;
1361 }
1362 
1363 // If the interface is Gateway we need to add a receive route,
1364 // such the packet gets routed. Bridging on gateway
1365 // interface is not supported
1367  const VmInterface *vmi) const {
1368  if ((vmi->vmi_type() != VmInterface::GATEWAY &&
1369  vmi->vmi_type() != VmInterface::REMOTE_VM))
1370  return VmInterfaceState::DEL;
1371 
1372  if (vmi->bridging() == false)
1373  return VmInterfaceState::DEL;
1374 
1375  if (vrf_ != vmi->forwarding_vrf())
1377 
1378  return VmInterfaceState::ADD;
1379 }
1380 
1381 bool ResolveRouteState::DeleteL2(const Agent *agent, VmInterface *vmi) const {
1382  if (vrf_ == NULL)
1383  return false;
1384 
1386  vmi->GetVifMac(agent), 0);
1387  return true;
1388 }
1389 
1390 bool ResolveRouteState::AddL2(const Agent *agent, VmInterface *vmi) const {
1391  if (vrf_ == NULL || vmi->vn() == NULL)
1392  return false;
1393 
1394  BridgeAgentRouteTable *table = static_cast<BridgeAgentRouteTable *>
1396  table->AddBridgeReceiveRoute(vmi->peer(), vrf_->GetName(), 0,
1397  vmi->GetVifMac(agent), vmi->vn()->GetName());
1398  return true;
1399 }
1400 
1402 // VmiRouteState Routines
1403 // This is responsible to manage following routes,
1404 // - Manages the <0.0.0.0, MAC> EVPN route for the interface
1405 // - Manage the L3 route for dhcp-relay when do_dhcp_relay_ is enabled
1406 // ip_ here is set to primary-ip when do_dhcp_relay_ is enabled
1407 // When do_dhcp_relay_ is enabled, adds route for ip_ along with service-ip.
1408 //
1409 // Note, instance-ip can also potentially add/delete route for same ip-address
1412  VmInterfaceState(), vrf_(NULL), ip_(), ethernet_tag_(0),
1413  do_dhcp_relay_(false) {
1414 }
1415 
1417 }
1418 
1419 void VmiRouteState::Copy(const Agent *agent, const VmInterface *vmi) const {
1420  vrf_ = vmi->vrf();
1421  ethernet_tag_ = vmi->ethernet_tag();
1422  do_dhcp_relay_ = vmi->do_dhcp_relay();
1423  ip_ = do_dhcp_relay_ ? ip_ = vmi->dhcp_addr() : Ip4Address(0);
1424 }
1425 
1427 (const Agent *agent, const VmInterface *vmi) const {
1428  if (vmi->ipv4_active() == false)
1429  return VmInterfaceState::DEL;
1430 
1431  // On do_dhcp_relay_ change from enable to disbale, delete the route
1432  // Normally, we should not look at old value of do_dhcp_relay_ here, but
1433  // ignoring it will result in delete and add of route for primary-ip
1434  // Check old value of do_dhcp_relay_ to avoid this
1435  //
1436  // Even on transition, if instance-ip is present matching the primary-ip
1437  // the route will added again due to instance-ip later
1438  if (do_dhcp_relay_ && vmi->do_dhcp_relay() == false)
1439  return VmInterfaceState::DEL;
1440 
1441  if (vrf_ != vmi->vrf())
1443 
1444  if (ip_ != vmi->dhcp_addr())
1446 
1447  // Dont have to add L3 route if DHCP Relay not enabled
1448  if (vmi->do_dhcp_relay() == false)
1450 
1451  return VmInterfaceState::ADD;
1452 }
1453 
1454 bool VmiRouteState::DeleteL3(const Agent *agent, VmInterface *vmi) const {
1455  if (vrf_ == NULL || ip_.is_unspecified())
1456  return false;
1457 
1458  vmi->DeleteRoute(vrf_->GetName(), ip_, 32);
1459  return true;
1460 }
1461 
1462 bool VmiRouteState::AddL3(const Agent *agent, VmInterface *vmi) const {
1463  if (vrf_ == NULL || vmi->vn() == NULL || ip_.is_unspecified())
1464  return false;
1465 
1466  /* expected only for instance IP */
1467  vmi->AddRoute(vrf_->GetName(), ip_, 32, vmi->vn()->GetName(), false,
1468  vmi->ecmp(), false, false, vmi->vm_ip_service_addr(),
1469  Ip4Address(0), CommunityList(), vmi->label(),
1471  return true;
1472 }
1473 
1475 (const Agent *agent, const VmInterface *vmi) const {
1476  if (vmi->l2_active() == false || vmi->is_hc_active() == false)
1477  return VmInterfaceState::DEL;
1478 
1479  if (vrf_ != vmi->vrf())
1481 
1482  if (ethernet_tag_ != vmi->ethernet_tag())
1484 
1485  return VmInterfaceState::ADD;
1486 }
1487 
1488 bool VmiRouteState::DeleteL2(const Agent *agent, VmInterface *vmi) const {
1489  if (vrf_ == NULL)
1490  return false;
1491 
1493  vmi->vm_mac());
1494  return true;
1495 }
1496 
1497 bool VmiRouteState::AddL2(const Agent *agent, VmInterface *vmi) const {
1498  if (vrf_ == NULL || vmi->vn() == NULL)
1499  return false;
1500 
1501  vmi->AddL2InterfaceRoute(Ip4Address(), vmi->vm_mac(), Ip4Address(0));
1502  BridgeAgentRouteTable *table =
1504  if(table != NULL){
1505  if(table->FindRoute(agent->vrrp_mac())){
1506  return true;
1507  }else{
1508  table->AddBridgeReceiveRoute(agent->local_vm_peer(),
1509  vrf_->GetName(),
1510  0,
1511  agent->vrrp_mac(),
1512  "");
1513  }
1514  }
1515  return true;
1516 }
1517 
1519 // InstanceIp routines. Manages following,
1520 // - Manages the L3 and L2 routes derived from the instance-ip.
1523  list_.insert(*rhs);
1524 }
1525 
1527  const InstanceIp *rhs) {
1528  lhs->ecmp_ = rhs->ecmp_;
1529  lhs->is_service_ip_ = rhs->is_service_ip_;
1531  lhs->is_local_ = rhs->is_local_;
1532  lhs->tracking_ip_ = rhs->tracking_ip_;
1533 
1534  lhs->set_del_pending(false);
1535 }
1536 
1537 void VmInterface::InstanceIpList::Remove(InstanceIpSet::iterator &it) {
1538  it->set_del_pending(true);
1539 }
1540 
1542 (const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op,
1543  VmInterfaceState::Op l3_force_op) {
1544  InstanceIpSet::iterator it = list_.begin();
1545  // Apply the instance-ip configured for interface
1546  while (it != list_.end()) {
1547  InstanceIpSet::iterator prev = it++;
1548  VmInterfaceState::Op l2_op = prev->GetOp(l2_force_op);
1549  VmInterfaceState::Op l3_op = prev->GetOp(l3_force_op);
1550  if (prev->del_pending() == false)
1551  prev->SetPrefixForAllocUnitIpam(vmi);
1552  vmi->UpdateState(&(*prev), l2_op, l3_op);
1553  if (prev->del_pending()) {
1554  list_.erase(prev);
1555  }
1556  }
1557 
1558  return true;
1559 }
1560 
1562  ListEntry(), VmInterfaceState(), ip_(), plen_(), ecmp_(false),
1563  is_primary_(false), is_service_ip_(false),
1564  is_service_health_check_ip_(false), is_local_(false),
1565  tracking_ip_(), vrf_(NULL), ethernet_tag_(0) {
1566 }
1567 
1569  ListEntry(rhs.del_pending_),
1570  VmInterfaceState(rhs.l2_installed_, rhs.l3_installed_),
1571  ip_(rhs.ip_), plen_(rhs.plen_), ecmp_(rhs.ecmp_),
1572  is_primary_(rhs.is_primary_), is_service_ip_(rhs.is_service_ip_),
1573  is_service_health_check_ip_(rhs.is_service_health_check_ip_),
1574  is_local_(rhs.is_local_), tracking_ip_(rhs.tracking_ip_),
1575  vrf_(NULL), ethernet_tag_(0) {
1576 }
1577 
1579  bool ecmp, bool is_primary,
1580  bool is_service_ip,
1581  bool is_service_health_check_ip,
1582  bool is_local,
1583  const IpAddress &tracking_ip) :
1584  ListEntry(), VmInterfaceState(), ip_(addr), plen_(plen), ecmp_(ecmp),
1585  is_primary_(is_primary), is_service_ip_(is_service_ip),
1586  is_service_health_check_ip_(is_service_health_check_ip),
1587  is_local_(is_local), tracking_ip_(tracking_ip), vrf_(NULL),
1588  ethernet_tag_(0) {
1589 }
1590 
1592 }
1593 
1595  const InstanceIp &rhs) const {
1596  return lhs.IsLess(&rhs);
1597 }
1598 
1600  return ip_ < rhs->ip_;
1601 }
1602 
1604  if (vmi->vn() == NULL)
1605  return;
1606 
1607  uint32_t alloc_unit = vmi->vn()->GetAllocUnitFromIpam(ip_);
1608 
1609  uint8_t alloc_prefix = 0;
1610  if (alloc_unit > 0) {
1611  alloc_prefix = log2(alloc_unit);
1612  }
1613 
1614  if (ip_.is_v4()) {
1615  plen_ = Address::kMaxV4PrefixLen - alloc_prefix;
1616  } else if (ip_.is_v6()) {
1617  plen_ = Address::kMaxV6PrefixLen - alloc_prefix;
1618  }
1619 }
1620 
1621 static bool GetInstanceIpActiveState(const VmInterface::InstanceIp *instance_ip,
1622  const VmInterface *vmi) {
1623  if (instance_ip->is_service_health_check_ip_) {
1624  // for service health check instance ip keep the route based on
1625  // metadata-active state
1626  return vmi->metadata_ip_active();
1627  }
1628 
1629  if (instance_ip->ip_.is_v6()) {
1630  return vmi->ipv6_active();
1631  }
1632 
1633  return vmi->ipv4_active();
1634 }
1635 
1637 (const Agent *agent, const VmInterface *vmi) const {
1638  if (GetInstanceIpActiveState(this, vmi) == false)
1639  return VmInterfaceState::DEL;
1640 
1641  if (!is_service_ip_ && vmi->vmi_type() != VmInterface::VHOST) {
1642  // Add route only when vn IPAM exists for the IP
1643  if (vmi->vn() && vmi->vn()->GetIpam(ip_) == NULL)
1644  return VmInterfaceState::DEL;
1645  }
1646 
1647  if (IsL3Only())
1648  return VmInterfaceState::DEL;
1649 
1650  if (vrf_ != vmi->vrf())
1652 
1653  if (ethernet_tag_ != vmi->ethernet_tag())
1655 
1656  return VmInterfaceState::ADD;
1657 }
1658 
1660  VmInterface *vmi) const {
1661  if (vrf_ == NULL)
1662  return false;
1663 
1664  vmi->AddL2InterfaceRoute(ip_, vmi->vm_mac(), tracking_ip_);
1665  return true;
1666 }
1667 
1669  VmInterface *vmi) const {
1670  if (vrf_ == NULL)
1671  return false;
1672 
1673  vmi->DeleteL2InterfaceRoute(vrf_, ethernet_tag_, ip_, vmi->vm_mac());
1674  return true;
1675 }
1676 
1678 (const Agent *agent, const VmInterface *vmi) const {
1679  // TODO : Should be check health-check state here?
1680  if (GetInstanceIpActiveState(this, vmi) == false)
1681  return VmInterfaceState::DEL;
1682 
1683  if (!is_service_ip_ && vmi->vmi_type() != VmInterface::VHOST) {
1684  // Add route only when vn IPAM exists for the IP
1685  if (vmi->vn() && vmi->vn()->GetIpam(ip_) == NULL)
1686  return VmInterfaceState::DEL;
1687  }
1688 
1689  if (vrf_ != vmi->vrf())
1691 
1692  return VmInterfaceState::ADD;
1693 }
1694 
1696  VmInterface *vmi) const {
1697  if (vrf_ == NULL)
1698  return false;
1699  assert(ip_.is_unspecified() == false);
1700  std::string vn_name;
1701  if (vmi->vn()) {
1702  vn_name = vmi->vn()->GetName();
1703  } else if (vmi->vmi_type() == VHOST) {
1704  vn_name = agent->fabric_vn_name();
1705  }
1706 
1707  vmi->AddRoute(vmi->vrf()->GetName(), ip_, plen_, vn_name,
1708  is_force_policy(), ecmp_,is_local_,
1709  is_service_health_check_ip_, vmi->GetServiceIp(ip_),
1710  tracking_ip_, CommunityList(), vmi->label(),
1711  is_service_ip_ ? kServiceInterface : kInterface);
1712  return true;
1713 }
1714 
1716  VmInterface *vmi) const {
1717  if (vrf_ == NULL)
1718  return false;
1719  vmi->DeleteRoute(vrf_->GetName(), ip_, plen_);
1720  return true;
1721 }
1722 
1724  const VmInterface *vmi) const {
1725  vrf_ = vmi->vrf();
1726  ethernet_tag_ = vmi->ethernet_tag();
1727 }
1728 
1730 // MacIp routines. Manages following,
1731 // - Manages the L3 and L2 routes derived from the instance-ip.
1734  list_.insert(*rhs);
1735 }
1736 
1738  const LearntMacIp *rhs) {
1739 
1740  lhs->set_del_pending(rhs->del_pending());
1741 }
1742 
1744  LearntMacIpSet::iterator it = list_.find(*rhs);
1745  if (it != list_.end()) {
1746  it->set_del_pending(true);
1747  }
1748 }
1749 
1751 (const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op,
1752  VmInterfaceState::Op l3_force_op) {
1753  LearntMacIpSet::iterator it = list_.begin();
1754  // Apply the instance-ip configured for interface
1755  while (it != list_.end()) {
1756  LearntMacIpSet::iterator prev = it++;
1757  VmInterfaceState::Op l2_op = prev->GetOp(l2_force_op);
1758  VmInterfaceState::Op l3_op = prev->GetOp(l3_force_op);
1759  vmi->UpdateState(&(*prev), l2_op, l3_op);
1760  if (prev->del_pending()) {
1761  list_.erase(prev);
1762  }
1763  }
1764 
1765  return true;
1766 }
1767 
1769  ListEntry(), VmInterfaceState(), ip_(), mac_(),
1770  vrf_(NULL), ethernet_tag_(0) {
1771 }
1772 
1774  ListEntry(rhs.del_pending_),
1775  VmInterfaceState(rhs.l2_installed_, rhs.l3_installed_),
1776  ip_(rhs.ip_), mac_(rhs.mac_),
1777  vrf_(NULL), ethernet_tag_(0) {
1778 }
1779 
1781  const MacAddress &mac) :
1782  ListEntry(), VmInterfaceState(), ip_(ip_addr), mac_(mac),
1783  vrf_(NULL), ethernet_tag_(0) {
1784 }
1785 
1787 }
1788 
1790  const VmInterface *vmi) {
1791  // supporting either L2 mode and L2/L3 mode
1792  if (!vmi->l2_active()) {
1793  return false;
1794  }
1795  if (mac_ip->ip_.is_v6()) {
1796  return vmi->ipv6_active();
1797  }
1798 
1799  return vmi->ipv4_active();
1800 }
1802  const LearntMacIp &rhs) const {
1803  return lhs.IsLess(&rhs);
1804 }
1805 
1807  return ip_ < rhs->ip_;
1808 }
1809 
1811 (const Agent *agent, const VmInterface *vmi) const {
1812  if (del_pending() == true)
1813  return VmInterfaceState::DEL;
1814 
1815 
1816  if (vrf_ != vmi->vrf())
1818 
1819  if (ethernet_tag_ != vmi->ethernet_tag())
1821 
1822  return VmInterfaceState::ADD;
1823 }
1824 
1826  VmInterface *vmi) const {
1827  // IPVLAN subinterface will have the same mac as the parent interface mac
1828  // skip adding the route, as these routes are already installed as part
1829  // of parent interface add.
1830  if (mac_.ToString() == vmi->vm_mac().ToString())
1831  return true;
1832 
1833  if (vrf_ == NULL)
1834  return false;
1836  vmi->forwarding_vrf()->GetName(),
1837  vmi->learning_enabled(),
1838  vmi->etree_leaf(),
1839  vmi->layer2_control_word(),
1840  vmi->name());
1841 
1843  vmi->GetUuid(), vmi->name()),
1844  true, InterfaceNHFlags::BRIDGE, mac_);
1845  l2_nh_policy_ = static_cast<NextHop *>
1846  (agent->nexthop_table()->FindActiveEntry(&key1));
1847 
1849  vmi->GetUuid(), vmi->name()),
1850  false, InterfaceNHFlags::BRIDGE, mac_);
1851  l2_nh_no_policy_ = static_cast<NextHop *>
1852  (agent->nexthop_table()->FindActiveEntry(&key2));
1853 
1854  // Update L2 mpls label from nh entry
1855  if (vmi->policy_enabled()) {
1856  l2_label_ = l2_nh_policy_->mpls_label()->label();
1857  } else {
1858  l2_label_ = l2_nh_no_policy_->mpls_label()->label();
1859  }
1860 
1861  vmi->AddL2InterfaceRoute(IpAddress(), mac_, IpAddress());
1862  return true;
1863 }
1864 
1866  VmInterface *vmi) const {
1867  if (vrf_ == NULL)
1868  return false;
1869 
1870  // IPVLAN subinterface will have the same mac as the parent interface mac
1871  // skip deleting the route as the parent interface is not deleted.
1872  if (mac_.ToString() == vmi->vm_mac().ToString())
1873  return true;
1874 
1876  mac_);
1877  l2_nh_policy_.reset();
1878  l2_nh_no_policy_.reset();
1881  vmi->name());
1882  return true;
1883 }
1884 
1886 (const Agent *agent, const VmInterface *vmi) const {
1887  // TODO : Should be check health-check state here?
1888  if (GetMacIpActiveState(this, vmi) == false)
1889  return VmInterfaceState::DEL;
1890 
1891  if (vrf_ != vmi->vrf())
1893 
1894  if (ethernet_tag_ != vmi->ethernet_tag())
1896 
1897  return VmInterfaceState::ADD;
1898 }
1899 
1901  VmInterface *vmi) const {
1902  if (vrf_ == NULL)
1903  return false;
1905  vmi->forwarding_vrf()->GetName(),
1906  vmi->learning_enabled(),
1907  vmi->name());
1909  vmi->GetUuid(), vmi->name()),
1910  true, InterfaceNHFlags::INET4, mac_);
1911  l3_nh_policy_ = static_cast<NextHop *>
1912  (agent->nexthop_table()->FindActiveEntry(&key1));
1913 
1915  vmi->GetUuid(), vmi->name()),
1916  false, InterfaceNHFlags::INET4, mac_);
1917  l3_nh_no_policy_ = static_cast<NextHop *>
1918  (agent->nexthop_table()->FindActiveEntry(&key2));
1919  // Update L3 mpls label from nh entry
1920  if (vmi->policy_enabled()) {
1921  l3_label_ = l3_nh_policy_->mpls_label()->label();
1922  } else {
1923  l3_label_ = l3_nh_no_policy_->mpls_label()->label();
1924  }
1925  std::string vn_name;
1926  if (vmi->vn()) {
1927  vn_name = vmi->vn()->GetName();
1928  }
1929  uint32_t plen = 0;
1930  if (ip_.is_v4()) {
1931  plen = Address::kMaxV4PrefixLen;
1932  } else {
1933  plen = Address::kMaxV6PrefixLen;
1934  }
1935 
1936 
1937  vmi->AddL2InterfaceRoute(ip_, mac_, IpAddress());
1938  vmi->AddRoute(vrf_->GetName(), ip_, plen, vmi->vn()->GetName(), false,
1939  false, false, false, vmi->vm_ip_service_addr(),
1940  Ip4Address(0), CommunityList(), l3_label_,
1941  VmInterface::kInterface, true);
1942  return true;
1943 }
1944 
1946  VmInterface *vmi) const {
1947  if (vrf_ == NULL)
1948  return false;
1949  uint32_t plen = 0;
1950  if (ip_.is_v4()) {
1951  plen = Address::kMaxV4PrefixLen;
1952  } else {
1953  plen = Address::kMaxV6PrefixLen;
1954  }
1955  vmi->DeleteL2InterfaceRoute(vrf_, ethernet_tag_, ip_, mac_);
1956  vmi->DeleteRoute(vrf_->GetName(), ip_, plen);
1958  mac_, vmi->name());
1959  l3_nh_policy_.reset();
1960  l3_nh_no_policy_.reset();
1961  return true;
1962 }
1963 
1965  const VmInterface *vmi) const {
1966  vrf_ = vmi->vrf();
1967  ethernet_tag_ = vmi->ethernet_tag();
1968 }
1969 
1971  if (learnt_mac_ip_list_.list_.size() >= kMaxMacIpLimit) {
1972  return true;
1973  }
1974  return false;
1975 }
1977 // FloatingIp routines
1980  FloatingIpSet::iterator it = floating_ip_list_.list_.begin();
1981  while (it != floating_ip_list_.list_.end()) {
1982  FloatingIpSet::iterator prev = it++;
1983  if (prev->del_pending_ == false)
1984  continue;
1985 
1986  if (prev->floating_ip_.is_v4()) {
1988  assert(floating_ip_list_.v4_count_ >= 0);
1989  } else {
1991  assert(floating_ip_list_.v6_count_ >= 0);
1992  }
1993  floating_ip_list_.list_.erase(prev);
1994  }
1995 }
1996 
1998  std::pair<FloatingIpSet::iterator, bool> ret = list_.insert(*rhs);
1999  if (ret.second) {
2000  if (rhs->floating_ip_.is_v4()) {
2001  v4_count_++;
2002  } else {
2003  v6_count_++;
2004  }
2005  }
2006 }
2007 
2009  const FloatingIp *rhs) {
2010  if (lhs->fixed_ip_ != rhs->fixed_ip_) {
2011  lhs->fixed_ip_ = rhs->fixed_ip_;
2012  }
2013 
2014  lhs->direction_ = rhs->direction_;
2016  lhs->src_port_map_ = rhs->src_port_map_;
2017  lhs->dst_port_map_ = rhs->dst_port_map_;
2018  lhs->set_del_pending(false);
2019 }
2020 
2021 void VmInterface::FloatingIpList::Remove(FloatingIpSet::iterator &it) {
2022  it->set_del_pending(true);
2023 }
2024 
2026  VmInterface *vmi,
2027  VmInterfaceState::Op l2_force_op,
2028  VmInterfaceState::Op l3_force_op) {
2029  FloatingIpSet::iterator it = list_.begin();
2030  while (it != list_.end()) {
2031  FloatingIpSet::iterator prev = it++;
2032  VmInterfaceState::Op l2_op = prev->GetOp(l2_force_op);
2033  VmInterfaceState::Op l3_op = prev->GetOp(l3_force_op);
2034  vmi->UpdateState(&(*prev), l2_op, l3_op);
2035  }
2036  return true;
2037 }
2038 
2040  ListEntry(), VmInterfaceState(), floating_ip_(), vn_(NULL),
2041  vrf_(NULL, this), vrf_name_(""), vn_uuid_(),
2042  fixed_ip_(), direction_(DIRECTION_BOTH), port_map_enabled_(false),
2043  src_port_map_(), dst_port_map_(), ethernet_tag_(0), port_nat_(false) {
2044 }
2045 
2047  ListEntry(rhs.del_pending_),
2048  VmInterfaceState(rhs.l2_installed_, rhs.l3_installed_),
2049  floating_ip_(rhs.floating_ip_), vn_(rhs.vn_), vrf_(rhs.vrf_, this),
2050  vrf_name_(rhs.vrf_name_), vn_uuid_(rhs.vn_uuid_), fixed_ip_(rhs.fixed_ip_),
2051  direction_(rhs.direction_), port_map_enabled_(rhs.port_map_enabled_),
2052  src_port_map_(rhs.src_port_map_), dst_port_map_(rhs.dst_port_map_),
2053  ethernet_tag_(rhs.ethernet_tag_), port_nat_(rhs.port_nat_) {
2054 }
2055 
2057  const std::string &vrf,
2058  const boost::uuids::uuid &vn_uuid,
2059  const IpAddress &fixed_ip,
2060  Direction direction,
2061  bool port_map_enabled,
2062  const PortMap &src_port_map,
2063  const PortMap &dst_port_map,
2064  bool port_nat) :
2065  ListEntry(), VmInterfaceState(),floating_ip_(addr), vn_(NULL),
2066  vrf_(NULL, this), vrf_name_(vrf), vn_uuid_(vn_uuid), fixed_ip_(fixed_ip),
2067  direction_(direction), port_map_enabled_(port_map_enabled),
2068  src_port_map_(src_port_map), dst_port_map_(dst_port_map), ethernet_tag_(0),
2069  port_nat_(port_nat) {
2070 }
2071 
2073 }
2074 
2076  const FloatingIp &rhs) const {
2077  return lhs.IsLess(&rhs);
2078 }
2079 
2080 // Compare key for FloatingIp. Key is <floating_ip_ and vrf_name_> for both
2081 // Config and Operational processing
2083  if (floating_ip_ != rhs->floating_ip_)
2084  return floating_ip_ < rhs->floating_ip_;
2085 
2086  return (vrf_name_ < rhs->vrf_name_);
2087 }
2088 
2089 const IpAddress
2091  if (fixed_ip_.is_unspecified()) {
2092  if (floating_ip_.is_v4() == true) {
2093  return vmi->primary_ip_addr();
2094  } else {
2095  return vmi->primary_ip6_addr();
2096  }
2097  }
2098  return fixed_ip_;
2099 }
2100 
2102  return port_map_enabled_;
2103 }
2104 
2106  return src_port_map_.size();
2107 }
2108 
2110  return port_nat_;
2111 }
2112 
2114  uint16_t src_port) const {
2115  PortMapIterator it = src_port_map_.find(PortMapKey(protocol, src_port));
2116  if (it == src_port_map_.end())
2117  return -1;
2118  return it->second;
2119 }
2120 
2122  uint16_t dst_port) const {
2123  PortMapIterator it = dst_port_map_.find(PortMapKey(protocol, dst_port));
2124  if (it == dst_port_map_.end())
2125  return -1;
2126  return it->second;
2127 }
2128 
2130  const VmInterface *vmi) const {
2131  // Delete for FloatingIp happens in CleanupFloatingIpList(). So, dont
2132  // update vn_ and vrf_ fields in case of delete
2133  if (del_pending_) {
2134  vn_ = NULL;
2135  vrf_ = NULL;
2136  return;
2137  }
2138 
2139  InterfaceTable *table = static_cast<InterfaceTable *>(vmi->get_table());
2140  if (vn_.get() == NULL)
2141  vn_ = table->FindVnRef(vn_uuid_);
2142 
2143  if (vrf_.get() == NULL)
2144  vrf_ = table->FindVrfRef(vrf_name_);
2145  ethernet_tag_ = vmi->ethernet_tag();
2146 
2147  return;
2148 }
2149 
2151 (const Agent *agent, const VmInterface *vmi) const {
2152  if (GetIpActiveState(floating_ip_, vmi) == false)
2153  return VmInterfaceState::DEL;
2154 
2155  if (vmi->vrf() == NULL || vmi->vn() == NULL)
2156  return VmInterfaceState::DEL;
2157 
2158  return VmInterfaceState::ADD;
2159 }
2160 
2162  VmInterface *vmi) const {
2163  if (vrf_.get() == NULL || vn_.get() == NULL || port_nat_)
2164  return false;
2165 
2166  fixed_ip_ = GetFixedIp(vmi);
2167  uint8_t plen = floating_ip_.is_v4() ?
2170  if (floating_ip_.is_v6())
2171  service_ip = Ip6Address();
2172 
2173  bool ecmp = floating_ip_.is_v4() ? vmi->ecmp() : vmi->ecmp6();
2174  vmi->AddRoute(vrf_.get()->GetName(), floating_ip_, plen, vn_->GetName(),
2175  false, ecmp, false, false, service_ip, fixed_ip_,
2176  CommunityList(), vmi->label(), kInterface);
2177 
2178  InterfaceTable *table = static_cast<InterfaceTable *>(vmi->get_table());
2179  if (table->update_floatingip_cb().empty() == false) {
2180  table->update_floatingip_cb()(vmi, vn_.get(), floating_ip_,
2181  false);
2182  //TODO:: callback for DNS handling
2183  }
2184 
2185  return true;
2186 }
2187 
2189  VmInterface *vmi) const {
2190  if (vrf_.get() == NULL)
2191  return false;
2192  uint8_t plen = floating_ip_.is_v4() ?
2194 
2195  vmi->DeleteRoute(vrf_.get()->GetName(), floating_ip_, plen);
2196 
2197  InterfaceTable *table = static_cast<InterfaceTable *>(vmi->get_table());
2198  if (table->update_floatingip_cb().empty() == false) {
2199  table->update_floatingip_cb()(vmi, vn_.get(), floating_ip_,
2200  true);
2201  //TODO:: callback for DNS handling
2202  }
2203  return true;
2204 }
2205 
2207 (const Agent *agent, const VmInterface *vmi) const {
2208  if (GetIpActiveState(floating_ip_, vmi) == false)
2209  return VmInterfaceState::DEL;
2210 
2211  if (vmi->vrf() == NULL || vmi->vn() == NULL)
2212  return VmInterfaceState::DEL;
2213 
2214  if (ethernet_tag_ != vmi->ethernet_tag())
2216 
2217  return VmInterfaceState::ADD;
2218 }
2219 
2221  VmInterface *vmi) const {
2222  if (vrf_.get() == NULL || vn_.get() == NULL || port_nat_)
2223  return false;
2224 
2225  SecurityGroupList sg_id_list;
2226  vmi->CopySgIdList(&sg_id_list);
2227 
2228  TagList tag_id_list;
2229  vmi->CopyTagIdList(&tag_id_list);
2230 
2231  PathPreference path_preference;
2232  vmi->SetPathPreference(&path_preference, false, GetFixedIp(vmi));
2233 
2234  EvpnAgentRouteTable *evpn_table = static_cast<EvpnAgentRouteTable *>
2235  (vrf_->GetEvpnRouteTable());
2236 
2237  std::string vn_name;
2238  if (vmi->vn()) {
2239  vn_name = vmi->vn()->GetName();
2240  }
2241 
2242  evpn_table->AddReceiveRoute(vmi->peer_.get(), vrf_->GetName(),
2243  vmi->l2_label(), vmi->vm_mac(), floating_ip_,
2244  ethernet_tag_, vn_name,
2245  path_preference);
2246  return true;
2247 }
2248 
2250  VmInterface *vmi) const {
2251  if (vrf_.get() == NULL)
2252  return false;
2253 
2254  EvpnAgentRouteTable *evpn_table =
2255  static_cast<EvpnAgentRouteTable *>(vrf_->GetEvpnRouteTable());
2256  if (evpn_table == NULL) {
2257  return false;
2258  }
2259 
2260  evpn_table->DelLocalVmRoute(vmi->peer_.get(), vrf_->GetName(),
2261  vmi->vm_mac(), vmi, floating_ip_,
2262  ethernet_tag_);
2263  return true;
2264 }
2265 
2267 // AliasIp routines
2270  std::pair<AliasIpSet::iterator, bool> ret = list_.insert(*rhs);
2271  if (ret.second) {
2272  if (rhs->alias_ip_.is_v4()) {
2273  v4_count_++;
2274  } else {
2275  v6_count_++;
2276  }
2277  }
2278 }
2279 
2280 void VmInterface::AliasIpList::Update(const AliasIp *lhs, const AliasIp *rhs) {
2281  lhs->set_del_pending(false);
2282 }
2283 
2284 void VmInterface::AliasIpList::Remove(AliasIpSet::iterator &it) {
2285  it->set_del_pending(true);
2286 }
2287 
2289  VmInterfaceState::Op l2_force_op,
2290  VmInterfaceState::Op l3_force_op) {
2291  AliasIpSet::iterator it = list_.begin();
2292  while (it != list_.end()) {
2293  AliasIpSet::iterator prev = it++;
2294  VmInterfaceState::Op l2_op = prev->GetOp(l2_force_op);
2295  VmInterfaceState::Op l3_op = prev->GetOp(l3_force_op);
2296  vmi->UpdateState(&(*prev), l2_op, l3_op);
2297  }
2298  return true;
2299 }
2300 
2302  AliasIpSet::iterator it = alias_ip_list_.list_.begin();
2303  while (it != alias_ip_list_.list_.end()) {
2304  AliasIpSet::iterator prev = it++;
2305  if (prev->del_pending_ == false)
2306  continue;
2307 
2308  if (prev->alias_ip_.is_v4()) {
2310  assert(alias_ip_list_.v4_count_ >= 0);
2311  } else {
2313  assert(alias_ip_list_.v6_count_ >= 0);
2314  }
2315  alias_ip_list_.list_.erase(prev);
2316  }
2317 }
2318 
2320  ListEntry(), VmInterfaceState(), alias_ip_(), vn_(NULL), vrf_(NULL, this),
2321  vrf_name_(""), vn_uuid_() {
2322 }
2323 
2325  ListEntry(rhs.del_pending_),
2326  VmInterfaceState(rhs.l2_installed_, rhs.l3_installed_),
2327  alias_ip_(rhs.alias_ip_), vn_(rhs.vn_), vrf_(rhs.vrf_, this),
2328  vrf_name_(rhs.vrf_name_), vn_uuid_(rhs.vn_uuid_) {
2329 }
2330 
2331 VmInterface::AliasIp::AliasIp(const IpAddress &addr, const std::string &vrf,
2332  const boost::uuids::uuid &vn_uuid) :
2333  ListEntry(), VmInterfaceState(), alias_ip_(addr), vn_(NULL),
2334  vrf_(NULL, this), vrf_name_(vrf), vn_uuid_(vn_uuid) {
2335 }
2336 
2338 }
2339 
2341  const AliasIp &rhs) const {
2342  return lhs.IsLess(&rhs);
2343 }
2344 
2345 // Compare key for AliasIp. Key is <alias_ip_ and vrf_name_> for both
2346 // Config and Operational processing
2347 bool VmInterface::AliasIp::IsLess(const AliasIp *rhs) const {
2348  if (alias_ip_ != rhs->alias_ip_)
2349  return alias_ip_ < rhs->alias_ip_;
2350 
2351  return (vrf_name_ < rhs->vrf_name_);
2352 }
2353 
2355  const VmInterface *vmi) const {
2356  if (GetIpActiveState(alias_ip_, vmi) == false)
2357  return VmInterfaceState::DEL;
2358 
2359  if (vrf_ != vmi->vrf())
2361 
2362  return VmInterfaceState::ADD;
2363 }
2364 
2366  const VmInterface *vmi) const {
2367  if (del_pending_) {
2368  vrf_ = NULL;
2369  vn_ = NULL;
2370  return;
2371  }
2372 
2373  InterfaceTable *table = static_cast<InterfaceTable *>(vmi->get_table());
2374  if (vn_.get() == NULL) {
2375  vn_ = table->FindVnRef(vn_uuid_);
2376  assert(vn_.get());
2377  }
2378 
2379  if (vrf_.get() == NULL) {
2380  vrf_ = table->FindVrfRef(vrf_name_);
2381  assert(vrf_.get());
2382  }
2383  return;
2384 }
2385 
2386 bool VmInterface::AliasIp::AddL3(const Agent *agent, VmInterface *vmi) const {
2387  if (vrf_.get() == NULL || vn_.get() == NULL)
2388  return false;
2389 
2390  uint8_t plen = alias_ip_.is_v4() ?
2393  if (alias_ip_.is_v6())
2394  service_ip = Ip6Address();
2395  vmi->AddRoute(vrf_->GetName(), alias_ip_, plen, vn_->GetName(), false,
2396  vmi->ecmp(), false, false, service_ip, service_ip,
2397  CommunityList(), vmi->label(), kInterface);
2398  return true;
2399 }
2400 
2402  VmInterface *vmi) const {
2403  if (vrf_ == NULL)
2404  return false;
2405  uint8_t plen = alias_ip_.is_v4() ?
2407  vmi->DeleteRoute(vrf_.get()->GetName(), alias_ip_, plen);
2408  return true;
2409 }
2410 
2412 // StaticRoute routines
2415  list_.insert(*rhs);
2416 }
2417 
2419  const StaticRoute *rhs) {
2420  if (lhs->communities_ != rhs->communities_) {
2421  (const_cast<StaticRoute *>(lhs))->communities_ = rhs->communities_;
2422  }
2423  lhs->set_del_pending(false);
2424 }
2425 
2426 void VmInterface::StaticRouteList::Remove(StaticRouteSet::iterator &it) {
2427  it->set_del_pending(true);
2428 }
2429 
2431 (const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op,
2432  VmInterfaceState::Op l3_force_op) {
2433  StaticRouteSet::iterator it = list_.begin();
2434  while (it != list_.end()) {
2435  StaticRouteSet::iterator prev = it++;
2436  VmInterfaceState::Op l2_op = prev->GetOp(l2_force_op);
2437  VmInterfaceState::Op l3_op = prev->GetOp(l3_force_op);
2438  vmi->UpdateState(&(*prev), l2_op, l3_op);
2439  if (prev->del_pending_) {
2440  list_.erase(prev);
2441  }
2442  }
2443  return true;
2444 }
2445 
2447  ListEntry(), VmInterfaceState(), vrf_(), addr_(), plen_(0), gw_list_(),
2448  communities_() {
2449 }
2450 
2452  ListEntry(rhs.del_pending_),
2453  VmInterfaceState(rhs.l2_installed_, rhs.l3_installed_),
2454  vrf_(rhs.vrf_), addr_(rhs.addr_), plen_(rhs.plen_), gw_list_(rhs.gw_list_),
2455  communities_(rhs.communities_) {
2456 }
2457 
2459  uint32_t plen, const AddressList &gw_list,
2460  const CommunityList &communities) :
2461  ListEntry(), VmInterfaceState(), vrf_(), addr_(addr), plen_(plen), gw_list_(gw_list),
2462  communities_(communities) {
2463 }
2464 
2466 }
2467 
2469  const StaticRoute &rhs) const {
2470  return lhs.IsLess(&rhs);
2471 }
2472 
2474  if (addr_ != rhs->addr_)
2475  return addr_ < rhs->addr_;
2476 
2477  if (plen_ != rhs->plen_) {
2478  return plen_ < rhs->plen_;
2479  }
2480 
2481  return gw_list_.size() < rhs->gw_list_.size();
2482 }
2483 
2485  const VmInterface *vmi) const {
2486  if (vmi->vmi_type() == VmInterface::VHOST) {
2487  vrf_ = vmi->forwarding_vrf();
2488  } else {
2489  vrf_ = vmi->vrf();
2490  }
2491 }
2492 
2494 (const Agent *agent, const VmInterface *vmi) const {
2495  if (GetIpActiveState(addr_, vmi) == false)
2496  return VmInterfaceState::DEL;
2497 
2498  if (vrf_ != vmi->vrf())
2500 
2501  return VmInterfaceState::ADD;
2502 }
2503 
2505  VmInterface *vmi) const {
2506  if (vrf_ == NULL)
2507  return false;
2508  std::string vn_name;
2509  if (vmi->vn()) {
2510  vn_name = vmi->vn()->GetName();
2511  } else if (vmi->vmi_type() == VHOST) {
2512  vn_name = agent->fabric_vn_name();
2513  }
2514 
2515  if (addr_.is_v4() && !gw_list_.empty() && gw_list_[0] != Ip4Address(0)) {
2516  SecurityGroupList sg_id_list;
2517  vmi->CopySgIdList(&sg_id_list);
2518 
2519  TagList tag_id_list;
2520  vmi->CopyTagIdList(&tag_id_list);
2521 
2522  VnListType vn_list;
2523  if (vmi->vn()) {
2524  vn_list.insert(vn_name);
2525  }
2526 
2527  bool native_encap = false;
2528  const Peer *peer = vmi->peer_.get();
2529  if (vrf_->GetName() == agent->fabric_vrf_name()) {
2530  vn_list.insert(agent->fabric_vn_name());
2531  native_encap = true;
2532  peer = agent->local_peer();
2533  }
2534 
2536  (peer, vrf_->GetName(), addr_.to_v4(), plen_,
2537  gw_list_, vn_list, vmi->vrf_->table_label(),
2538  sg_id_list, tag_id_list, communities_, native_encap);
2539  } else {
2540  IpAddress dependent_ip;
2541  bool ecmp = false;
2542  if (addr_.is_v4()) {
2543  dependent_ip = vmi->primary_ip_addr();
2544  ecmp = vmi->ecmp();
2545  } else if (addr_.is_v6()) {
2546  dependent_ip = vmi->primary_ip6_addr();
2547  ecmp = vmi->ecmp6();
2548  }
2549  vmi->AddRoute(vrf_->GetName(), addr_, plen_, vn_name,
2550  false, ecmp, false, false, vmi->GetServiceIp(addr_),
2551  dependent_ip, communities_, vmi->label(),
2553  }
2554  return true;
2555 }
2556 
2558  VmInterface *vmi) const {
2559  if (vrf_ == NULL)
2560  return false;
2561 
2562  const Peer *peer = vmi->peer();
2563  if (vmi->vmi_type() == VHOST) {
2564  peer = agent->local_peer();
2565  }
2566  InetUnicastAgentRouteTable::Delete(peer, vrf_->GetName(),
2567  addr_, plen_);
2568  return true;
2569 }
2570 
2572 //Allowed addresss pair route
2575 (const AllowedAddressPair *rhs){
2576  list_.insert(*rhs);
2577 }
2578 
2580 (const AllowedAddressPair *lhs, const AllowedAddressPair *rhs) {
2581  lhs->set_del_pending(false);
2582  if (lhs->ecmp_ != rhs->ecmp_) {
2583  lhs->ecmp_ = rhs->ecmp_;
2584  lhs->ecmp_config_changed_ = true;
2585  }
2586 }
2587 
2589 (AllowedAddressPairSet::iterator &it) {
2590  it->set_del_pending(true);
2591 }
2592 
2594 (const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op,
2595  VmInterfaceState::Op l3_force_op) {
2596  AllowedAddressPairSet::iterator it = list_.begin();
2597  while (it != list_.end()) {
2598  AllowedAddressPairSet::iterator prev = it++;
2599  if (!prev->del_pending_)
2600  continue;
2601  VmInterfaceState::Op l2_op = prev->GetOp(l2_force_op);
2602  VmInterfaceState::Op l3_op = prev->GetOp(l3_force_op);
2603  vmi->UpdateState(&(*prev), l2_op, l3_op);
2604  list_.erase(prev);
2605  }
2606  it = list_.begin();
2607  while (it != list_.end()) {
2608  AllowedAddressPairSet::iterator prev = it++;
2609  VmInterfaceState::Op l2_op = prev->GetOp(l2_force_op);
2610  VmInterfaceState::Op l3_op = prev->GetOp(l3_force_op);
2611  vmi->UpdateState(&(*prev), l2_op, l3_op);
2612  }
2613  return true;
2614 }
2615 
2617  ListEntry(), VmInterfaceState(), addr_(), plen_(0), ecmp_(false), mac_(),
2618  ecmp_config_changed_(false),
2619  service_ip_(), label_(MplsTable::kInvalidLabel), policy_enabled_nh_(NULL),
2620  policy_disabled_nh_(NULL), vrf_(NULL), ethernet_tag_(0) {
2621 }
2622 
2624  const AllowedAddressPair &rhs) : ListEntry(rhs.del_pending_),
2625  VmInterfaceState(rhs.l2_installed_, rhs.l3_installed_),
2626  addr_(rhs.addr_), plen_(rhs.plen_), ecmp_(rhs.ecmp_),
2627  mac_(rhs.mac_),
2628  ecmp_config_changed_(rhs.ecmp_config_changed_),
2629  service_ip_(rhs.service_ip_), label_(rhs.label_),
2630  policy_enabled_nh_(rhs.policy_enabled_nh_),
2631  policy_disabled_nh_(rhs.policy_disabled_nh_),
2632  vrf_(rhs.vrf_), ethernet_tag_(rhs.ethernet_tag_) {
2633 }
2634 
2636  uint32_t plen, bool ecmp,
2637  const MacAddress &mac) :
2638  ListEntry(), VmInterfaceState(), addr_(addr), plen_(plen), ecmp_(ecmp),
2639  mac_(mac), ecmp_config_changed_(false),
2640  label_(MplsTable::kInvalidLabel), policy_enabled_nh_(NULL),
2641  policy_disabled_nh_(NULL), vrf_(NULL), ethernet_tag_(0) {
2642 }
2643 
2645 }
2646 
2648  const AllowedAddressPair &rhs)
2649  const {
2650  return lhs.IsLess(&rhs);
2651 }
2652 
2654  const {
2655  if (addr_ != rhs->addr_)
2656  return addr_ < rhs->addr_;
2657 
2658  if (plen_ != rhs->plen_) {
2659  return plen_ < rhs->plen_;
2660  }
2661 
2662  return mac_ < rhs->mac_;
2663 }
2664 
2666  const VmInterface *vmi) const {
2667  vrf_ = vmi->vrf();
2668  ethernet_tag_ = vmi->ethernet_tag();
2669 }
2670 
2672 (const Agent *agent, const VmInterface *vmi) const {
2673  if (vmi->bridging() == false)
2674  return VmInterfaceState::DEL;
2675 
2676  if (ethernet_tag_ != vmi->ethernet_tag())
2678 
2679  return VmInterfaceState::ADD;
2680 }
2681 
2683  VmInterface *vmi) const {
2684  if (vrf_ == NULL || mac_ == MacAddress::kZeroMac)
2685  return false;
2686 
2687  IpAddress dependent_rt;
2688  IpAddress route_addr;
2689  if (addr_.is_v4()) {
2690  if (plen_ == 32) {
2691  route_addr = addr_;
2692  } else {
2693  route_addr = Ip4Address(0);
2694  }
2695  dependent_rt = Ip4Address(0);
2696  } else if (addr_.is_v6()) {
2697  if (plen_ == 128) {
2698  route_addr = addr_;
2699  } else {
2700  route_addr = Ip6Address();
2701  }
2702  dependent_rt = Ip6Address();
2703  }
2704  vmi->AddL2InterfaceRoute(route_addr, mac_, dependent_rt);
2705  return true;
2706 }
2707 
2709  VmInterface *vmi) const {
2710  if (vrf_ == NULL || mac_ == MacAddress::kZeroMac)
2711  return false;
2712 
2713  IpAddress route_addr;
2714  if (addr_.is_v4()) {
2715  if (plen_ == 32) {
2716  route_addr = addr_;
2717  } else {
2718  route_addr = Ip4Address(0);
2719  }
2720  } else if (addr_.is_v6()) {
2721  if (plen_ == 128) {
2722  route_addr = addr_;
2723  } else {
2724  route_addr = Ip6Address();
2725  }
2726  }
2727  vmi->DeleteL2InterfaceRoute(vrf_, ethernet_tag_, route_addr, mac_);
2728  return true;
2729 }
2730 
2732 (const Agent *agent, const VmInterface *vmi) const {
2733  if (GetIpActiveState(addr_, vmi) == false)
2734  return VmInterfaceState::DEL;
2735 
2736  return VmInterfaceState::ADD;
2737 }
2738 
2740  VmInterface *vmi) const {
2741  if (vrf_ == NULL)
2742  return false;
2743 
2744  vmi->DeleteRoute(vrf_->GetName(), addr_, plen_);
2747  }
2748  policy_enabled_nh_ = NULL;
2749  policy_disabled_nh_ = NULL;
2750  return true;
2751 }
2752 
2754  VmInterface *vmi) const {
2755  if (vrf_ == NULL || vmi->vn_ == NULL)
2756  return false;
2757 
2758  service_ip_ = vmi->GetServiceIp(addr_);
2759  if (mac_ == MacAddress::kZeroMac || mac_ == vmi->vm_mac_) {
2760  vmi->AddRoute(vrf_->GetName(), addr_, plen_, vmi->vn_->GetName(),
2761  false, ecmp_, false, false, service_ip_, Ip4Address(0),
2762  CommunityList(), vmi->label(), kInterface);
2763  return true;
2764  }
2765 
2767  (vmi->GetUuid(), mac_, vmi->vrf_->GetName(), vmi->learning_enabled_,
2768  vmi->name());
2769 
2771  vmi->name());
2772 
2773  // Get policy disabled nh first
2774  InterfaceNHKey key(vmi_key.Clone(), false, InterfaceNHFlags::INET4, mac_);
2775  InterfaceNH *nh =static_cast<InterfaceNH *>
2776  (agent->nexthop_table()->FindActiveEntry(&key));
2777  policy_disabled_nh_ = nh;
2778  // Ensure nexthop to be deleted upon refcount falling to 0
2779  nh->set_delete_on_zero_refcount(true);
2780 
2781  // Get policy enabled nh first
2782  InterfaceNHKey key1(vmi_key.Clone(), true, InterfaceNHFlags::INET4, mac_);
2783  nh = static_cast<InterfaceNH *>(agent->
2784  nexthop_table()->FindActiveEntry(&key1));
2785  // Ensure nexthop to be deleted upon refcount falling to 0
2786  nh->set_delete_on_zero_refcount(true);
2787  policy_enabled_nh_ = nh;
2788 
2789  // Update AAP mpls label from nh entry
2790  if (vmi->policy_enabled()) {
2791  label_ = policy_enabled_nh_->mpls_label()->label();
2792  } else {
2793  label_ = policy_disabled_nh_->mpls_label()->label();
2794  }
2795 
2796  vmi->AddRoute(vrf_->GetName(), addr_, plen_, vmi->vn_->GetName(),
2797  false, ecmp_, false, false, service_ip_, Ip6Address(),
2799  return true;
2800 }
2801 
2803 // ServiceVlan routines
2806  list_.insert(*rhs);
2807 }
2808 
2810  const ServiceVlan *rhs) {
2811  if (lhs->vrf_name_ != rhs->vrf_name_) {
2812  lhs->vrf_name_ = rhs->vrf_name_;
2813  lhs->del_add_ = true;
2814  }
2815 
2816  if (lhs->addr_ != rhs->addr_) {
2817  lhs->addr_ = rhs->addr_;
2818  lhs->del_add_ = true;
2819  }
2820 
2821  if (lhs->addr6_ != rhs->addr6_) {
2822  lhs->addr6_ = rhs->addr6_;
2823  lhs->del_add_ = true;
2824  }
2825 
2826  if (lhs->smac_ != rhs->smac_) {
2827  lhs->smac_ = rhs->smac_;
2828  lhs->del_add_ = true;
2829  }
2830 
2831  if (lhs->dmac_ != rhs->dmac_) {
2832  lhs->dmac_ = rhs->dmac_;
2833  lhs->del_add_ = true;
2834  }
2835 
2836  lhs->set_del_pending(false);
2837 }
2838 
2839 void VmInterface::ServiceVlanList::Remove(ServiceVlanSet::iterator &it) {
2840  it->set_del_pending(true);
2841 }
2842 
2844 (const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op,
2845  VmInterfaceState::Op l3_force_op) {
2846  ServiceVlanSet::iterator it = list_.begin();
2847  while (it != list_.end()) {
2848  ServiceVlanSet::iterator prev = it++;
2849  if (prev->del_pending_ || prev->del_add_) {
2850  prev->Update(agent, vmi);
2851  if (prev->del_pending_) {
2852  list_.erase(prev);
2853  }
2854  }
2855  }
2856 
2857  it = list_.begin();
2858  while (it != list_.end()) {
2859  ServiceVlanSet::iterator prev = it++;
2860  prev->Update(agent, vmi);
2861  }
2862 
2863  return true;
2864 }
2865 
2867 // TagGroup routines
2870  ListEntry(), VmInterfaceState() , type_(0xFFFFFFFF), uuid_(nil_uuid()) {
2871 }
2872 
2874  ListEntry(rhs.del_pending_),
2875  VmInterfaceState(rhs.l2_installed_, rhs.l3_installed_),
2876  type_(rhs.type_), uuid_(rhs.uuid_) {
2877 }
2878 
2880  ListEntry(), VmInterfaceState(), type_(type), uuid_(u) {
2881 }
2882 
2884 }
2885 
2887  return uuid_ == rhs.uuid_;
2888 }
2889 
2891  const TagEntry &rhs) const {
2892  return lhs.IsLess(&rhs);
2893 }
2894 
2895 bool VmInterface::TagEntry::IsLess(const TagEntry *rhs) const {
2896  if (type_ != rhs->type_) {
2897  return type_ < rhs->type_;
2898  }
2899 
2900  //We can only have duplicate of tag of type Label
2901  //Rest of tags would be unique
2902  if (type_ != TagTable::LABEL) {
2903  return false;
2904  }
2905  return uuid_ < rhs->uuid_;
2906 }
2907 
2909  VmInterface *intrface) const {
2910  if (tag_.get() && tag_->tag_uuid() == uuid_) {
2911  return false;
2912  }
2913 
2914  TagKey tag_key(uuid_);
2915  typedef ::TagEntry GlobalTagEntry;
2916  tag_ = static_cast<GlobalTagEntry *>(agent->tag_table()->
2917  FindActiveEntry(&tag_key));
2918  return true;
2919 }
2920 
2922  VmInterface *intrface) const {
2923  tag_.reset();
2924  return true;
2925 }
2926 
2929  const VmInterface *vmi) const {
2930  if (del_pending_)
2932 
2933  return VmInterfaceState::ADD;
2934 }
2935 
2937  list_.insert(*rhs);
2938 }
2939 
2941  const TagEntry *rhs) {
2942  if (lhs->uuid_ != rhs->uuid_) {
2943  lhs->uuid_ = rhs->uuid_;
2944  }
2945 }
2946 
2947 void VmInterface::TagEntryList::Remove(TagEntrySet::iterator &it) {
2948  it->set_del_pending(true);
2949 }
2950 
2952  VmInterface *vmi,
2953  VmInterfaceState::Op l2_force_op,
2954  VmInterfaceState::Op l3_force_op) {
2955  TagEntrySet::iterator it = list_.begin();
2956  while (it != list_.end()) {
2957  TagEntrySet::iterator prev = it++;
2958  VmInterfaceState::Op l2_op = prev->GetOp(l2_force_op);
2959  VmInterfaceState::Op l3_op = prev->GetOp(l3_force_op);
2960  vmi->UpdateState(&(*prev), l2_op, l3_op);
2961  if (prev->del_pending()) {
2962  list_.erase(prev);
2963  }
2964  }
2965 
2966  vmi->UpdatePolicySet(agent);
2967  return true;
2968 }
2969 
2971 // ServiceVlan routines
2974  ListEntry(), tag_(0), vrf_name_(""), addr_(0), old_addr_(0),
2975  addr6_(), old_addr6_(), smac_(), dmac_(), vrf_(NULL, this),
2976  label_(MplsTable::kInvalidLabel), v4_rt_installed_(false),
2977  v6_rt_installed_(false), del_add_(false) {
2978 }
2979 
2981  ListEntry(rhs.del_pending_), tag_(rhs.tag_),
2982  vrf_name_(rhs.vrf_name_), addr_(rhs.addr_), old_addr_(rhs.old_addr_),
2983  addr6_(rhs.addr6_), old_addr6_(rhs.old_addr6_),
2984  vrf_(rhs.vrf_, this), label_(rhs.label_),
2985  v4_rt_installed_(rhs.v4_rt_installed_),
2986  v6_rt_installed_(rhs.v6_rt_installed_), del_add_(false) {
2987  smac_ = rhs.smac_;
2988  dmac_ = rhs.dmac_;
2989 }
2990 
2991 VmInterface::ServiceVlan::ServiceVlan(uint16_t tag, const std::string &vrf_name,
2992  const Ip4Address &addr,
2993  const Ip6Address &addr6,
2994  const MacAddress &smac,
2995  const MacAddress &dmac) :
2996  ListEntry(), tag_(tag), vrf_name_(vrf_name), addr_(addr), old_addr_(addr),
2997  addr6_(addr6), old_addr6_(addr6),
2998  smac_(smac), dmac_(dmac), vrf_(NULL, this),
2999  label_(MplsTable::kInvalidLabel) , v4_rt_installed_(false),
3000  v6_rt_installed_(false), del_add_(false) {
3001 }
3002 
3004 }
3005 
3007  const ServiceVlan &rhs) const {
3008  return lhs.IsLess(&rhs);
3009 }
3010 
3012  return tag_ < rhs->tag_;
3013 }
3014 
3016  VmInterface *vmi) const {
3017  InterfaceTable *table = static_cast<InterfaceTable *>(vmi->get_table());
3018  VrfEntry *vrf = table->FindVrfRef(vrf_name_);
3019 
3020  if (del_pending_ || vrf_ != vrf || vmi->ipv4_active() == false || del_add_) {
3021  if (v4_rt_installed_) {
3022  InetUnicastAgentRouteTable::Delete(vmi->peer(), vrf_->GetName(),
3023  old_addr_,
3025  v4_rt_installed_ = false;
3026  }
3027  }
3028 
3029  if (del_pending_ || vrf_ != vrf || vmi->ipv6_active() == false || del_add_) {
3030  if (v6_rt_installed_) {
3031  InetUnicastAgentRouteTable::Delete(vmi->peer(), vrf_->GetName(),
3032  old_addr6_,
3034  v6_rt_installed_ = false;
3035  }
3036  }
3037 
3038  if (del_pending_ || vrf_ != vrf || del_add_) {
3039  DeleteCommon(vmi);
3040  }
3041 
3042  vrf_ = vrf;
3043  old_addr_ = addr_;
3044  old_addr6_ = addr6_;
3045  bool old_del_add = del_add_;
3046  del_add_ = false;
3047 
3048  if (del_pending_ || vrf_ == NULL || old_del_add)
3049  return;
3050 
3051  if (vmi->ipv4_active() == false && vmi->ipv6_active() == false)
3052  return;
3053 
3055  AddCommon(agent, vmi);
3056  }
3057 
3058  SecurityGroupList sg_id_list;
3059  vmi->CopySgIdList(&sg_id_list);
3060 
3061  TagList tag_id_list;
3062  vmi->CopyTagIdList(&tag_id_list);
3063 
3064  VnListType vn_list;
3065  vn_list.insert(vmi->vn()->GetName());
3066 
3067  // Add both ipv4 *and* ipv6 service vlan route if one of v4 or v6 is active
3068  // TODO : Shouldnt route be added only if corresponding state is active?
3069  if (addr_.is_unspecified() == false) {
3070  PathPreference pref;
3071  vmi->SetServiceVlanPathPreference(&pref, addr_);
3072 
3074  (vmi->peer(), vrf_->GetName(), addr_, Address::kMaxV4PrefixLen,
3075  vmi->GetUuid(), tag_, label_, vn_list, sg_id_list,
3076  tag_id_list, pref);
3077  v4_rt_installed_ = true;
3078  }
3079 
3080  if (addr6_.is_unspecified() == false) {
3081  PathPreference pref;
3082  vmi->SetServiceVlanPathPreference(&pref, addr6_);
3083 
3085  (vmi->peer(), vrf_->GetName(), addr6_, Address::kMaxV6PrefixLen,
3086  vmi->GetUuid(), tag_, label_, vn_list, sg_id_list,
3087  tag_id_list, pref);
3088  v6_rt_installed_ = true;
3089  }
3090 
3091  return;
3092 }
3093 
3096  return;
3097 
3098  // Delete the L2 Recive routes added for smac_ and dmac_
3099  BridgeAgentRouteTable *table = static_cast<BridgeAgentRouteTable *>
3100  (vrf_->GetBridgeRouteTable());
3101  if (table) {
3102  table->Delete(vmi->peer(), vrf_->GetName(), dmac_, 0);
3103  table->Delete(vmi->peer(), vrf_->GetName(), smac_, 0);
3104  }
3105 
3106  VrfAssignTable::DeleteVlan(vmi->GetUuid(), tag_);
3107  VlanNH::Delete(vmi->GetUuid(), tag_);
3109 }
3110 
3112  const VmInterface *vmi) const {
3114  return;
3115 
3116  assert(vrf_);
3117  VlanNH::Create(vmi->GetUuid(), tag_, vrf_name_, smac_, dmac_);
3119  // Assign label_ from vlan NH db entry
3120  VlanNHKey key(vmi->GetUuid(), tag_);
3121  const NextHop *nh = static_cast<const NextHop *>
3122  (agent->nexthop_table()->FindActiveEntry(&key));
3123  label_ = nh->mpls_label()->label();
3124 
3125  // With IRB model, add L2 Receive route for SMAC and DMAC to ensure
3126  // packets from service vm go thru routing
3127  BridgeAgentRouteTable *table = static_cast<BridgeAgentRouteTable *>
3128  (vrf_->GetBridgeRouteTable());
3129  table->AddBridgeReceiveRoute(vmi->peer(), vrf_->GetName(), 0, dmac_,
3130  vmi->vn()->GetName());
3131  table->AddBridgeReceiveRoute(vmi->peer(), vrf_->GetName(), 0, smac_,
3132  vmi->vn()->GetName());
3133 }
3134 
3136 // VRF assign rule routines
3139  ListEntry(), id_(0), vrf_name_(" "), ignore_acl_(false) {
3140 }
3141 
3143  ListEntry(rhs.del_pending_), id_(rhs.id_),
3144  vrf_name_(rhs.vrf_name_), ignore_acl_(rhs.ignore_acl_),
3145  match_condition_(rhs.match_condition_) {
3146 }
3147 
3149 (uint32_t id, const autogen::MatchConditionType &match_condition,
3150  const std::string &vrf_name, bool ignore_acl):
3151  ListEntry(), id_(id), vrf_name_(vrf_name), ignore_acl_(ignore_acl),
3152  match_condition_(match_condition) {
3153 }
3154 
3156 }
3157 
3159  const VrfAssignRule &rhs) const {
3160  return lhs.IsLess(&rhs);
3161 }
3162 
3164  return id_ < rhs->id_;
3165 }
3166 
3168  list_.insert(*rhs);
3169 }
3170 
3172  const VrfAssignRule *rhs) {
3173  lhs->set_del_pending(false);
3174  lhs->match_condition_ = rhs->match_condition_;
3175  lhs->ignore_acl_ = rhs->ignore_acl_;
3176  lhs->vrf_name_ = rhs->vrf_name_;
3177 }
3178 
3179 void VmInterface::VrfAssignRuleList::Remove(VrfAssignRuleSet::iterator &it) {
3180  it->set_del_pending(true);
3181 }
3182 
3184 (const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op,
3185  VmInterfaceState::Op l3_force_op) {
3186  // Erase all delete marked entry
3187  VrfAssignRuleSet::iterator it = list_.begin();
3188  while (it != list_.end()) {
3189  VrfAssignRuleSet::iterator prev = it++;
3190  if (prev->del_pending_) {
3191  list_.erase(prev);
3192  }
3193  }
3194 
3195  // Delete vrf_assign_acl_ if there are no more ACE entries
3196  if (list_.size() == 0 || vmi->IsActive() == false) {
3197  if (vrf_assign_acl_.get() != NULL) {
3198  vrf_assign_acl_ = NULL;
3200  req.key.reset(new AclKey(vmi->GetUuid()));
3201  req.data.reset(NULL);
3202  agent->acl_table()->Process(req);
3203  }
3204  return true;
3205  }
3206 
3207  // One or more ace-entries present, create corresponding ACL
3208  AclSpec acl_spec;
3209  acl_spec.acl_id = vmi->GetUuid();
3210  uint32_t id = 0;
3211  for (it = list_.begin(); it != list_.end(); it++) {
3212  AclEntrySpec ace_spec;
3213  ace_spec.id = id++;
3214 
3215  if (ace_spec.Populate(&(it->match_condition_)) == false) {
3216  continue;
3217  }
3218 
3219  // Add both v4 and v6 rules regardless of whether interface is
3220  //ipv4_active_/ipv6_active_
3221  ActionSpec vrf_translate_spec;
3222  vrf_translate_spec.ta_type = TrafficAction::VRF_TRANSLATE_ACTION;
3223  vrf_translate_spec.simple_action = TrafficAction::VRF_TRANSLATE;
3224  vrf_translate_spec.vrf_translate.set_vrf_name(it->vrf_name_);
3225  vrf_translate_spec.vrf_translate.set_ignore_acl(it->ignore_acl_);
3226  ace_spec.action_l.push_back(vrf_translate_spec);
3227  acl_spec.acl_entry_specs_.push_back(ace_spec);
3228  }
3229 
3230  // ACL entries populated, add the DBEntry
3232  req.key.reset(new AclKey(acl_spec.acl_id));
3233  Agent *agent1 = static_cast<InterfaceTable *>(vmi->get_table())->agent();
3234  req.data.reset(new AclData(agent1, NULL, acl_spec));
3235  agent->acl_table()->Process(req);
3236 
3237  // Query the ACL entry and store it
3238  AclKey entry_key(vmi->GetUuid());
3239  vrf_assign_acl_ = static_cast<AclDBEntry *>
3240  (agent->acl_table()->FindActiveEntry(&entry_key));
3241  assert(vrf_assign_acl_);
3242  return true;
3243 }
3244 
3246 // RecevieRoute routines
3249  list_.insert(*rhs);
3250 }
3251 
3253  const VmiReceiveRoute *rhs) {
3254  lhs->set_del_pending(false);
3255 }
3256 
3257 void VmInterface::VmiReceiveRouteList::Remove(VmiReceiveRouteSet::iterator &it) {
3258  it->set_del_pending(true);
3259 }
3260 
3262  VmInterface *vmi,
3263  VmInterfaceState::Op l2_force_op,
3264  VmInterfaceState::Op l3_force_op) {
3265  VmiReceiveRouteSet::iterator it = list_.begin();
3266  while (it != list_.end()) {
3267  VmiReceiveRouteSet::iterator prev = it++;
3268  VmInterfaceState::Op l2_op = prev->GetOp(l2_force_op);
3269  VmInterfaceState::Op l3_op = prev->GetOp(l3_force_op);
3270  vmi->UpdateState(&(*prev), l2_op, l3_op);
3271  if (prev->del_pending_) {
3272  list_.erase(prev);
3273  }
3274  }
3275  return true;
3276 }
3277 
3279  ListEntry(), VmInterfaceState(), addr_(), plen_(0), add_l2_(false) {
3280 }
3281 
3283  ListEntry(rhs.del_pending_),
3284  VmInterfaceState(rhs.l2_installed_, rhs.l3_installed_),
3285  addr_(rhs.addr_), plen_(rhs.plen_), add_l2_(rhs.add_l2_) {
3286 }
3287 
3289  uint32_t plen,
3290  bool add_l2):
3291  ListEntry(), VmInterfaceState(), addr_(addr), plen_(plen), add_l2_(add_l2) {
3292 }
3293 
3295  const VmiReceiveRoute &rhs)
3296  const {
3297  return lhs.IsLess(&rhs);
3298 }
3299 
3301  if (addr_ != rhs->addr_) {
3302  return addr_ < rhs->addr_;
3303  }
3304 
3305  if (plen_ != rhs->plen_) {
3306  return plen_ < rhs->plen_;
3307  }
3308 
3309  return add_l2_ < rhs->add_l2_;
3310 }
3311 
3313  const VmInterface *vmi) const {
3314  vrf_ = vmi->forwarding_vrf();
3315 }
3316 
3319  const VmInterface *vmi) const {
3320  if (GetIpActiveState(addr_, vmi) == false)
3321  return VmInterfaceState::DEL;
3322 
3323  if (vrf_ != vmi->forwarding_vrf())
3325 
3326  return VmInterfaceState::ADD;
3327 }
3328 
3331  const VmInterface *vmi) const {
3332  if (add_l2_ == false) {
3334  }
3335 
3336  if (vrf_ != vmi->forwarding_vrf())
3338 
3339  return VmInterfaceState::ADD;
3340 }
3341 
3343  VmInterface *vmi) const {
3344  if (vrf_ == NULL) {
3345  return false;
3346  }
3347 
3348  ReceiveNH::Create(agent->nexthop_table(), vmi, vmi->policy_enabled());
3349  ReceiveNH::Create(agent->nexthop_table(), vmi, false);
3350  InetUnicastAgentRouteTable *table = vrf_->GetInet4UnicastRouteTable();
3352  vmi->name());
3353  if (addr_.is_v6()) {
3354  table = vrf_->GetInet6UnicastRouteTable();
3355  }
3356 
3357  table->AddVHostRecvRoute(agent->local_peer(), vrf_->GetName(), vmi_key,
3358  addr_, plen_, agent->fabric_vn_name(),
3359  vmi->policy_enabled(), true);
3360  return true;
3361 }
3362 
3364  VmInterface *vmi) const {
3365  if (vrf_ == NULL)
3366  return false;
3367 
3368  InetUnicastAgentRouteTable::Delete(agent->local_peer(), vrf_->GetName(),
3369  addr_, plen_);
3370  return true;
3371 }
3372 
3374  VmInterface *vmi) const {
3375  if (vrf_ == NULL) {
3376  return false;
3377  }
3378 
3379  BridgeAgentRouteTable *table =
3380  static_cast<BridgeAgentRouteTable *>(vrf_->GetRouteTable(Agent::BRIDGE));
3381  table->AddBridgeReceiveRoute(agent->local_peer(), vrf_->GetName(), 0,
3382  vmi->GetVifMac(agent), agent->fabric_vn_name());
3383  return true;
3384 }
3385 
3387  VmInterface *vmi) const {
3388  if (vrf_ == NULL)
3389  return false;
3390 
3391  BridgeAgentRouteTable::Delete(agent->local_peer(), vrf_->GetName(),
3392  vmi->GetVifMac(agent), 0);
3393  return true;
3394 }
3395 //Build ACL list to be applied on VMI
3396 //ACL list build on two criteria
3397 //1> global-application-policy set.
3398 //2> application-policy-set attached via application tag
3400  bool ret = false;
3401  FirewallPolicyList new_firewall_policy_list;
3402  FirewallPolicyList new_fwaas_firewall_policy_list;
3403 
3404  PolicySet *gps = agent->policy_set_table()->global_policy_set();
3405  if (gps) {
3406  new_firewall_policy_list = gps->fw_policy_list();
3407  }
3408 
3409  TagEntrySet::const_iterator it = tag_list_.list_.begin();
3410  for(; it != tag_list_.list_.end(); it++) {
3411  if (it->tag_ == NULL) {
3412  continue;
3413  }
3414 
3415  ::TagEntry::PolicySetList::const_iterator ps_it =
3416  it->tag_->policy_set_list().begin();
3417  for(; ps_it != it->tag_->policy_set_list().end(); ps_it++) {
3418  FirewallPolicyList &tag_fp_list = ps_it->get()->fw_policy_list();
3419  FirewallPolicyList::iterator fw_policy_it = tag_fp_list.begin();
3420  for (; fw_policy_it != tag_fp_list.end(); fw_policy_it++) {
3421  if (it->tag_->IsNeutronFwaasTag())
3422  new_fwaas_firewall_policy_list.push_back(*fw_policy_it);
3423  else
3424  new_firewall_policy_list.push_back(*fw_policy_it);
3425  }
3426  }
3427  }
3428 
3429  if (fw_policy_list_ != new_firewall_policy_list) {
3430  fw_policy_list_ = new_firewall_policy_list;
3431  ret = true;
3432  }
3433 
3434  if (fwaas_fw_policy_list_ != new_fwaas_firewall_policy_list) {
3435  fwaas_fw_policy_list_ = new_fwaas_firewall_policy_list;
3436  ret = true;
3437  }
3438 
3439  return ret;
3440 }
3441 
3442 void VmInterface::CopyTagIdList(TagList *tag_id_list) const {
3443  TagEntrySet::const_iterator it;
3444  for (it = tag_list_.list_.begin(); it != tag_list_.list_.end(); ++it) {
3445  if (it->del_pending_)
3446  continue;
3447  if (it->tag_.get() == NULL)
3448  continue;
3449  tag_id_list->push_back(it->tag_->tag_id());
3450  }
3451  std::sort(tag_id_list->begin(), tag_id_list->end());
3452 }
3453 
3454 void VmInterface::update_flow_count(int val) const {
3455  int max_flows = max_flows_;
3456  int new_flow_count = flow_count_.fetch_and_add(val);
3457 
3458  if (max_flows == 0) {
3459  // max_flows are not configured,
3460  // disable drop new flows and return
3462  return;
3463  }
3464 
3465  if (val < 0) {
3466  assert(new_flow_count >= val);
3467  if ((new_flow_count + val) <
3468  ((max_flows * (Agent::kDropNewFlowsRecoveryThreshold))/100)) {
3470  }
3471  } else {
3472  if ((new_flow_count + val) >= max_flows) {
3474  }
3475  }
3476 }
3477 
3479  if (drop_new_flows_vmi_ == drop_new_flows) {
3480  return;
3481  }
3483  DBRequest req;
3485  req.key.reset(new VmInterfaceKey(AgentKey::RESYNC,
3486  GetUuid(), ""));
3487  req.data.reset(new VmInterfaceNewFlowDropData(drop_new_flows));
3488  agent()->interface_table()->Enqueue(&req);
3489 }
PortSubscribeTable * port_subscribe_table() const
virtual bool UpdateList(const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op, VmInterfaceState::Op l3_force_op)
void Insert(const ServiceVlan *rhs)
VmInterfaceState::Op GetOpL2(const Agent *agent, const VmInterface *vmi) const
boost::uuids::uuid uuid_
Definition: interface.h:162
bool IsLess(const InstanceIp *rhs) const
bool DeleteL2(const Agent *agent, VmInterface *vmi) const
bool DeleteL2(const Agent *agent, VmInterface *vmi) const
void Update(const SecurityGroupEntry *lhs, const SecurityGroupEntry *rhs)
bool is_hc_active_
Definition: interface.h:169
BridgeDomainEntrySet list_
std::unique_ptr< LocalVmPortPeer > peer_
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
Definition: sg.h:13
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
void SetPathPreference(PathPreference *pref, bool ecmp, const IpAddress &dependent_ip) const
bool ecmp6() const
void AddReceiveRoute(const Peer *peer, const std::string &vrf_name, uint32_t label, const MacAddress &mac, const IpAddress &ip_addr, uint32_t ethernet_tag, const std::string &vn_name, const PathPreference &pref)
const MacAddress & vm_mac() const
void CleanupFloatingIpList()
bool AddL3(const Agent *agent, VmInterface *vmi) const
Type type() const
Definition: interface.h:112
bool DeleteL2(const Agent *agent, VmInterface *vmi) const
void GetNextHopInfo()
bool UpdateList(const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op, VmInterfaceState::Op l3_force_op)
VmInterfaceState::Op GetOpL2(const Agent *agent, const VmInterface *vmi) const
uint32_t label() const
Definition: mpls.h:79
bool AddL2(const Agent *agent, VmInterface *vmi) const
uint32_t l2_label_
Definition: interface.h:165
AliasIpList alias_ip_list_
VrfTranslateActionSpec vrf_translate
void Copy(const Agent *agent, const VmInterface *vmi) const
void SetInterfacesDropNewFlows(bool drop_new_flows) const
std::unique_ptr< MetaDataIpState > metadata_ip6_state_
void Insert(const AllowedAddressPair *rhs)
static const uint8_t kMaxV6PrefixLen
Definition: address.h:22
NextHopRef l3_nh_no_policy_
Definition: vm_interface.h:271
static void AddResolveRoute(const Peer *peer, const string &vrf_name, const Ip4Address &ip, const uint8_t plen, const InterfaceKey &intf_key, const uint32_t label, bool policy, const std::string &vn_name, const SecurityGroupList &sg_list, const TagList &tag_list)
static void DeleteVlan(const boost::uuids::uuid &intf_uuid, uint16_t vlan_tag)
Definition: vrf_assign.cc:132
boost::uuids::uuid uuid_
Definition: vm_interface.h:826
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
Definition: vrf.h:86
void Remove(SecurityGroupEntrySet::iterator &it)
static void Delete(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, uint32_t ethernet_tag)
bool etree_leaf() const
const NextHop * l2_interface_nh_policy() const
bool IsLess(const VmiReceiveRoute *rhs) const
static bool GetMacIpActiveState(const VmInterface::LearntMacIp *mac_ip, const VmInterface *vmi)
bool IsLess(const StaticRoute *rhs) const
bool port_map_enabled() const
bool AddL3(const Agent *agent, VmInterface *vmi) const
void SendTrace(const AgentDBTable *table, Trace event) const
void Update(const VrfAssignRule *lhs, const VrfAssignRule *rhs)
virtual bool CmpInterface(const DBEntry &rhs) const
std::vector< AclEntrySpec > acl_entry_specs_
const boost::uuids::uuid & GetUuid() const
Definition: interface.h:113
static const uint32_t kMaxMacIpLimit
Definition: vm_interface.h:365
bool IsVxlanMode() const
NextHopRef l2_nh_policy_
Definition: vm_interface.h:266
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
const uint32_t id() const
Definition: interface.h:123
NextHopTable * nexthop_table() const
Definition: agent.h:475
const VnIpam * GetIpam(const IpAddress &ip) const
Definition: vn.cc:651
DBTableBase * get_table() const
Definition: db_entry.cc:119
void ResetConfigurer(VmInterface::Configurer type)
bool learning_enabled_
bool AddL3(const Agent *agent, VmInterface *vmi) const
bool UpdateList(const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op, VmInterfaceState::Op l3_force_op)
void Remove(InstanceIpSet::iterator &it)
bool AddL2(const Agent *agent, VmInterface *vmi) const
Ip4Address mdata_ip_addr() const
VmInterfaceState::Op GetOpL2(const Agent *agent, const VmInterface *vmi) const
bool dhcp_enabled_
Definition: interface.h:175
void Remove(FatFlowEntrySet::iterator &it)
VmInterface::DeviceType device_type_
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
bool dhcp_enable_config() const
bool AddL3(const Agent *agent, VmInterface *vmi) const
uint32_t table_label() const
Definition: vrf.h:117
VmInterface::DeviceType device_type() const
bool is_l3mh() const
Definition: agent.h:725
void DelLocalVmRoute(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const VmInterface *intf, const IpAddress &ip, uint32_t ethernet_tag)
bool IsDeleted() const
Definition: db_entry.h:49
void Remove(BridgeDomainEntrySet::iterator &it)
AllowedAddressPairList allowed_address_pair_list_
boost::asio::ip::address IpAddress
Definition: address.h:13
static const MacAddress & vrrp_mac()
Definition: agent.h:439
const MacAddress & GetVifMac(const Agent *) const
static const MacAddress kZeroMac
Definition: mac_address.h:149
bool operator()(const VmiReceiveRoute &lhs, const VmiReceiveRoute &rhs) const
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
VmInterfaceState::Op GetOpL2(const Agent *agent, const VmInterface *vmi) const
bool l2_active() const
Definition: interface.h:122
Definition: acl.h:62
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
bool AddL3(const Agent *agent, VmInterface *vmi) const
void DeleteDhcpSnoopEntry(const std::string &ifname)
Definition: interface.cc:727
void Update(const FatFlowEntry *lhs, const FatFlowEntry *rhs)
PortIpcHandler * port_ipc_handler() const
Definition: agent.cc:1005
const Ip4Address & vm_ip_service_addr() const
tbb::atomic< int > flow_count_
std::vector< int > SecurityGroupList
Definition: agent.h:201
Definition: acl.h:69
const NextHop * l3_interface_nh_no_policy() const
virtual ~VrfTableLabelState()
bool l2_active_
Definition: interface.h:173
std::unique_ptr< DBRequestData > data
Definition: db_table.h:49
bool operator()(const FloatingIp &lhs, const FloatingIp &rhs) const
std::string ToString() const
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
void Remove(const LearntMacIp *rhs)
const NextHop * l2_interface_nh_no_policy() const
uint32_t l3_label_
Definition: vm_interface.h:272
Ip4Address ip_
Definition: vm_interface.h:328
void Copy(const Agent *agent, const VmInterface *vmi) const
std::unique_ptr< MetaDataIpState > metadata_ip_state_
const Ip4Address & subnet() const
std::unique_ptr< NextHopState > nexthop_state_
AgentDBEntry * FindActiveEntry(const DBEntry *key)
Definition: agent_db.cc:110
InterfaceTable * interface_table() const
Definition: agent.h:465
bool Enqueue(DBRequest *req)
Definition: db_table.cc:194
boost::uuids::uuid uuid
bool UpdateList(const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op, VmInterfaceState::Op l3_force_op)
static void DeleteMulticastVmInterfaceNH(const boost::uuids::uuid &intf_uuid, const MacAddress &dmac, const std::string &intf_name)
Definition: nexthop.cc:797
static const uint8_t kMaxV4PrefixLen
Definition: address.h:20
bool dhcp_enabled_v6_
Definition: interface.h:176
bool AddL2(const Agent *agent, VmInterface *vmi) const
virtual bool DeleteL3(const Agent *agent, VmInterface *vmi) const
Definition: vm_interface.h:216
virtual ~VmiRouteState()
bool AddL2(const Agent *agent, VmInterface *vmi) const
IFMapNode * ifmap_node() const
Definition: oper_db.h:79
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
const string & GetName() const
Definition: vrf.h:100
const MacAddress & mac() const
Definition: interface.h:131
bool AddL2(const Agent *agent, VmInterface *vmi) const
int32_t GetSrcPortMap(uint8_t protocol, uint16_t src_port) const
void Copy(const Agent *agent, const VmInterface *vmi) const
bool metadata_ip_active_
Definition: interface.h:171
Ip4Address subnet_
Definition: vm_interface.h:309
void DeleteCommon(const VmInterface *vmi) const
IFMapTable * table()
Definition: ifmap_node.h:29
std::vector< ActionSpec > action_l
StaticRouteList static_route_list_
bool metadata_l2_active_
Definition: interface.h:172
bool AddL2(const Agent *agent, VmInterface *vmi) const
bool policy_enabled_
VmInterfaceState::Op GetOpL2(const Agent *agent, const VmInterface *vmi) const
VmInterfaceState::Op GetOp(VmInterfaceState::Op op) const
const Peer * peer() const
IpAddress GetServiceIp(const IpAddress &ip) const
FatFlowPrefixAggregateType prefix_aggregate
Agent * agent() const
Definition: interface.h:447
VrfEntry * vrf() const
Definition: interface.h:115
bool operator()(const AliasIp &lhs, const AliasIp &rhs) const
Ip4Address subnet_
static Ip4Address GetIp4SubnetAddress(const Ip4Address &prefix, uint16_t plen)
Definition: address.cc:179
bool operator()(const VrfAssignRule &lhs, const VrfAssignRule &rhs) const
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
std::unique_ptr< DBRequestKey > KeyPtr
Definition: db_entry.h:25
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
bool AddL3(const Agent *agent, VmInterface *vmi) const
bool AddL3(const Agent *agent, VmInterface *vmi) const
VrfAssignRuleList vrf_assign_rule_list_
VmInterface(const boost::uuids::uuid &uuid, const std::string &name, bool os_oper_state, const boost::uuids::uuid &logical_router_uuid)
Definition: vm_interface.cc:48
std::vector< AclDBEntryConstRef > FirewallPolicyList
Definition: vm_interface.h:107
uint32_t max_flows_
const VrfEntry * vrf_
Definition: vm_interface.h:308
Ip4Address dhcp_addr() const
std::unique_ptr< VrfTableLabelState > vrf_table_label_state_
TagTable * tag_table() const
Definition: agent.h:505
bool learning_enabled() const
int32_t GetDstPortMap(uint8_t protocol, uint16_t dst_port) const
void Copy(const Agent *agent, const VmInterface *vmi) const
void Update(const StaticRoute *lhs, const StaticRoute *rhs)
bool DeleteL2(const Agent *agent, VmInterface *vmi) const
static Ip6Address GetIp6SubnetAddress(const Ip6Address &prefix, uint16_t plen)
Definition: address.cc:200
std::string ToString() const
Definition: mac_address.cc:53
bool AddL2(const Agent *agent, VmInterface *vmi) const
void SetPrefixForAllocUnitIpam(VmInterface *intrface) const
void SetServiceVlanPathPreference(PathPreference *pref, const IpAddress &service_ip) const
bool UpdatePolicySet(const Agent *agent)
void Update(const ServiceVlan *lhs, const ServiceVlan *rhs)
const IpAddress ip_
Definition: vm_interface.h:922
static FatFlowEntry MakeFatFlowEntry(const std::string &protocol, const int &port, const std::string &ignore_addr_str, const std::string &src_prefix_str, const int &src_prefix_mask, const int &src_aggregate_plen, const std::string &dst_prefix_str, const int &dst_prefix_mask, const int &dst_aggregate_plen)
bool UpdateList(const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op, VmInterfaceState::Op l3_force_op)
IFMapNode * UuidToIFNode(const boost::uuids::uuid &u) const
uint32_t label() const
Definition: interface.h:127
void Remove(AliasIpSet::iterator &it)
void Update(const VmiReceiveRoute *lhs, const VmiReceiveRoute *rhs)
const std::string & fabric_vrf_name() const
Definition: agent.h:903
bool AddL2(const Agent *agent, VmInterface *vmi) const
bool ipv6_active_
Definition: interface.h:167
void Copy(const Agent *agent, const VmInterface *vmi) const
bool pbb_interface_
void Insert(const BridgeDomain *rhs)
FirewallPolicyList & fw_policy_list()
Definition: policy_set.h:90
void SetConfigurer(VmInterface::Configurer type)
BridgeDomainList bridge_domain_list_
FatFlowPrefixAggregateType
Definition: vm_interface.h:446
MetaDataIpAllocator * metadata_ip_allocator() const
Definition: agent.cc:949
Ip4Address service_ip_
bool operator()(const LearntMacIp &lhs, const LearntMacIp &rhs) const
VmInterfaceState::Op GetOpL2(const Agent *agent, const VmInterface *vmi) const
bool IsActive() const
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
void print(void) const
BridgeRouteEntry * FindRoute(const MacAddress &mac)
Definition: bridge_route.cc:72
bool AddL3(const Agent *agent, VmInterface *vmi) const
void ApplyConfig(bool old_ipv4_active, bool old_l2_active, bool old_ipv6_active, const Ip4Address &old_subnet, const uint8_t old_subnet_plen)
static void Delete(const Peer *peer, const string &vrf_name, const IpAddress &addr, uint8_t plen)
void Insert(const TagEntry *rhs)
void Insert(const StaticRoute *rhs)
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
void CleanupAliasIpList()
void Update(const TagEntry *lhs, const TagEntry *rhs)
PolicySetTable * policy_set_table() const
Definition: agent.h:520
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
bool OnChange(VmInterfaceData *data)
void Insert(const LearntMacIp *rhs)
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
bool IsLess(const SecurityGroupEntry *rhs) const
uint8_t type
Definition: load_balance.h:109
KeyPtr GetDBRequestKey() const
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
void Remove(TagEntrySet::iterator &it)
NextHopRef l3_mcast_nh_no_policy_
Definition: vm_interface.h:274
bool IsConfigurerSet(VmInterface::Configurer type)
const UpdateFloatingIpFn & update_floatingip_cb() const
Definition: interface.cc:634
uint32_t l2_label_
Definition: vm_interface.h:268
VmiReceiveRouteList receive_route_list_
Definition: agent.h:358
uint32_t label_
Definition: interface.h:164
std::string vrf_name_
Definition: interface.h:265
static void CreateMulticastVmInterfaceNH(const boost::uuids::uuid &intf_uuid, const MacAddress &dmac, const string &vrf_name, const string &intf_name)
Definition: nexthop.cc:788
virtual bool OnResync(const InterfaceTable *table, VmInterface *vmi, bool *force_update) const =0
std::unique_ptr< MacVmBindingState > mac_vm_binding_state_
static void Create(NextHopTable *table, const Interface *intf, bool policy)
Definition: nexthop.cc:1530
Definition: vrf.h:22
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
bool need_linklocal_ip() const
uint32_t label_op() const
bool ipv4_active() const
Definition: interface.h:116
uint32_t GetAllocUnitFromIpam(const IpAddress &ip) const
Definition: vn.cc:676
BridgeDomainTable * bridge_domain_table() const
Definition: agent.cc:941
VnEntryRef vn_
MetaDataIpMap metadata_ip_map_
NextHopConstRef flow_key_nh_
Definition: interface.h:185
bool Populate(const autogen::MatchConditionType *match_condition)
Ip4Address vm_ip_service_addr_
boost::asio::ip::address_v6 Ip6Address
Definition: address.h:15
uint32_t PortMappingSize() const
Ip4Address service_ip()
bool operator()(const StaticRoute &lhs, const StaticRoute &rhs) const
bool UpdateState(const VmInterfaceState *attr, VmInterfaceState::Op l2_force_op, VmInterfaceState::Op l3_force_op)
VnEntry * FindVnRef(const boost::uuids::uuid &uuid) const
Definition: interface.cc:306
std::map< std::string, FatFlowIgnoreAddressType > IgnoreAddressMap
bool metadata_ip_active() const
Definition: interface.h:119
std::string vrf_name_
bool ResetVrfDelete()
Definition: vrf.cc:465
ServiceVlanList service_vlan_list_
std::unique_ptr< ResolveRouteState > resolve_route_state_
std::unique_ptr< DBRequestKey > key
Definition: db_table.h:48
bool IsMaxMacIpLearnt() const
void Update(const BridgeDomain *lhs, const BridgeDomain *rhs)
friend struct VmInterfaceNewFlowDropData
DBOperation oper
Definition: db_table.h:42
bool layer3_forwarding() const
Type type_
Definition: interface.h:161
virtual bool DeleteL2(const Agent *agent, VmInterface *vmi) const
Definition: vm_interface.h:206
bool IsIpv4Active() const
LearntMacIpList learnt_mac_ip_list_
virtual bool OnDelete(const InterfaceTable *table, VmInterface *entry) const
bool AddL3(const Agent *agent, VmInterface *vmi) const
void Copy(const Agent *agent, const VmInterface *vmi) const
bool IsLess(const TagEntry *rhs) const
bool UpdateList(const Agent *agent, VmInterface *vmi)
bool DeleteState(VmInterfaceState *attr)
bool bridging() const
bool AddL3(const Agent *agent, VmInterface *vmi) const
void DeleteRoute(const std::string &vrf_name, const IpAddress &ip, uint32_t plen)
AgentRouteTable * GetBridgeRouteTable() const
Definition: vrf.cc:334
uint8_t subnet_plen_
const Peer * local_peer() const
Definition: agent.h:1022
void AddCommon(const Agent *agent, const VmInterface *vmi) const
Definition: sg.h:35
const VrfEntry * vrf_
Definition: vm_interface.h:235
VrfEntry * FindVrfRef(const std::string &name) const
Definition: interface.cc:295
virtual ~VmInterface()
void Update(const AllowedAddressPair *lhs, const AllowedAddressPair *rhs)
HealthCheckInstanceSet hc_instance_set_
void CreateTableLabel(bool learning_enabled, bool l2, bool flod_unknown_unicast, bool layer2_control_word)
Definition: vrf.cc:118
FirewallPolicyList fwaas_fw_policy_list_
void Remove(VrfAssignRuleSet::iterator &it)
const VnEntry * vn() const
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
void Update(const InstanceIp *lhs, const InstanceIp *rhs)
bool policy_enabled() const
std::vector< std::string > CommunityList
Definition: bgp_config.h:347
void update_flow_count(int val) const
std::unique_ptr< MetaDataIp > mdata_ip_
Definition: vm_interface.h:290
std::vector< Ip4Address > AddressList
Definition: agent.h:217
Ip6Address mdata_ip6_addr() const
AgentDBEntry * Find(const DBEntry *key, bool ret_del)
Definition: agent_db.cc:134
FatFlowList fat_flow_list_
bool del_pending() const
Definition: vm_interface.h:476
virtual void Process(DBRequest &req)
Definition: agent_db.cc:231
void Remove(VmiReceiveRouteSet::iterator &it)
Definition: peer.h:44
FatFlowIgnoreAddressType ignore_address
void set_del_pending(bool val) const
Definition: vm_interface.h:477
void AddRoute(const std::string &vrf_name, const IpAddress &ip, uint32_t plen, const std::string &vn_name, bool force_policy, bool ecmp, bool is_local, bool proxy_arp, const IpAddress &service_ip, const IpAddress &dependent_ip, const CommunityList &communties, uint32_t label, const string &intf_route_type, bool is_learnt_route=false)
std::set< std::string > VnListType
Definition: agent.h:212
void decr_active_vmi_count()
Definition: interface.h:460
bool AddL3(const Agent *agent, VmInterface *vmi) const
bool PolicyEnabled() const
bool IsLess(const ServiceVlan *rhs) const
void UpdateInterfaceHealthCheckService()
uint8_t configurer_
TagEntryList tag_list_
void Remove(ServiceVlanSet::iterator &it)
bool DeleteL2(const Agent *agent, VmInterface *vmi) const
void Insert(const VrfAssignRule *rhs)
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
TrafficAction::Action simple_action
bool ipv4_active_
Definition: interface.h:166
static const uint32_t kInvalidLabel
Definition: mpls.h:101
std::map< PortMapKey, uint16_t, PortMapKey > PortMap
Definition: vm_interface.h:509
VrfTable * vrf_table() const
Definition: agent.h:485
void Delete()
Definition: db_entry.cc:131
VmInterfaceState::Op GetOpL2(const Agent *agent, const VmInterface *vmi) const
void PostAdd()
const Ip4Address & primary_ip_addr() const
bool DeleteL2(const Agent *agent, VmInterface *vmi) const
void incr_active_vmi_count()
Definition: interface.h:459
void set_ignore_acl(bool ignore_acl)
FirewallPolicyList fw_policy_list_
MacAddress vm_mac_
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
const std::string & vrf_name() const
PortMap::iterator PortMapIterator
Definition: vm_interface.h:510
uint32_t ethernet_tag_
Definition: vm_interface.h:329
static void DeleteL2InterfaceNH(const boost::uuids::uuid &intf_uuid, const MacAddress &mac, const std::string &intf_name)
Definition: nexthop.cc:781
void Copy(const Agent *agent, const VmInterface *vmi) const
Definition: mpls.h:99
static const char * kInterfaceStatic
Definition: vm_interface.h:370
bool dhcp_enable_v6_
bool Resync(const InterfaceTable *table, const VmInterfaceData *data)
PolicySet * global_policy_set() const
Definition: policy_set.h:140
bool drop_new_flows_vmi_
virtual ~MacVmBindingState()
bool IsLess(const VrfAssignRule *rhs) const
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
bool operator()(const AllowedAddressPair &lhs, const AllowedAddressPair &rhs) const
void Remove(StaticRouteSet::iterator &it)
const Peer * mac_vm_binding_peer() const
Definition: agent.h:1034
static const char * kInterface
Definition: vm_interface.h:368
void Update(const AliasIp *lhs, const AliasIp *rhs)
VmInterface::VmiType vmi_type() const
AclEntryID id
autogen::MatchConditionType match_condition_
Definition: vm_interface.h:862
InstanceIpList instance_ipv4_list_
bool IsLess(const AliasIp *rhs) const
virtual bool AddL3(const Agent *agent, VmInterface *vmi) const
Definition: vm_interface.h:211
const Ip6Address & primary_ip6_addr() const
virtual bool AddL2(const Agent *agent, VmInterface *vmi) const
Definition: vm_interface.h:201
bool IsMetaDataIPActive() const
static IgnoreAddressMap fatflow_ignore_addr_map_
bool AddL3(const Agent *agent, VmInterface *vmi) const
static void CreateL2VmInterfaceNH(const boost::uuids::uuid &intf_uuid, const MacAddress &dmac, const string &vrf_name, bool learning_enabled, bool etree_leaf, bool layer2_control_word, const std::string &intf_name)
Definition: nexthop.cc:768
void DeleteMacVmBindingRoute(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const VmInterface *vm_intf)
bool operator==(const TagEntry &rhs) const
virtual ~MetaDataIpState()
const VrfEntry * vrf_
Definition: vm_interface.h:327
uint32_t l2_label() const
Definition: interface.h:128
uint32_t max_flows() const
const uint8_t subnet_plen() const
static bool GetInstanceIpActiveState(const VmInterface::InstanceIp *instance_ip, const VmInterface *vmi)
#define LOCAL_VM_PORT_PEER_NAME
Definition: peer.h:18
static void AddGatewayRoute(const Peer *peer, const string &vrf_name, const Ip4Address &dst_addr, uint8_t plen, const AddressList &gw_list, const VnListType &vn_name, uint32_t label, const SecurityGroupList &sg_list, const TagList &tag_list, const CommunityList &communities, bool native_encap)
FloatingIpList floating_ip_list_
InstanceIpList instance_ipv6_list_
std::unique_ptr< VmiRouteState > interface_route_state_
static void AddBridgeReceiveRoute(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const std::string &vn_name, const std::string &interface, bool policy)
bool IsLess(const FloatingIp *rhs) const
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
virtual KeyPtr GetDBRequestKey() const
Definition: ifmap_node.cc:121
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
Agent * agent() const
virtual Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
Definition: vm_interface.h:192
#define LOG(_Level, _Msg)
Definition: logging.h:33
VrfEntryRef vrf_
Definition: interface.h:163
uint32_t ethernet_tag() const
bool layer2_control_word() const
void AddL2InterfaceRoute(const IpAddress &ip, const MacAddress &mac, const IpAddress &dependent_ip) const
SgTable * sg_table() const
Definition: agent.h:500
AgentRouteTable * GetRouteTable(uint8_t table_type) const
Definition: vrf.cc:285
virtual bool Update(const Agent *agent, VmInterface *vmi, Op l2_force_op, Op l3_force_op) const
static void AddVlanNHRoute(const Peer *peer, const string &vm_vrf, const IpAddress &addr, uint8_t plen, const boost::uuids::uuid &intf_uuid, uint16_t tag, uint32_t label, const VnListType &dest_vn_list, const SecurityGroupList &sg_list_, const TagList &tag_list, const PathPreference &path_preference)
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
void Insert(const VmiReceiveRoute *rhs)
static void CreateL3VmInterfaceNH(const boost::uuids::uuid &intf_uuid, const MacAddress &dmac, const string &vrf_name, bool learning_enabled, const std::string &intf_name)
Definition: nexthop.cc:750
virtual void Copy(const Agent *agent, const VmInterface *vmi) const
Definition: vm_interface.h:197
const std::string & name() const
Definition: interface.h:114
void Insert(const FloatingIp *rhs)
const Peer * local_vm_peer() const
Definition: agent.h:1023
void Copy(const Agent *agent, const VmInterface *vmi) const
VmInterfaceState::Op GetOpL2(const Agent *agent, const VmInterface *vmi) const
VmInterfaceState::Op GetOpL3(const Agent *agent, const VmInterface *vmi) const
bool IsMetaDataL2Active() const
bool do_dhcp_relay() const
static const int kDropNewFlowsRecoveryThreshold
Definition: agent.h:398
MetaDataIpState(bool ipv4=true)
Creates a new instance of MetaDataIpState.
NextHopRef l2_nh_no_policy_
Definition: vm_interface.h:267
const string & GetName() const
Definition: vn.h:162
bool DeleteL2(const Agent *agent, VmInterface *vmi) const
VrfEntry * forwarding_vrf() const
static void CreateVlan(const boost::uuids::uuid &intf_uuid, const std::string &vrf_name, uint16_t vlan_tag)
Definition: vrf_assign.cc:116
static bool GetIpActiveState(const IpAddress &ip, const VmInterface *vmi)
static void DeleteL3InterfaceNH(const boost::uuids::uuid &intf_uuid, const MacAddress &mac, const std::string &intf_name)
Definition: nexthop.cc:761
bool DeleteL2(const Agent *agent, VmInterface *vmi) const
static const char * kServiceInterface
Definition: vm_interface.h:369
bool IsLess(const LearntMacIp *rhs) const
bool UpdateList(const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op, VmInterfaceState::Op l3_force_op)
virtual ~NextHopState()
bool UpdateList(const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op, VmInterfaceState::Op l3_force_op)
bool IsL2Active() const
virtual bool UpdateList(const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op, VmInterfaceState::Op l3_force_op)
const std::string & fabric_vn_name() const
Definition: agent.h:901
bool ResetVrfDelete(const InterfaceTable *table, const std::string &vrf_name)
void Update(const FloatingIp *lhs, const FloatingIp *rhs)
virtual Op GetOpL2(const Agent *agent, const VmInterface *vmi) const
Definition: vm_interface.h:185
void Remove(AllowedAddressPairSet::iterator &it)
void Insert(const SecurityGroupEntry *rhs)
void set_delete_on_zero_refcount(bool val)
Definition: nexthop.h:1346
void AddMacVmBindingRoute(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const VmInterface *vm_intf, bool flood_dhcp)
const IpAddress GetFixedIp(const VmInterface *) const
bool dns_enabled_
Definition: interface.h:177
void DeleteL2InterfaceRoute(const VrfEntry *vrf, uint32_t ethernet_tag, const IpAddress &ip, const MacAddress &mac) const
AclTable * acl_table() const
Definition: agent.h:515
void Insert(const AliasIp *rhs)
bool ecmp() const
MetaDataIpAllocator * metadata_ip6_allocator() const
Definition: agent.cc:957
void Insert(const FatFlowEntry *rhs)
CommunityList communities_
Definition: vm_interface.h:699
TrafficAction::TrafficActionType ta_type
void Remove(FloatingIpSet::iterator &it)
bool UpdateList(const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op, VmInterfaceState::Op l3_force_op)
bool UpdateList(const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op, VmInterfaceState::Op l3_force_op)
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
NextHopRef l3_nh_policy_
Definition: vm_interface.h:270
void CopySgIdList(SecurityGroupList *sg_id_list) const
void set_vrf_name(const std::string &vrf_name)
bool IsLess(const AllowedAddressPair *rhs) const
bool operator()(const InstanceIp &lhs, const InstanceIp &rhs) const
bool IsIpv6Active() const
static Op RecomputeOp(Op old_op, Op new_op)
static uint16_t ProtocolStringToInt(const std::string &str)
Definition: agent.cc:1066
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
bool AddL3(const Agent *agent, VmInterface *vmi) const
void Update(const LearntMacIp *lhs, const LearntMacIp *rhs)
bool DeleteL3(const Agent *agent, VmInterface *vmi) const
bool ipv6_active() const
Definition: interface.h:117
Definition: acl.h:92
SecurityGroupEntryList sg_list_
virtual ~ResolveRouteState()
bool is_hc_active() const
Definition: interface.h:118
void UpdateL2()
void Insert(const InstanceIp *rhs)
bool UpdateList(const Agent *agent, VmInterface *vmi, VmInterfaceState::Op l2_force_op, VmInterfaceState::Op l3_force_op)
void Copy(const Agent *agent, const VmInterface *vmi) const
static void Create(const boost::uuids::uuid &intf_uuid, uint16_t vlan_tag, const std::string &vrf_name, const MacAddress &smac, const MacAddress &dmac)
Definition: nexthop.cc:1703
void Copy(const Agent *agent, const VmInterface *vmi) const
bool AddL3(const Agent *agent, VmInterface *vmi) const
size_t id_
Definition: interface.h:174
bool operator()(const ServiceVlan &lhs, const ServiceVlan &rhs) const
bool drop_new_flows() const
bool AddL3(const Agent *agent, VmInterface *vmi) const
void Update(const Agent *agent, VmInterface *vmi) const
const MplsLabel * mpls_label() const
Definition: nexthop.h:434
std::vector< int > TagList
Definition: agent.h:202
bool operator()(const TagEntry &lhs, const TagEntry &rhs) const
void CopyTagIdList(TagList *tag_id_list) const
bool DeleteL3(const Agent *agent, VmInterface *vmi) const