Skip to content

Commit

Permalink
Fix for fat-flow configuration not getting deleted
Browse files Browse the repository at this point in the history
Purge fat-flow entries with del_pending_ set to true after config
processing.
Also, updated interface-ksync to print fat-flows configured to vrouter

Change-Id: I886d4ffe4e24d3acfeb15e4f90fca3b33f407db3
Fixes-Bug: #1522285
  • Loading branch information
praveenkv committed Dec 3, 2015
1 parent c80ab82 commit 6388a2e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/vnsw/agent/oper/test/test_intf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3289,6 +3289,40 @@ TEST_F(IntfTest, FatFlow) {
client->Reset();
}

TEST_F(IntfTest, FatFlowDel) {
struct PortInfo input[] = {
{"vnet1", 1, "1.1.1.1", "00:00:00:00:00:01", 1, 1},
};

CreateVmportEnv(input, 1);
client->WaitForIdle();
EXPECT_TRUE(VmPortFind(1));

const VmInterface *intf = static_cast<const VmInterface *>(VmPortGet(1));
EXPECT_TRUE(intf->fat_flow_list().list_.size() == 0);

AddFatFlow(input, "udp", 53);
client->WaitForIdle();
EXPECT_TRUE(intf->fat_flow_list().list_.size() == 1);
EXPECT_TRUE(intf->IsFatFlow(IPPROTO_UDP, 53) == true);
EXPECT_TRUE(intf->IsFatFlow(IPPROTO_UDP, 0) == false);

CreateVmportEnv(input, 1);
client->WaitForIdle();
EXPECT_TRUE(intf->fat_flow_list().list_.size() == 0);
EXPECT_TRUE(intf->IsFatFlow(IPPROTO_UDP, 53) == false);
EXPECT_TRUE(intf->IsFatFlow(IPPROTO_UDP, 0) == false);

DelNode("virtual-machine-interface", "vnet1");
client->WaitForIdle();
EXPECT_TRUE(intf->fat_flow_list().list_.size() == 0);

DeleteVmportEnv(input, 1, true);
client->WaitForIdle();
EXPECT_FALSE(VmPortFind(1));
client->Reset();
}

int main(int argc, char **argv) {
GETUSERARGS();

Expand Down
11 changes: 11 additions & 0 deletions src/vnsw/agent/oper/vm_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,7 @@ void VmInterface::ApplyConfigCommon(const VrfEntry *old_vrf,
//Security Group update
if (IsActive()) {
UpdateSecurityGroup();
UpdateFatFlow();
} else {
DeleteSecurityGroup();
DeleteFatFlow();
Expand Down Expand Up @@ -2949,6 +2950,16 @@ void VmInterface::DeleteSecurityGroup() {
}
}

void VmInterface::UpdateFatFlow() {
FatFlowEntrySet::iterator it = fat_flow_list_.list_.begin();
while (it != fat_flow_list_.list_.end()) {
FatFlowEntrySet::iterator prev = it++;
if (prev->del_pending_) {
fat_flow_list_.list_.erase(prev);
}
}
}

void VmInterface::DeleteFatFlow() {
FatFlowEntrySet::iterator it = fat_flow_list_.list_.begin();
while (it != fat_flow_list_.list_.end()) {
Expand Down
3 changes: 2 additions & 1 deletion src/vnsw/agent/oper/vm_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ class VmInterface : public Interface {

struct FatFlowList {
FatFlowList(): list_() {}
~FatFlowList() {};
~FatFlowList() {}
void Insert(const FatFlowEntry *rhs);
void Update(const FatFlowEntry *lhs, const FatFlowEntry *rhs);
void Remove(FatFlowEntrySet::iterator &it);
Expand Down Expand Up @@ -727,6 +727,7 @@ class VmInterface : public Interface {
void DeleteAllowedAddressPair(bool l2);
void UpdateSecurityGroup();
void DeleteSecurityGroup();
void UpdateFatFlow();
void DeleteFatFlow();
void UpdateL2TunnelId(bool force_update, bool policy_change);
void DeleteL2TunnelId();
Expand Down
6 changes: 6 additions & 0 deletions src/vnsw/agent/vrouter/ksync/agent_ksync.sandesh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/

struct KSyncIntfFatFlowInfo {
1: u16 protocol;
2: u16 port;
}

struct KSyncIntfInfo {
1: u32 idx;
2: string name;
Expand All @@ -13,6 +18,7 @@ struct KSyncIntfInfo {
8: optional u32 service_enabled;
9: optional string analyzer_name;
10: optional u32 l2_active;
11: optional list<KSyncIntfFatFlowInfo> fat_flows;
}

traceobject sandesh KSyncIntf {
Expand Down
11 changes: 11 additions & 0 deletions src/vnsw/agent/vrouter/ksync/interface_ksync.cc
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,17 @@ void InterfaceKSyncEntry::FillObjectLog(sandesh_op::type op,
info.set_policy_enabled(policy_enabled_);
info.set_service_enabled(has_service_vlan_);
info.set_analyzer_name(analyzer_name_);

std::vector<KSyncIntfFatFlowInfo> fat_flows;
for (VmInterface::FatFlowEntrySet::const_iterator it =
fat_flow_list_.list_.begin(); it != fat_flow_list_.list_.end();
it++) {
KSyncIntfFatFlowInfo info;
info.set_protocol(it->protocol);
info.set_port(it->port);
fat_flows.push_back(info);
}
info.set_fat_flows(fat_flows);
}
}

Expand Down

0 comments on commit 6388a2e

Please sign in to comment.