-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Take interface nh reference after creating in VmInterface.
Previously say a db entry is created so it has ref count of 0. Now references are being taken and released in multiple partition (currently in flow). The refcount manipulation is atomic but operations after manipulations are not. In absence of self reference refcount can go to 0 and come back to 1 and in turn dbstate could be deleted. Entry is not marked for deletion and is valid. This results in double call to free state and second call asserts as there was no state. Bit more explanation on why refcount is 1 and there is no state above. Say there are two referrers a and b. a has taken reference and then releasing it. So refcount goes to 1 and then back to 0. While it has modified refcount and going through clearrefstate (refcount being 0), b runs in parallel and increments refcount as well as tried adding state. Meanwhile a also proceeds and then deletes state. Result is refcount is at 1 and there is no state which is wrong. Closes-bug: #1571584 Change-Id: I2237971d2f36aac00fa76b90770943bdddc86c19
- Loading branch information
1 parent
c801325
commit 40e5eb0
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2016 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
|
||
#include "test_cmn_util.h" | ||
|
||
void RouterIdDepInit(Agent *agent) { | ||
} | ||
|
||
class AgentDbEntry : public ::testing::Test { | ||
public: | ||
AgentDbEntry() { | ||
agent_ = Agent::GetInstance(); | ||
} | ||
virtual ~AgentDbEntry() { } | ||
Agent *agent_; | ||
}; | ||
|
||
TEST_F(AgentDbEntry, db_entry_self_reference) { | ||
struct PortInfo input[] = { | ||
{"vnet1", 1, "1.1.1.10", "00:00:01:01:01:10", 1, 1}, | ||
}; | ||
|
||
client->Reset(); | ||
CreateVmportEnv(input, 1); | ||
client->WaitForIdle(); | ||
VmInterfaceKey *intf_key = new VmInterfaceKey(AgentKey::ADD_DEL_CHANGE, | ||
MakeUuid(1), "vnet1"); | ||
InterfaceNHKey intf_nh_key(intf_key, false, | ||
(InterfaceNHFlags::INET4) | | ||
(InterfaceNHFlags::MULTICAST)); | ||
NextHop *nh = GetNH(&intf_nh_key); | ||
EXPECT_TRUE(nh->GetRefCount() != 0); | ||
DeleteVmportEnv(input, 1, true); | ||
client->WaitForIdle(); | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
GETUSERARGS(); | ||
client = TestInit(init_file, ksync_init, true, true, false); | ||
|
||
int ret = RUN_ALL_TESTS(); | ||
TestShutdown(); | ||
delete client; | ||
return ret; | ||
} |