Skip to content

Commit

Permalink
Fix for interface link-state going out-of-sync between agent and host-os
Browse files Browse the repository at this point in the history
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
  • Loading branch information
praveenkv committed Jun 19, 2015
1 parent a25e85f commit 3503adf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/vnsw/agent/vrouter/ksync/linux/vnswif_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 2 additions & 15 deletions src/vnsw/agent/vrouter/ksync/vnswif_listener_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,26 +191,20 @@ 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) {
HostInterfaceEntry *entry = GetHostInterfaceEntry(name);
if (entry == NULL)
return;

bool old_active = IsInterfaceActive(entry);
if (oper) {
entry->oper_seen_ = false;
} else {
Expand All @@ -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){
Expand All @@ -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
Expand Down

0 comments on commit 3503adf

Please sign in to comment.