OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
interface_ksync.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include <stdio.h>
6 #include <string.h>
7 
8 #include <net/if.h>
9 
10 #include <boost/asio.hpp>
11 #include <db/db_entry.h>
12 #include <db/db_table.h>
13 #include <db/db_table_partition.h>
14 #include <ksync/ksync_index.h>
15 #include <ksync/ksync_entry.h>
16 #include <ksync/ksync_object.h>
17 #include <ksync/ksync_netlink.h>
18 #include <ksync/ksync_sock.h>
20 #include <init/agent_param.h>
21 #include "vrouter/ksync/agent_ksync_types.h"
22 #include "vr_types.h"
23 #include "base/logging.h"
24 #include "oper/interface_common.h"
25 #include "oper/mirror_table.h"
26 #include "ksync/ksync_index.h"
27 #include "interface_ksync.h"
28 #include "vr_interface.h"
29 #include "vhost.h"
30 #include "pkt/pkt_handler.h"
34 
35 // Name of clone device for creating tap interface
36 #define TUN_INTF_CLONE_DEV "/dev/net/tun"
37 #define SOCK_RETRY_COUNT 4
38 
39 #define VIF_FAT_FLOW_ENCODE_AGGR_PROTO_PORT(prefix_aggr, ignore_addr, protocol, port) \
40  (((prefix_aggr) << 28) | \
41  ((ignore_addr) << 24) | \
42  ((protocol) << 16) | \
43  (port))
44 
46  const InterfaceKSyncEntry *entry,
47  uint32_t index) :
48  KSyncNetlinkDBEntry(index), analyzer_name_(entry->analyzer_name_),
49  drop_new_flows_(entry->drop_new_flows_),
50  dhcp_enable_(entry->dhcp_enable_),
51  dhcp_enable_v6_(entry->dhcp_enable_v6_),
52  fd_(kInvalidIndex),
53  flow_key_nh_id_(entry->flow_key_nh_id_),
54  has_service_vlan_(entry->has_service_vlan_),
55  interface_id_(entry->interface_id_),
56  interface_name_(entry->interface_name_),
57  ip_(entry->ip_), primary_ip6_(entry->primary_ip6_),
58  hc_active_(false), ipv4_active_(false),
59  layer3_forwarding_(entry->layer3_forwarding_),
60  ksync_obj_(obj), l2_active_(false),
61  metadata_l2_active_(entry->metadata_l2_active_),
62  metadata_ip_active_(entry->metadata_ip_active_),
63  bridging_(entry->bridging_),
64  proxy_arp_mode_(VmInterface::PROXY_ARP_NONE),
65  mac_(entry->mac_),
66  smac_(entry->smac_),
67  mirror_direction_(entry->mirror_direction_),
68  network_id_(entry->network_id_),
69  os_index_(Interface::kInvalidIndex),
70  parent_(entry->parent_),
71  policy_enabled_(entry->policy_enabled_),
72  sub_type_(entry->sub_type_),
73  vmi_device_type_(entry->vmi_device_type_),
74  vmi_type_(entry->vmi_type_),
75  hbs_intf_type_(entry->hbs_intf_type_),
76  type_(entry->type_),
77  rx_vlan_id_(entry->rx_vlan_id_),
78  tx_vlan_id_(entry->tx_vlan_id_),
79  vrf_id_(entry->vrf_id_),
80  multicast_vrf_id_(entry->multicast_vrf_id_),
81  persistent_(entry->persistent_),
82  subtype_(entry->subtype_),
83  xconnect_(entry->xconnect_),
84  no_arp_(entry->no_arp_),
85  encap_type_(entry->encap_type_),
86  display_name_(entry->display_name_),
87  transport_(entry->transport_),
88  flood_unknown_unicast_ (entry->flood_unknown_unicast_),
89  qos_config_(entry->qos_config_),
90  learning_enabled_(entry->learning_enabled_),
91  isid_(entry->isid_), pbb_cmac_vrf_(entry->pbb_cmac_vrf_),
92  pbb_mac_(entry->pbb_mac_), etree_leaf_(entry->etree_leaf_),
93  pbb_interface_(entry->pbb_interface_),
94  vhostuser_mode_(entry->vhostuser_mode_),
95  igmp_enable_(entry->igmp_enable_),
96  mac_ip_learning_enable_(false),
97  os_guid_(entry->os_guid_),
98  xconnect_list_(entry->xconnect_list_) {
99 }
100 
102  const Interface *intf) :
103  KSyncNetlinkDBEntry(kInvalidIndex),
104  analyzer_name_(),
105  drop_new_flows_(false),
106  dhcp_enable_(true),
107  dhcp_enable_v6_(false),
108  fd_(-1),
109  flow_key_nh_id_(0),
110  has_service_vlan_(false),
111  interface_id_(intf->id()),
112  interface_name_(intf->name()),
113  ip_(0),
114  hc_active_(false),
115  ipv4_active_(false),
116  layer3_forwarding_(true),
117  ksync_obj_(obj),
118  l2_active_(false),
119  metadata_l2_active_(false),
120  metadata_ip_active_(false),
121  bridging_(true),
122  proxy_arp_mode_(VmInterface::PROXY_ARP_NONE),
123  mac_(),
124  smac_(),
125  mirror_direction_(Interface::UNKNOWN),
126  os_index_(intf->os_index()),
127  parent_(NULL),
128  policy_enabled_(false),
129  sub_type_(InetInterface::VHOST),
130  vmi_device_type_(VmInterface::DEVICE_TYPE_INVALID),
131  vmi_type_(VmInterface::VMI_TYPE_INVALID),
132  hbs_intf_type_(VmInterface::HBS_INTF_INVALID),
133  type_(intf->type()),
134  rx_vlan_id_(VmInterface::kInvalidVlanId),
135  tx_vlan_id_(VmInterface::kInvalidVlanId),
136  vrf_id_(intf->vrf_id()),
137  multicast_vrf_id_(VrfEntry::kInvalidIndex),
138  persistent_(false),
139  subtype_(PhysicalInterface::INVALID),
140  xconnect_(NULL),
141  no_arp_(false),
142  encap_type_(PhysicalInterface::ETHERNET),
143  transport_(Interface::TRANSPORT_INVALID),
144  flood_unknown_unicast_(false), qos_config_(NULL),
145  learning_enabled_(false), isid_(VmInterface::kInvalidIsid),
146  pbb_cmac_vrf_(VrfEntry::kInvalidIndex), pbb_mac_(), etree_leaf_(false),
147  pbb_interface_(false), vhostuser_mode_(VmInterface::vHostUserClient),
148  igmp_enable_(false), mac_ip_learning_enable_(false),
149  os_guid_(intf->os_guid()),
150  xconnect_list_() {
151 
152  if (intf->flow_key_nh()) {
153  flow_key_nh_id_ = intf->flow_key_nh()->id();
154  }
155  network_id_ = 0;
157  const VmInterface *vmitf =
158  static_cast<const VmInterface *>(intf);
159  ip_ = vmitf->primary_ip_addr().to_ulong();
160  primary_ip6_ = vmitf->primary_ip6_addr();
161  network_id_ = vmitf->vxlan_id();
162  rx_vlan_id_ = vmitf->rx_vlan_id();
163  tx_vlan_id_ = vmitf->tx_vlan_id();
164  vhostuser_mode_ = vmitf->vhostuser_mode();
165  if (vmitf->parent()) {
166  InterfaceKSyncEntry tmp(ksync_obj_, vmitf->parent());
168  }
169  vmi_device_type_ = vmitf->device_type();
170  vmi_type_ = vmitf->vmi_type();
171  if (vmi_type_ == VmInterface::VHOST) {
172  for (size_t i = 0; i <vmitf->parent_list().size(); i++) {
173  InterfaceKSyncEntry tmp(ksync_obj_, vmitf->parent_list()[i]);
174  xconnect_list_.push_back(ksync_obj_->GetReference(&tmp));
175  }
176  parent_ = NULL;
177  InterfaceKSyncEntry *xconnect = static_cast<InterfaceKSyncEntry *>
178  (xconnect_list_[0].get());
179  encap_type_ = xconnect->encap_type();
180  no_arp_ = xconnect->no_arp();
181  }
182  hbs_intf_type_ = vmitf->hbs_intf_type();
183  } else if (type_ == Interface::INET) {
184  const InetInterface *inet_intf =
185  static_cast<const InetInterface *>(intf);
186  sub_type_ = inet_intf->sub_type();
187  ip_ = inet_intf->ip_addr().to_ulong();
189  InterfaceKSyncEntry tmp(ksync_obj_, inet_intf->xconnect());
191  InterfaceKSyncEntry *xconnect = static_cast<InterfaceKSyncEntry *>
192  (xconnect_.get());
193  encap_type_ = xconnect->encap_type();
194  no_arp_ = xconnect->no_arp();
195  }
196  } else if (type_ == Interface::PHYSICAL) {
197  const PhysicalInterface *physical_intf =
198  static_cast<const PhysicalInterface *>(intf);
199  encap_type_ = physical_intf->encap_type();
200  no_arp_ = physical_intf->no_arp();
201  display_name_ = physical_intf->display_name();
202  ip_ = physical_intf->ip_addr().to_ulong();
203  }
204 }
205 
207 }
208 
210  return ksync_obj_;
211 }
212 
213 bool InterfaceKSyncEntry::IsLess(const KSyncEntry &rhs) const {
214  const InterfaceKSyncEntry &entry = static_cast
215  <const InterfaceKSyncEntry &>(rhs);
216  if (interface_name_ != entry.interface_name_ ) {
217  return interface_name_ < entry.interface_name_;
218  } else {
219  return interface_id_ < entry.interface_id_;
220  }
221 }
222 
223 std::string InterfaceKSyncEntry::ToString() const {
224  std::stringstream s;
225  s << "Interface : " << interface_name_ << " Index : " << interface_id_;
226  const VrfEntry* vrf =
228  if (vrf) {
229  s << " Vrf : " << vrf->GetName();
230  }
231  return s.str();
232 }
233 
235  Interface *intf = static_cast<Interface *>(e);
236  bool ret = false;
237 
238  if (hc_active_ != intf->is_hc_active()) {
239  hc_active_ = intf->is_hc_active();
240  ret = true;
241  }
242 
243  if (ipv4_active_ != intf->ipv4_active()) {
244  ipv4_active_ = intf->ipv4_active();
245  ret = true;
246  }
247 
248  if (l2_active_ != intf->l2_active()) {
249  l2_active_ = intf->l2_active();
250  ret = true;
251  }
252 
253  if (os_index_ != intf->os_index()) {
254  os_index_ = intf->os_index();
255  ret = true;
256  }
257 
258  if (intf->type() == Interface::VM_INTERFACE) {
259  VmInterface *vm_port = static_cast<VmInterface *>(intf);
260  if (vmi_device_type_ != vm_port->device_type()) {
261  vmi_device_type_ = vm_port->device_type();
262  ret = true;
263  }
264 
265  if (vmi_type_ != vm_port->vmi_type()) {
266  vmi_type_ = vm_port->vmi_type();
267  ret = true;
268  }
269 
270  if (hbs_intf_type_ != vm_port->hbs_intf_type()) {
271  hbs_intf_type_ = vm_port->hbs_intf_type();
272  ret = true;
273  }
274 
275  if (drop_new_flows_ != vm_port->drop_new_flows()) {
276  drop_new_flows_ = vm_port->drop_new_flows();
277  ret = true;
278  }
279 
280  if (dhcp_enable_ != vm_port->dhcp_enabled()) {
281  dhcp_enable_ = vm_port->dhcp_enabled();
282  ret = true;
283  }
284 
285  if (dhcp_enable_v6_ != vm_port->dhcp_enabled_v6()) {
286  dhcp_enable_v6_ = vm_port->dhcp_enabled_v6();
287  ret = true;
288  }
289 
290  if (ip_ != vm_port->primary_ip_addr().to_ulong()) {
291  ip_ = vm_port->primary_ip_addr().to_ulong();
292  ret = true;
293  }
294 
295  if (primary_ip6_ != vm_port->primary_ip6_addr()) {
296  primary_ip6_ = vm_port->primary_ip6_addr();
297  ret = true;
298  }
299 
300  if (layer3_forwarding_ != vm_port->layer3_forwarding()) {
302  ret = true;
303  }
304 
305  if (flood_unknown_unicast_ != vm_port->flood_unknown_unicast()) {
307  ret = true;
308  }
309 
310  if (bridging_ != vm_port->bridging()) {
311  bridging_ = vm_port->bridging();
312  ret = true;
313  }
314 
315  if (proxy_arp_mode_ != vm_port->proxy_arp_mode()) {
316  proxy_arp_mode_ = vm_port->proxy_arp_mode();
317  ret = true;
318  }
319 
320  if (rx_vlan_id_ != vm_port->rx_vlan_id()) {
321  rx_vlan_id_ = vm_port->rx_vlan_id();
322  ret = true;
323  }
324 
325  if (tx_vlan_id_ != vm_port->tx_vlan_id()) {
326  tx_vlan_id_ = vm_port->tx_vlan_id();
327  ret = true;
328  }
329 
330  if (vhostuser_mode_ != vm_port->vhostuser_mode()) {
331  vhostuser_mode_ = vm_port->vhostuser_mode();
332  ret = true;
333  }
334 
335  KSyncEntryPtr parent = NULL;
336  if (vm_port->parent()) {
337  InterfaceKSyncEntry tmp(ksync_obj_, vm_port->parent());
338  parent = ksync_obj_->GetReference(&tmp);
339  }
340 
341  if (parent_ != parent) {
342  parent_ = parent;
343  ret = true;
344  }
345 
346  if (metadata_l2_active_ !=
347  vm_port->metadata_l2_active()) {
349  vm_port->metadata_l2_active();
350  ret = true;
351  }
352 
353  if (metadata_ip_active_ !=
354  vm_port->metadata_ip_active()) {
356  vm_port->metadata_ip_active();
357  ret = true;
358  }
359 
360  if (learning_enabled_ != vm_port->learning_enabled()) {
361  learning_enabled_ = vm_port->learning_enabled();
362  ret = true;
363  }
364 
365  if (pbb_interface_ != vm_port->pbb_interface()) {
366  pbb_interface_ = vm_port->pbb_interface();
367  ret = true;
368  }
369 
370  if (l2_active_ && pbb_interface_ && isid_ != vm_port->GetIsid()) {
371  isid_ = vm_port->GetIsid();
372  ret = true;
373  }
374 
375  if (l2_active_ && pbb_interface_ &&
376  pbb_cmac_vrf_ != vm_port->GetPbbVrf()) {
377  pbb_cmac_vrf_ = vm_port->GetPbbVrf();
378  ret = true;
379  }
380 
381  if (etree_leaf_ != vm_port->etree_leaf()) {
382  etree_leaf_ = vm_port->etree_leaf();
383  ret = true;
384  }
385 
386  if (igmp_enable_ != vm_port->igmp_enabled()) {
387  igmp_enable_ = vm_port->igmp_enabled();
388  ret = true;
389  }
390 
393  ret = true;
394  }
395  }
396 
397  uint32_t vrf_id = VIF_VRF_INVALID;
398  uint32_t multicast_vrf_id = VIF_VRF_INVALID;
399  bool policy_enabled = false;
400  std::string analyzer_name;
402  bool has_service_vlan = false;
404  vrf_id = intf->vrf_id();
405  if (vrf_id == VrfEntry::kInvalidIndex) {
406  vrf_id = VIF_VRF_INVALID;
407  }
408 
409  if (intf->type() == Interface::VM_INTERFACE) {
410  VmInterface *vm_port = static_cast<VmInterface *>(intf);
411  if (vm_port->forwarding_vrf()) {
412  vrf_id = vm_port->forwarding_vrf()->vrf_id();
413  }
414 
415  if (vmi_type_ != VmInterface::VHOST) {
416  multicast_vrf_id = intf->vrf_id();
417  if (pbb_interface_ && l2_active_) {
418  multicast_vrf_id = vm_port->GetPbbVrf();;
419  }
420 
421  if (multicast_vrf_id == VrfEntry::kInvalidIndex) {
422  multicast_vrf_id = VIF_VRF_INVALID;
423  }
424  }
425 
426  has_service_vlan = vm_port->HasServiceVlan();
427  policy_enabled = vm_port->policy_enabled();
428  analyzer_name = vm_port->GetAnalyzer();
429  mirror_direction = vm_port->mirror_direction();
430  if (network_id_ != vm_port->vxlan_id()) {
431  network_id_ = vm_port->vxlan_id();
432  ret = true;
433  }
434  }
435  }
436 
437  if (intf->type() == Interface::INET) {
438  InetInterface *vhost = static_cast<InetInterface *>(intf);
439  sub_type_ = vhost->sub_type();
440 
441  if (ip_ != vhost->ip_addr().to_ulong()) {
442  ip_ = vhost->ip_addr().to_ulong();
443  ret = true;
444  }
445 
446  InetInterface *inet_interface = static_cast<InetInterface *>(intf);
448  KSyncEntryPtr xconnect = NULL;
449  if (!inet_interface->xconnect()) {
450  InterfaceKSyncEntry tmp(ksync_obj_, inet_interface->xconnect());
451  xconnect = ksync_obj_->GetReference(&tmp);
452  }
453  if(xconnect) {
454  if (xconnect_ != xconnect) {
455  xconnect_ = xconnect;
456  ret = true;
457  }
458  }
459  }
460  }
461 
462  KSyncEntryPtr qos_config = NULL;
463  QosConfigKSyncObject *qos_object =
464  static_cast<InterfaceKSyncObject *>(ksync_obj_)->ksync()->
465  qos_config_ksync_obj();
466  if (intf->qos_config() != NULL) {
467  QosConfigKSyncEntry tmp(qos_object, intf->qos_config());
468  qos_config = qos_object->GetReference(&tmp);
469  }
470  if (qos_config != qos_config_) {
471  qos_config_ = qos_config;
472  ret = true;
473  }
474 
475  if (vrf_id != vrf_id_) {
476  vrf_id_ = vrf_id;
477  ret = true;
478  }
479 
480  if (multicast_vrf_id_ != multicast_vrf_id) {
481  multicast_vrf_id_ = multicast_vrf_id;
482  ret = true;
483  }
484 
485  if (policy_enabled_ != policy_enabled) {
486  policy_enabled_ = policy_enabled;
487  ret = true;
488  }
489 
490  if (analyzer_name_ != analyzer_name) {
491  analyzer_name_ = analyzer_name;
492  ret = true;
493  }
494 
495  if (mirror_direction_ != mirror_direction) {
496  mirror_direction_ = mirror_direction;
497  ret = true;
498  }
499 
500  if (has_service_vlan_ != has_service_vlan) {
502  ret = true;
503  }
504 
505  InterfaceTable *table = static_cast<InterfaceTable *>(intf->get_table());
506  MacAddress dmac;
507 
508  switch (intf->type()) {
510  {
511  const VmInterface *vm_intf = static_cast<const VmInterface *>(intf);
512  if (fat_flow_list_.list_ != vm_intf->fat_flow_list().list_) {
513  fat_flow_list_ = vm_intf->fat_flow_list();
514  ret = true;
515  }
517  std::set<MacAddress> aap_mac_list;
518  for (VmInterface::AllowedAddressPairSet::iterator aap_it =
519  vm_intf->allowed_address_pair_list().list_.begin();
520  aap_it != vm_intf->allowed_address_pair_list().list_.end();
521  ++aap_it) {
522  aap_mac_list.insert(aap_it->mac_);
523  }
524  if (aap_mac_list_ != aap_mac_list) {
525  aap_mac_list_.swap(aap_mac_list);
526  ret = true;
527  }
529  if (pbb_interface_) {
530  pbb_mac = MacAddress(vm_intf->vm_mac());
531  }
532  if (pbb_mac != pbb_mac_) {
533  pbb_mac_ = pbb_mac;
534  ret = true;
535  }
536  }
537  case Interface::PACKET:
538  dmac = table->agent()->vrrp_mac();
539  break;
540 
541  case Interface::PHYSICAL:
542  {
543  dmac = intf->mac();
544  PhysicalInterface *phy_intf = static_cast<PhysicalInterface *>(intf);
545  persistent_ = phy_intf->persistent();
546  subtype_ = phy_intf->subtype();
547  break;
548  }
549  case Interface::INET: {
550  dmac = intf->mac();
551 
552  bool no_arp = false;
554  InterfaceKSyncEntry *xconnect = static_cast<InterfaceKSyncEntry *>
555  (xconnect_.get());
556  if (xconnect) {
557  no_arp = xconnect->no_arp();
558  encap = xconnect->encap_type();
559  }
560 
561  if (no_arp_ != no_arp) {
562  no_arp_ = no_arp;
563  ret = true;
564  }
565  if (encap_type_ != encap) {
566  encap_type_ = encap;
567  ret = true;
568  }
569 
570  break;
571  }
572 
573  case Interface::LOGICAL:
575  dmac = intf->mac();
576  break;
577 
578  default:
579  assert(0);
580  }
581 
582  if (dmac != mac()) {
583  mac_ = dmac;
584  ret = true;
585  }
586 
587  // In VMWare VCenter mode, interface is assigned using the SMAC
588  // in packet. Store the SMAC for interface
590  if (intf->type() == Interface::VM_INTERFACE &&
594  const VmInterface *vm_intf = static_cast<const VmInterface *>(intf);
595  smac = MacAddress(vm_intf->vm_mac());
596  }
597 
598  if (smac != smac_) {
599  smac_ = smac;
600  ret = true;
601  }
602 
603  //Nexthop index gets used in flow key, vrouter just treats
604  //it as an index and doesnt cross check against existence of nexthop,
605  //hence there is no need to make sure that nexthop is programmed
606  //before flow key nexthop index is set in interface
607  //Nexthop index 0 if set in interface is treated as invalid index,
608  //and packet would be dropped if such a packet needs to go thru
609  //flow lookup
610  uint32_t nh_id = 0;
611  if (intf->flow_key_nh()) {
612  nh_id = intf->flow_key_nh()->id();
613  }
614  if (nh_id != flow_key_nh_id_) {
615  flow_key_nh_id_ = nh_id;
616  ret = true;
617  }
618 
619  if (transport_ != intf->transport()) {
620  transport_ = intf->transport();
621  ret = true;
622  }
623 
624  if (os_guid_ != intf->os_guid()) {
625  os_guid_ = intf->os_guid();
626  ret = true;
627  }
628 
629  return ret;
630 }
631 
633  if (qos_config_.get() && qos_config_->IsResolved() == false) {
634  return qos_config_.get();
635  }
636 
638  if (xconnect_.get() && !xconnect_->IsResolved()) {
639  return xconnect_.get();
640  }
641  }
642 
644  return NULL;
645  }
646 
647  if (parent_.get() && !parent_->IsResolved()) {
648  return parent_.get();
649  }
650 
651  if (!analyzer_name_.empty()) {
652  MirrorKSyncObject *mirror_object =
654  MirrorKSyncEntry mksync1(mirror_object, analyzer_name_);
655  MirrorKSyncEntry *mirror =
656  static_cast<MirrorKSyncEntry *>(mirror_object->GetReference(&mksync1));
657  if (mirror && !mirror->IsResolved() &&
659  return mirror;
660  }
661  }
662  return NULL;
663 }
664 
665 bool IsValidOsIndex(size_t os_index, Interface::Type type, uint16_t vlan_id,
666  VmInterface::VmiType vmi_type, Interface::Transport transport) {
667  if (transport != Interface::TRANSPORT_ETHERNET) {
668  return true;
669  }
670 
671  if (os_index != Interface::kInvalidIndex)
672  return true;
673 
674  if (type == Interface::VM_INTERFACE &&
675  vlan_id != VmInterface::kInvalidVlanId) {
676  return true;
677  }
678 
679  if (vmi_type == VmInterface::GATEWAY ||
680  vmi_type == VmInterface::REMOTE_VM) {
681  return true;
682  }
683 
684  return false;
685 }
686 
687 int InterfaceKSyncEntry::Encode(sandesh_op::type op, char *buf, int buf_len) {
688  vr_interface_req encoder;
689  int encode_len;
690  uint32_t vrf_id = vrf_id_;
691  std::vector<int32_t> cross_connect_idx_list;
692 
693  uint32_t flags = 0;
694  encoder.set_h_op(op);
695  if (op == sandesh_op::DEL) {
696  encoder.set_vifr_idx(interface_id_);
697  int error = 0;
698  encode_len = encoder.WriteBinary((uint8_t *)buf, buf_len, &error);
699  assert(error == 0);
700  assert(encode_len <= buf_len);
701  return encode_len;
702  }
703 
704  if (qos_config_.get() != NULL) {
705  QosConfigKSyncEntry *qos_config =
706  static_cast<QosConfigKSyncEntry *>(qos_config_.get());
707  encoder.set_vifr_qos_map_index(qos_config->id());
708  } else {
709  encoder.set_vifr_qos_map_index(-1);
710  }
711 
712  if (etree_leaf_ == false) {
713  flags |= VIF_FLAG_ETREE_ROOT;
714  }
715 
716  switch (type_) {
719  return 0;
720  if (drop_new_flows_) {
721  flags |= VIF_FLAG_DROP_NEW_FLOWS;
722  }
723  if (dhcp_enable_ || dhcp_enable_v6_) {
724  flags |= VIF_FLAG_DHCP_ENABLED;
725  }
726  if (bridging_) {
727  flags |= VIF_FLAG_L2_ENABLED;
728  }
730  flags |= VIF_FLAG_NO_ARP_PROXY;
731  }
734  VIF_FLAG_HBS_RIGHT:VIF_FLAG_HBS_LEFT;
735  }
737  flags |= VIF_FLAG_UNKNOWN_UC_FLOOD;
738  }
739  if (learning_enabled_) {
740  flags |= VIF_FLAG_MAC_LEARN;
741  }
743  flags |= VIF_FLAG_MAC_PROXY;
744  }
745  if (igmp_enable_) {
746  flags |= VIF_FLAG_IGMP_ENABLED;
747  }
749  flags |= VIF_FLAG_MAC_IP_LEARNING;
750  }
751  MacAddress mac;
752  if (parent_.get() != NULL) {
753  encoder.set_vifr_type(VIF_TYPE_VIRTUAL_VLAN);
757  //By default in case of gateway, untagged packet
758  //would be considered as belonging to interface
759  //at tag 0
760  encoder.set_vifr_vlan_id(0);
761  encoder.set_vifr_ovlan_id(0);
762  } else {
763  encoder.set_vifr_vlan_id(rx_vlan_id_);
764  encoder.set_vifr_ovlan_id(tx_vlan_id_);
765  }
766  InterfaceKSyncEntry *parent =
767  (static_cast<InterfaceKSyncEntry *> (parent_.get()));
768  encoder.set_vifr_parent_vif_idx(parent->interface_id());
769  mac = parent->mac();
770  } else {
771  mac = ksync_obj_->ksync()->agent()->vrrp_mac();
772  encoder.set_vifr_type(VIF_TYPE_VIRTUAL);
773  }
774 
775  if (vmi_type_ == VmInterface::VHOST) {
776  encoder.set_vifr_type(VIF_TYPE_HOST);
777  encoder.set_vifr_loopback_ip(ksync_obj_->ksync()->agent()->loopback_ip().to_ulong());
778  if (xconnect_list_.empty() == false) {
779  for (size_t i = 0; i < xconnect_list_.size(); i++) {
780  InterfaceKSyncEntry *xconnect =
781  static_cast<InterfaceKSyncEntry *>(xconnect_list_[i].get());
782  cross_connect_idx_list.push_back(xconnect->os_index_);
783  }
784  } else {
785  cross_connect_idx_list.push_back(Interface::kInvalidIndex);
786  }
787  encoder.set_vifr_cross_connect_idx(cross_connect_idx_list);
788  }
789 
790  std::vector<int8_t> intf_mac((int8_t *)mac,
791  (int8_t *)mac + mac.size());
792  encoder.set_vifr_mac(intf_mac);
793 
794  if (ksync_obj_->ksync()->agent()->isVmwareVcenterMode() ||
798  std::vector<int8_t> mac;
799  mac.insert(mac.begin(), (const int8_t *)smac(),
800  (const int8_t *)smac() + smac().size());
801  for (std::set<MacAddress>::iterator it = aap_mac_list_.begin();
802  it != aap_mac_list_.end(); ++it) {
803  mac.insert(mac.end(), (const int8_t *)(*it),
804  (const int8_t *)(*it) + (*it).size());
805  }
806  encoder.set_vifr_src_mac(mac);
807  flags |= VIF_FLAG_MIRROR_NOTAG;
808  }
809 
810  // Disable fat-flow when health-check status is inactive
811  // If fat-flow is active, then following problem happens,
812  // 1. Health Check Request from vhost0 interface creates a flow
813  // 2. Health Check response is received from VMI with fat-flow
814  // - Response creates new flow due to fat-flow configuration
815  // - If health-check status is inactive routes for interface are
816  // withdrawn
817  // - Flow created from response fails due to missing routes
818  // If fat-flow is disabled, the reverse packet hits flow created (1)
819  // and succeeds
820  if (hc_active_ && fat_flow_list_.list_.size() != 0) {
821  std::vector<int32_t> fat_flow_protocol_port_list;
822  std::vector<uint64_t> fat_flow_src_prefix_h_list;
823  std::vector<uint64_t> fat_flow_src_prefix_l_list;
824  std::vector<int8_t> fat_flow_src_prefix_mask_list;
825  std::vector<int8_t> fat_flow_src_aggregate_plen_list;
826  std::vector<uint64_t> fat_flow_dst_prefix_h_list;
827  std::vector<uint64_t> fat_flow_dst_prefix_l_list;
828  std::vector<int8_t> fat_flow_dst_prefix_mask_list;
829  std::vector<int8_t> fat_flow_dst_aggregate_plen_list;
830  uint64_t tmp_ip6[2];
831 
832  for (VmInterface::FatFlowEntrySet::const_iterator it =
833  fat_flow_list_.list_.begin();
834  it != fat_flow_list_.list_.end(); it++) {
835  if (it->prefix_aggregate == VmInterface::AGGREGATE_NONE) {
836  fat_flow_protocol_port_list.push_back(
837  VIF_FAT_FLOW_ENCODE_AGGR_PROTO_PORT(it->prefix_aggregate,
838  it->ignore_address,
839  it->protocol,
840  it->port));
841  fat_flow_src_prefix_l_list.push_back(0);
842  fat_flow_src_prefix_h_list.push_back(0);
843  fat_flow_src_prefix_mask_list.push_back(0);
844  fat_flow_src_aggregate_plen_list.push_back(0);
845  fat_flow_dst_prefix_l_list.push_back(0);
846  fat_flow_dst_prefix_h_list.push_back(0);
847  fat_flow_dst_prefix_mask_list.push_back(0);
848  fat_flow_dst_aggregate_plen_list.push_back(0);
849  } else if ((it->prefix_aggregate ==
851  (it->prefix_aggregate ==
853  (it->prefix_aggregate ==
855  fat_flow_protocol_port_list.push_back(
856  VIF_FAT_FLOW_ENCODE_AGGR_PROTO_PORT(it->prefix_aggregate,
857  it->ignore_address,
858  it->protocol,
859  it->port));
860  fat_flow_src_prefix_l_list.push_back(
861  (uint64_t) htonl(it->src_prefix.to_v4().to_ulong()));
862  fat_flow_src_prefix_h_list.push_back(0);
863  fat_flow_src_prefix_mask_list.push_back(it->src_prefix_mask);
864  fat_flow_src_aggregate_plen_list.push_back(it->src_aggregate_plen);
865  fat_flow_dst_prefix_l_list.push_back(
866  (uint64_t) htonl(it->dst_prefix.to_v4().to_ulong()));
867  fat_flow_dst_prefix_h_list.push_back(0);
868  fat_flow_dst_prefix_mask_list.push_back(it->dst_prefix_mask);
869  fat_flow_dst_aggregate_plen_list.push_back(it->dst_aggregate_plen);
870  } else {
871  fat_flow_protocol_port_list.push_back(
872  VIF_FAT_FLOW_ENCODE_AGGR_PROTO_PORT(it->prefix_aggregate,
873  it->ignore_address,
874  it->protocol,
875  it->port));
876  if (it->prefix_aggregate == VmInterface::AGGREGATE_DST_IPV6) {
877  // src prefix is not valid
878  fat_flow_src_prefix_h_list.push_back(0);
879  fat_flow_src_prefix_l_list.push_back(0);
880  fat_flow_src_prefix_mask_list.push_back(0);
881  fat_flow_src_aggregate_plen_list.push_back(0);
882  } else {
883  Ip6AddressToU64Array(it->src_prefix.to_v6(), tmp_ip6, 2);
884  fat_flow_src_prefix_h_list.push_back(tmp_ip6[0]);
885  fat_flow_src_prefix_l_list.push_back(tmp_ip6[1]);
886  fat_flow_src_prefix_mask_list.push_back(
887  it->src_prefix_mask);
888  fat_flow_src_aggregate_plen_list.push_back(
889  it->src_aggregate_plen);
890  }
891  if (it->prefix_aggregate == VmInterface::AGGREGATE_SRC_IPV6) {
892  // dst prefix is not valid
893  fat_flow_dst_prefix_h_list.push_back(0);
894  fat_flow_dst_prefix_l_list.push_back(0);
895  fat_flow_dst_prefix_mask_list.push_back(0);
896  fat_flow_dst_aggregate_plen_list.push_back(0);
897  } else {
898  Ip6AddressToU64Array(it->dst_prefix.to_v6(), tmp_ip6, 2);
899  fat_flow_dst_prefix_h_list.push_back(tmp_ip6[0]);
900  fat_flow_dst_prefix_l_list.push_back(tmp_ip6[1]);
901  fat_flow_dst_prefix_mask_list.push_back(it->dst_prefix_mask);
902  fat_flow_dst_aggregate_plen_list.push_back(
903  it->dst_aggregate_plen);
904  }
905  }
906  }
907  encoder.set_vifr_fat_flow_protocol_port(
908  fat_flow_protocol_port_list);
909  encoder.set_vifr_fat_flow_src_prefix_h(
910  fat_flow_src_prefix_h_list);
911  encoder.set_vifr_fat_flow_src_prefix_l(
912  fat_flow_src_prefix_l_list);
913  encoder.set_vifr_fat_flow_src_prefix_mask(
914  fat_flow_src_prefix_mask_list);
915  encoder.set_vifr_fat_flow_src_aggregate_plen(
916  fat_flow_src_aggregate_plen_list);
917  encoder.set_vifr_fat_flow_dst_prefix_h(
918  fat_flow_dst_prefix_h_list);
919  encoder.set_vifr_fat_flow_dst_prefix_l(
920  fat_flow_dst_prefix_l_list);
921  encoder.set_vifr_fat_flow_dst_prefix_mask(
922  fat_flow_dst_prefix_mask_list);
923  encoder.set_vifr_fat_flow_dst_aggregate_plen(
924  fat_flow_dst_aggregate_plen_list);
925 
926  encoder.set_vifr_fat_flow_exclude_ip_list
928  encoder.set_vifr_fat_flow_exclude_ip6_u_list
930  encoder.set_vifr_fat_flow_exclude_ip6_l_list
932  encoder.set_vifr_fat_flow_exclude_ip6_plen_list
934  }
935 
936  if (pbb_interface_) {
937  std::vector<int8_t> pbb_mac((int8_t *)pbb_mac_,
938  (int8_t *)pbb_mac_ + mac.size());
939  encoder.set_vifr_pbb_mac(pbb_mac);
940  encoder.set_vifr_isid(isid_);
942  vrf_id = pbb_cmac_vrf_;
943  }
944  }
945 
946  if (!primary_ip6_.is_unspecified()) {
947  uint64_t data[2];
949  encoder.set_vifr_ip6_u(data[0]);
950  encoder.set_vifr_ip6_l(data[1]);
951  }
952  encoder.set_vifr_vhostuser_mode(vhostuser_mode_);
953  break;
954  }
955 
956  case Interface::PHYSICAL: {
957  encoder.set_vifr_type(VIF_TYPE_PHYSICAL);
958  flags |= VIF_FLAG_L3_ENABLED;
959  flags |= VIF_FLAG_L2_ENABLED;
960  if (!persistent_) {
961  flags |= VIF_FLAG_VHOST_PHYS;
962  }
963 
967  flags |= VIF_FLAG_PROMISCOUS;
968  }
970  flags |= VIF_FLAG_NATIVE_VLAN_TAG;
971  flags |= VIF_FLAG_FAB_GW_MODE;
972  }
973  encoder.set_vifr_name(display_name_);
974 
975  AgentParam *params = ksync_obj_->ksync()->agent()->params();
976  std::vector<int16_t> nic_queue_list;
977  for (std::set<uint16_t>::const_iterator it =
978  params->nic_queue_list().begin();
979  it != params->nic_queue_list().end(); it++) {
980  nic_queue_list.push_back(*it);
981  }
982  encoder.set_vifr_hw_queues(nic_queue_list);
983  break;
984  }
985 
986  case Interface::INET: {
987  switch (sub_type_) {
989  encoder.set_vifr_type(VIF_TYPE_GATEWAY);
990  break;
992  encoder.set_vifr_type(VIF_TYPE_XEN_LL_HOST);
993  break;
995  encoder.set_vifr_type(VIF_TYPE_HOST);
996  encoder.set_vifr_loopback_ip(ksync_obj_->ksync()->agent()->loopback_ip().to_ulong());
997  if (xconnect_.get()) {
998  InterfaceKSyncEntry *xconnect =
999  static_cast<InterfaceKSyncEntry *>(xconnect_.get());
1000  cross_connect_idx_list.push_back(xconnect->os_index_);
1001  } else {
1002  cross_connect_idx_list.push_back(Interface::kInvalidIndex);
1003  }
1004  encoder.set_vifr_cross_connect_idx(cross_connect_idx_list);
1005  break;
1006  default:
1007  encoder.set_vifr_type(VIF_TYPE_HOST);
1008  break;
1009  }
1010  flags |= VIF_FLAG_L3_ENABLED;
1011  flags |= VIF_FLAG_L2_ENABLED;
1012  break;
1013  }
1014 
1015  case Interface::PACKET: {
1016  encoder.set_vifr_type(VIF_TYPE_AGENT);
1017  flags |= VIF_FLAG_L3_ENABLED;
1018  break;
1019  }
1020  default:
1021  assert(0);
1022  }
1023 
1024  if (layer3_forwarding_) {
1025  flags |= VIF_FLAG_L3_ENABLED;
1026  if (policy_enabled_) {
1027  flags |= VIF_FLAG_POLICY_ENABLED;
1028  }
1030  if (!analyzer_name_.empty()) {
1031  uint16_t idx = obj->GetIdx(analyzer_name_);
1033  flags |= VIF_FLAG_MIRROR_TX;
1034  } else if (Interface::MIRROR_RX == mirror_direction_) {
1035  flags |= VIF_FLAG_MIRROR_RX;
1036  } else {
1037  flags |= VIF_FLAG_MIRROR_RX;
1038  flags |= VIF_FLAG_MIRROR_TX;
1039  }
1040  encoder.set_vifr_mir_id(idx);
1041 
1042  const VrfEntry* vrf =
1044  if (vrf && vrf->vn()) {
1045  const std::string &vn_name = vrf->vn()->GetName() ;
1046  // TLV for RX Mirror
1047  std::vector<int8_t> srcdata;
1048  srcdata.push_back(FlowEntry::PCAP_SOURCE_VN);
1049  srcdata.push_back(vn_name.size());
1050  srcdata.insert(srcdata.end(), vn_name.begin(),
1051  vn_name.end());
1052  srcdata.push_back(FlowEntry::PCAP_TLV_END);
1053  srcdata.push_back(0x0);
1054  encoder.set_vifr_in_mirror_md(srcdata);
1055  // TLV for TX Mirror
1056  std::vector<int8_t> destdata;
1057  destdata.push_back(FlowEntry::PCAP_DEST_VN);
1058  destdata.push_back(vn_name.size());
1059  destdata.insert(destdata.end(), vn_name.begin(),
1060  vn_name.end());
1061  destdata.push_back(FlowEntry::PCAP_TLV_END);
1062  destdata.push_back(0x0);
1063  encoder.set_vifr_out_mirror_md(destdata);
1064  }
1065  }
1066 
1067  if (has_service_vlan_) {
1068  flags |= VIF_FLAG_SERVICE_IF;
1069  }
1070  }
1071 
1072  encoder.set_vifr_mac(std::vector<int8_t>((const int8_t *)mac(),
1073  (const int8_t *)mac() + mac().size()));
1074 
1075  switch(transport_) {
1077  encoder.set_vifr_transport(VIF_TRANSPORT_ETH);
1078  break;
1079  }
1080 
1082  encoder.set_vifr_transport(VIF_TRANSPORT_SOCKET);
1083  break;
1084  }
1085 
1086  case Interface::TRANSPORT_PMD: {
1087  encoder.set_vifr_transport(VIF_TRANSPORT_PMD);
1088  break;
1089  }
1090  default:
1091  break;
1092  }
1093 
1094  encoder.set_vifr_flags(flags);
1095 
1096  encoder.set_vifr_vrf(vrf_id);
1097  encoder.set_vifr_mcast_vrf(multicast_vrf_id_);
1098  encoder.set_vifr_idx(interface_id_);
1099  encoder.set_vifr_rid(0);
1100  encoder.set_vifr_os_idx(os_index_);
1101  encoder.set_vifr_mtu(0);
1102  if (type_ != Interface::PHYSICAL) {
1103  encoder.set_vifr_name(interface_name_);
1104  }
1105  encoder.set_vifr_ip(htonl(ip_));
1106  encoder.set_vifr_nh_id(flow_key_nh_id_);
1107 
1108  // GUIDs are used as interface identifiers on Windows
1109  if (os_guid_) {
1110  InterfaceOsParams::IfGuid& os_guid = os_guid_.get();
1111 
1112  std::vector<int8_t> raw_guid(os_guid.size(), 0);
1113  memcpy(raw_guid.data(), &os_guid, os_guid.size());
1114 
1115  encoder.set_vifr_if_guid(raw_guid);
1116  }
1117 
1118  int error = 0;
1119  encode_len = encoder.WriteBinary((uint8_t *)buf, buf_len, &error);
1120  assert(error == 0);
1121  assert(encode_len <= buf_len);
1122  return encode_len;
1123 }
1124 
1126  KSyncIntfInfo &info) const {
1127  info.set_name(interface_name_);
1128  info.set_idx(interface_id_);
1129 
1130  if (op == sandesh_op::ADD) {
1131  info.set_operation("ADD/CHANGE");
1132  } else {
1133  info.set_operation("DELETE");
1134  }
1135 
1136  if (op == sandesh_op::ADD) {
1137  info.set_os_idx(os_index_);
1138  info.set_vrf_id(vrf_id_);
1139  info.set_hc_active(hc_active_);
1140  info.set_l2_active(l2_active_);
1141  info.set_active(ipv4_active_);
1142  info.set_policy_enabled(policy_enabled_);
1143  info.set_service_enabled(has_service_vlan_);
1144  info.set_analyzer_name(analyzer_name_);
1145 
1146  std::vector<KSyncIntfFatFlowInfo> fat_flows;
1147  for (VmInterface::FatFlowEntrySet::const_iterator it =
1148  fat_flow_list_.list_.begin(); it != fat_flow_list_.list_.end();
1149  it++) {
1150  KSyncIntfFatFlowInfo info;
1151  info.set_protocol(it->protocol);
1152  info.set_port(it->port);
1153  info.set_ignore_address(it->ignore_address);
1154  fat_flows.push_back(info);
1155  }
1156  info.set_fat_flows(fat_flows);
1157  info.set_fat_flow_v4_exclude_list
1159  info.set_fat_flow_v6_exclude_upper_list
1161  info.set_fat_flow_v6_exclude_lower_list
1163  info.set_fat_flow_v6_exclude_plen_list
1165  }
1166 }
1167 
1168 int InterfaceKSyncEntry::AddMsg(char *buf, int buf_len) {
1169  KSyncIntfInfo info;
1170 
1171  FillObjectLog(sandesh_op::ADD, info);
1172  KSYNC_TRACE(Intf, GetObject(), info);
1173  return Encode(sandesh_op::ADD, buf, buf_len);
1174 }
1175 
1176 int InterfaceKSyncEntry::DeleteMsg(char *buf, int buf_len) {
1177  KSyncIntfInfo info;
1178  FillObjectLog(sandesh_op::DEL, info);
1179  KSYNC_TRACE(Intf, GetObject(), info);
1180  return Encode(sandesh_op::DEL, buf, buf_len);
1181 }
1182 
1183 int InterfaceKSyncEntry::ChangeMsg(char *buf, int buf_len) {
1184  return AddMsg(buf, buf_len);
1185 }
1186 
1188  KSyncDBObject("KSync Interface"), ksync_(ksync) {
1189 }
1190 
1192 }
1193 
1196 }
1197 
1199  uint32_t index) {
1200  const InterfaceKSyncEntry *intf =
1201  static_cast<const InterfaceKSyncEntry *>(entry);
1202  InterfaceKSyncEntry *ksync = new InterfaceKSyncEntry(this, intf, index);
1203  return static_cast<KSyncEntry *>(ksync);
1204 }
1205 
1207  const Interface *intf = static_cast<const Interface *>(e);
1208  InterfaceKSyncEntry *key = NULL;
1209 
1210  switch (intf->type()) {
1211  case Interface::PHYSICAL:
1213  case Interface::PACKET:
1214  case Interface::INET:
1215  case Interface::LOGICAL:
1217  key = new InterfaceKSyncEntry(this, intf);
1218  break;
1219 
1220  default:
1221  assert(0);
1222  break;
1223  }
1224  return static_cast<KSyncEntry *>(key);
1225 }
1226 
1228  ksync_->agent()->set_test_mode(false);
1229 }
1230 
1232  ksync_->agent()->set_test_mode(true);
1233 }
1234 
1237  const KSyncDBEntry *ksync) {
1238 
1239  const Interface *intf = dynamic_cast<const Interface *>(entry);
1240  const VmInterface *vm_intf = dynamic_cast<const VmInterface *>(intf);
1241 
1242  uint32_t rx_vlan_id = VmInterface::kInvalidVlanId;
1244 
1245  if (vm_intf) {
1246  rx_vlan_id = vm_intf->rx_vlan_id();
1247  vmi_type = vm_intf->vmi_type();
1248  }
1249 
1250  if (IsValidOsIndex(intf->os_index(), intf->type(), rx_vlan_id,
1251  vmi_type, intf->transport()) == false) {
1252  return DBFilterIgnore;
1253  }
1254 
1255  if (intf->type() == Interface::LOGICAL ||
1256  intf->type() == Interface::REMOTE_PHYSICAL) {
1257  return DBFilterIgnore;
1258  }
1259 
1260  // No need to add VLAN sub-interface if there is no parent
1261  if (vm_intf && vm_intf->device_type() == VmInterface::VM_VLAN_ON_VMI &&
1262  vm_intf->parent() == NULL) {
1263  return DBFilterIgnore;
1264  }
1265 
1266  return DBFilterAccept;
1267 }
1268 
1270 // sandesh routines
1272 void vr_response::Process(SandeshContext *context) {
1273  AgentSandeshContext *ioc = static_cast<AgentSandeshContext *>(context);
1274  ioc->SetErrno(ioc->VrResponseMsgHandler(this));
1275 }
1276 
1277 void InterfaceKSyncEntry::SetKsyncItfSandeshData(KSyncItfSandeshData *data) const {
1278 
1279  data->set_analyzer_name(analyzer_name_);
1280 
1281  if (drop_new_flows_) {
1282  data->set_drop_new_flows("Enable");
1283  } else {
1284  data->set_drop_new_flows("Disable");
1285  }
1286 
1287  if (dhcp_enable_) {
1288  data->set_dhcp_service("Enable");
1289  } else {
1290  data->set_dhcp_service("Disable");
1291  }
1292 
1293  data->set_fd(fd_);
1294  data->set_flow_key_nh_id(flow_key_nh_id_);
1295 
1296  if (has_service_vlan_) {
1297  data->set_has_service_vlan("Enable");
1298  } else {
1299  data->set_has_service_vlan("Disable");
1300  }
1301 
1302  data->set_interface_id(interface_id_);
1303  data->set_interface_name(interface_name_);
1304  data->set_ip(ip_);
1305 
1306  if (hc_active_) {
1307  data->set_health_check("Active");
1308  } else {
1309  data->set_health_check("Inactive");
1310  }
1311 
1312  if (ipv4_active_) {
1313  data->set_ipv4_active("Active");
1314  } else {
1315  data->set_ipv4_active("Inactive");
1316  }
1317 
1318  if (layer3_forwarding_) {
1319  data->set_layer3_forwarding("Enable");
1320  } else {
1321  data->set_layer3_forwarding("Disable");
1322  }
1323 
1324  if (l2_active_) {
1325  data->set_l2_active("Active");
1326  } else {
1327  data->set_l2_active("Inactive");
1328  }
1329 
1330  if (metadata_l2_active_) {
1331  data->set_metadata_l2_active("Active");
1332  } else {
1333  data->set_metadata_l2_active("Inactive");
1334  }
1335 
1336 
1337  if (metadata_ip_active_) {
1338  data->set_metadata_ip_active("Active");
1339  } else {
1340  data->set_metadata_ip_active("Inactive");
1341  }
1342 
1343  if (bridging_) {
1344  data->set_bridging("Enable");
1345  } else {
1346  data->set_l2_active("Disable");
1347  }
1348 
1349  data->set_mac(mac_.ToString());
1350  data->set_smac(smac_.ToString());
1351  data->set_network_id(network_id_);
1352  data->set_os_index(os_index_);
1353 
1354  if (policy_enabled_) {
1355  data->set_policy_enabled("Enable");
1356  } else {
1357  data->set_policy_enabled("Disable");
1358  }
1359 
1360  data->set_rx_vlan_id(rx_vlan_id_);
1361  data->set_tx_vlan_id(tx_vlan_id_);
1362  data->set_vrf_id(vrf_id_);
1363 
1364  if (persistent_) {
1365  data->set_persistent("Enable");
1366  } else {
1367  data->set_persistent("Disable");
1368  }
1369 
1370  if (no_arp_) {
1371  data->set_no_arp("Enable");
1372  } else {
1373  data->set_no_arp("Disable");
1374  }
1375 
1376  data->set_display_name(display_name_);
1377 
1378  if (flood_unknown_unicast_) {
1379  data->set_flood_unknown_unicast("Enable");
1380  } else {
1381  data->set_flood_unknown_unicast("Disable");
1382  }
1383 
1384  if (learning_enabled_) {
1385  data->set_learning("Enable");
1386  } else {
1387  data->set_learning("Disable");
1388  }
1389 
1390  data->set_isid(isid_);
1391  data->set_pbb_cmac_vrf(pbb_cmac_vrf_);
1392  data->set_pbb_mac(pbb_mac_.ToString());
1393 
1394  if (etree_leaf_) {
1395  data->set_etree_leaf("Enable");
1396  } else {
1397  data->set_etree_leaf("Disable");
1398  }
1399 
1400  if (pbb_interface_) {
1401  data->set_pbb_interface("Enable");
1402  } else {
1403  data->set_pbb_interface("Disable");
1404  }
1405 
1406  if (igmp_enable_) {
1407  data->set_igmp_enable("Enable");
1408  } else {
1409  data->set_igmp_enable("Disable");
1410  }
1411 
1413  data->set_mac_ip_learning_enable("Enable");
1414  } else {
1415  data->set_mac_ip_learning_enable("Disable");
1416  }
1417 }
1418 
1420  KSyncItfResp *resp = static_cast<KSyncItfResp *> (sresp);
1421 
1422  KSyncItfSandeshData data;
1423  SetKsyncItfSandeshData(&data);
1424  std::vector<KSyncItfSandeshData> &list =
1425  const_cast<std::vector<KSyncItfSandeshData>&>(resp->get_KSyncitf_list());
1426  list.push_back(data);
1427 
1428  return true;
1429 }
1430 
1431 void KSyncItfReq::HandleRequest() const {
1432  AgentKsyncSandeshPtr sand(new AgentKsyncIntfSandesh(context()));
1433  sand->DoKsyncSandesh(sand);
1434 
1435 }
void BuildFatFlowExcludeList(FatFlowExcludeList *list) const
Interface * xconnect() const
#define KSYNC_TRACE(obj, parent,...)
Definition: ksync_object.h:304
#define VIF_FAT_FLOW_ENCODE_AGGR_PROTO_PORT(prefix_aggr, ignore_addr, protocol, port)
bool pbb_interface() const
int vxlan_id() const
PhysicalInterface::EncapType encap_type_
const MacAddress & vm_mac() const
Type type() const
Definition: interface.h:112
const AgentQosConfig * qos_config() const
Definition: interface.h:140
bool HasServiceVlan() const
void RegisterDb(DBTableBase *table)
Definition: vrf.h:86
InetInterface::SubType sub_type_
bool etree_leaf() const
virtual void SetErrno(int err)
Definition: ksync_sock.h:78
uint16_t rx_vlan_id() const
bool IsResolved()
VmInterface::DeviceType vmi_device_type_
std::vector< uint16_t > fat_flow_v6_exclude_plen_list_
DBTableBase * get_table() const
Definition: db_entry.cc:119
Agent * agent() const
Definition: ksync_init.h:39
VmInterface::FatFlowList fat_flow_list_
SubType subtype() const
VmInterface::DeviceType device_type() const
uint32_t os_index() const
Definition: interface.h:130
InterfaceKSyncObject(KSync *parent)
std::vector< uint64_t > fat_flow_v4_exclude_list_
KSync * ksync() const
static const MacAddress & vrrp_mac()
Definition: agent.h:439
Interface::Transport transport() const
Definition: interface.h:138
bool l2_active() const
Definition: interface.h:122
VmInterface::ProxyArpMode proxy_arp_mode_
bool pbb_gateway_mode() const
Definition: agent.h:1170
virtual KSyncEntry * UnresolvedReference()
bool KSyncEntrySandesh(Sandesh *resp)
ProxyArpMode proxy_arp_mode() const
bool persistent() const
const std::set< uint16_t > & nic_queue_list() const
Definition: agent_param.h:510
VmInterface::HbsIntfType hbs_intf_type() const
bool has_service_vlan() const
InterfaceTable * interface_table() const
Definition: agent.h:465
boost::optional< InterfaceOsParams::IfGuid > os_guid_
virtual bool IsLess(const KSyncEntry &rhs) const
KSyncDBObject * GetObject() const
static size_t size()
Definition: mac_address.h:57
const string & GetName() const
Definition: vrf.h:100
const MacAddress & mac() const
Definition: interface.h:131
virtual KSyncEntry * Alloc(const KSyncEntry *entry, uint32_t index)
int Encode(sandesh_op::type op, char *buf, int buf_len)
Agent * agent() const
Definition: interface.h:447
Ip4Address loopback_ip() const
Definition: agent.h:716
Ip4Address ip_addr() const
const MacAddress & mac() const
const NextHop * flow_key_nh() const
Definition: interface.h:137
bool learning_enabled() const
bool no_arp() const
uint8_t vhostuser_mode() const
virtual KSyncEntry * DBToKSyncEntry(const DBEntry *e)
std::string ToString() const
Definition: mac_address.cc:53
bool server_gateway_mode() const
Definition: agent.h:1168
uint16_t tx_vlan_id() const
std::vector< uint64_t > fat_flow_v6_exclude_upper_list_
const MacAddress & smac() const
static const uint8_t kInvalidIndex
Definition: mirror_table.h:119
bool metadata_l2_active() const
Definition: interface.h:120
VrfEntry * FindVrfFromId(size_t index)
Definition: vrf.cc:884
std::vector< KSyncEntryPtr > xconnect_list_
uint8_t type
Definition: load_balance.h:109
bool dhcp_enabled_v6() const
Definition: interface.h:125
static const uint32_t kInvalidVlanId
Definition: vm_interface.h:360
bool flood_unknown_unicast() const
MirrorKSyncObject * mirror_ksync_obj() const
Definition: ksync_init.h:40
uint32_t vrf_id() const
Definition: interface.cc:621
const std::string GetAnalyzer() const
KSyncEntryPtr qos_config_
InterfaceKSyncObject * ksync_obj_
bool ipv4_active() const
Definition: interface.h:116
bool metadata_ip_active() const
Definition: interface.h:119
boost::intrusive_ptr< KSyncEntry > KSyncEntryPtr
Definition: ksync_entry.h:68
VmInterface::FatFlowExcludeList fat_flow_exclude_list_
const MacAddress & pbb_mac() const
class boost::shared_ptr< AgentKsyncSandesh > AgentKsyncSandeshPtr
bool layer3_forwarding() const
void set_test_mode(bool test_mode)
Definition: agent.h:1192
bool dhcp_enabled() const
Definition: interface.h:124
bool bridging() const
uint32_t GetPbbVrf() const
bool policy_enabled() const
void Ip6AddressToU64Array(const Ip6Address &addr, uint64_t *arr, int size)
KSyncEntryPtr xconnect_
Interface::MirrorDirection mirror_direction() const
virtual std::string ToString() const
AgentParam * params() const
Definition: agent.h:1218
uint32_t GetIsid() const
const uint32_t vrf_id() const
Definition: vrf.h:99
KSyncEntry * GetReference(const KSyncEntry *key)
std::string display_name_
PhysicalInterface::SubType subtype_
virtual ~InterfaceKSyncEntry()
EncapType encap_type() const
VmInterface::HbsIntfType hbs_intf_type_
virtual int DeleteMsg(char *buf, int buf_len)
const FatFlowList & fat_flow_list() const
VrfTable * vrf_table() const
Definition: agent.h:485
InterfaceKSyncEntry(InterfaceKSyncObject *obj, const InterfaceKSyncEntry *entry, uint32_t index)
const Ip4Address & primary_ip_addr() const
virtual bool Sync(DBEntry *e)
std::vector< uint64_t > fat_flow_v6_exclude_lower_list_
uint32_t id() const
Definition: nexthop.h:408
PhysicalInterface::EncapType encap_type() const
VmInterface::VmiType vmi_type() const
DBFilterResp DBEntryFilter(const DBEntry *e, const KSyncDBEntry *k)
static const uint32_t kInvalidIndex
Definition: interface.h:70
const Ip6Address & primary_ip6_addr() const
virtual int ChangeMsg(char *buf, int buf_len)
VnEntry * vn() const
Definition: vrf.h:101
uint32_t mirror_index()
Definition: mirror_ksync.h:40
bool igmp_enabled() const
static const uint32_t kInvalidIndex
Definition: vrf.h:88
bool no_arp() const
bool IsValidOsIndex(size_t os_index, Interface::Type type, uint16_t vlan_id, VmInterface::VmiType vmi_type, Interface::Transport transport)
std::set< MacAddress > aap_mac_list_
KSyncEntryPtr parent_
Interface::MirrorDirection mirror_direction_
const Ip4Address & ip_addr() const
const string & GetName() const
Definition: vn.h:162
VrfEntry * forwarding_vrf() const
bool isVmwareVcenterMode() const
Definition: agent.cc:1037
VmInterface::VmiType vmi_type_
boost::uuids::uuid IfGuid
bool mac_ip_learning_enable() const
SubType sub_type() const
uint32_t GetIdx(std::string analyzer_name)
void SetKsyncItfSandeshData(KSyncItfSandeshData *data) const
const std::string & display_name() const
MirrorDirection
Definition: interface.h:55
boost::optional< InterfaceOsParams::IfGuid > os_guid() const
Definition: interface.h:145
uint32_t interface_id() const
InterfaceList parent_list() const
const Interface * parent() const
const AllowedAddressPairList & allowed_address_pair_list() const
void FillObjectLog(sandesh_op::type op, KSyncIntfInfo &info) const
virtual int AddMsg(char *buf, int buf_len)
bool is_hc_active() const
Definition: interface.h:118
virtual int VrResponseMsgHandler(vr_response *resp)=0
bool drop_new_flows() const
uint32_t id() const
Interface::Type type_
Interface::Transport transport_