From 3503adfb0daf549152010a537e50f0671b13bec6 Mon Sep 17 00:00:00 2001 From: Praveen K V Date: Sat, 20 Jun 2015 00:29:10 +0530 Subject: [PATCH] Fix for interface link-state going out-of-sync between agent and host-os The VifListener module tracks the link-state for a tap interface by listening to Netlink messages from host-os. When it identifies transition of link-state, it enqueues RESYNC operation on interface to re-evaluate the ACTIVE state of interface. Bug: There is a corner case where Interface object may not have right state. 1. Tap interface gets created in down state 2. Agent adds interface to oper-db in down state 3. Agent adds the interface-object in notify queue 4. When interface is in notify-queue, - VifListener gets notification of link going to UP state - VifListener ignore the link transition since it is not notified of the interface yet 5. VifListener module gets interface notification In (5), VifListener should enqueue RESYNC operation on interface. But, its not doing it currently. Fix: - Modify case (5) above to enqueue RESYNC operation on interface - Modify VifListener to notify all Netlink messages to interface independent of whether state is transitioned or not Change-Id: I4472d9396387d75c53a0c3cd53f30d87de565799 Closes-Bug: #1466935 --- .../vrouter/ksync/linux/vnswif_listener.cc | 2 +- .../agent/vrouter/ksync/vnswif_listener_base.cc | 17 ++--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/vnsw/agent/vrouter/ksync/linux/vnswif_listener.cc b/src/vnsw/agent/vrouter/ksync/linux/vnswif_listener.cc index 9de5e8dbb35..002c99f7e49 100644 --- a/src/vnsw/agent/vrouter/ksync/linux/vnswif_listener.cc +++ b/src/vnsw/agent/vrouter/ksync/linux/vnswif_listener.cc @@ -297,7 +297,7 @@ VnswInterfaceListenerLinux::HandleNetlinkIntfMsg(struct nlmsghdr *nlh) { assert(port_name != NULL); LOG(DEBUG, "Handle netlink interface message " << NetlinkTypeToString(nlh->nlmsg_type) - << " for interface " << port_name); + << " for interface " << port_name << " flags " << ifi->ifi_flags); Event::Type type; if (nlh->nlmsg_type == RTM_DELLINK) { diff --git a/src/vnsw/agent/vrouter/ksync/vnswif_listener_base.cc b/src/vnsw/agent/vrouter/ksync/vnswif_listener_base.cc index a49e4163f55..002aae9f632 100644 --- a/src/vnsw/agent/vrouter/ksync/vnswif_listener_base.cc +++ b/src/vnsw/agent/vrouter/ksync/vnswif_listener_base.cc @@ -191,18 +191,13 @@ void VnswInterfaceListenerBase::SetSeen(const std::string &name, bool oper) { host_interface_table_.insert(make_pair(name, entry)); } - bool old_active = IsInterfaceActive(entry); if (oper) { entry->oper_seen_ = true; } else { entry->host_seen_ = true; } - if (old_active == IsInterfaceActive(entry)) - return; - - if (old_active == false) - Activate(name, entry->oper_id_); + Activate(name, entry->oper_id_); } void VnswInterfaceListenerBase::ResetSeen(const std::string &name, bool oper) { @@ -210,7 +205,6 @@ void VnswInterfaceListenerBase::ResetSeen(const std::string &name, bool oper) { if (entry == NULL) return; - bool old_active = IsInterfaceActive(entry); if (oper) { entry->oper_seen_ = false; } else { @@ -224,11 +218,7 @@ void VnswInterfaceListenerBase::ResetSeen(const std::string &name, bool oper) { return; } - if (old_active == IsInterfaceActive(entry)) - return; - - if (old_active) - DeActivate(name, entry->oper_id_); + DeActivate(name, entry->oper_id_); } void VnswInterfaceListenerBase::SetLinkState(const std::string &name, bool link_up){ @@ -239,9 +229,6 @@ void VnswInterfaceListenerBase::SetLinkState(const std::string &name, bool link_ bool old_active = IsInterfaceActive(entry); entry->link_up_ = link_up; - if (old_active == IsInterfaceActive(entry)) - return; - if (old_active) DeActivate(name, entry->oper_id_); else