Skip to content

Commit

Permalink
Don't add loopback ip2me route again if already configured (#656)
Browse files Browse the repository at this point in the history
* Don't add loopback ip2me route again if already configured

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>

* Handle case of multiple ip/ipv6 addresses on lo interface

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>

* Empty check for lo interface data

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>

* TODO: handle case for which lo is not in default vrf gVirtualRouterId

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
  • Loading branch information
jipanyang authored and lguohan committed Nov 9, 2018
1 parent 6eb1613 commit 8c60787
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,38 @@ void IntfsOrch::doTask(Consumer &consumer)
{
if (alias == "lo")
{
addIp2MeRoute(vrf_id, ip_prefix);
if (!ip_prefix_in_key)
{
it = consumer.m_toSync.erase(it);
continue;
}

bool addIp2Me = false;
// set request for lo may come after warm start restore.
// It is also to prevent dupicate set requests in normal running case.
auto it_intfs = m_syncdIntfses.find(alias);
if (it_intfs == m_syncdIntfses.end())
{
IntfsEntry intfs_entry;

intfs_entry.ref_count = 0;
intfs_entry.ip_addresses.insert(ip_prefix);
m_syncdIntfses[alias] = intfs_entry;
addIp2Me = true;
}
else
{
if (m_syncdIntfses[alias].ip_addresses.count(ip_prefix) == 0)
{
m_syncdIntfses[alias].ip_addresses.insert(ip_prefix);
addIp2Me = true;
}
}
if (addIp2Me)
{
addIp2MeRoute(vrf_id, ip_prefix);
}

it = consumer.m_toSync.erase(it);
continue;
}
Expand Down Expand Up @@ -261,7 +292,20 @@ void IntfsOrch::doTask(Consumer &consumer)
{
if (alias == "lo")
{
removeIp2MeRoute(vrf_id, ip_prefix);
// TODO: handle case for which lo is not in default vrf gVirtualRouterId
if (m_syncdIntfses.find(alias) != m_syncdIntfses.end())
{
if (m_syncdIntfses[alias].ip_addresses.count(ip_prefix))
{
m_syncdIntfses[alias].ip_addresses.erase(ip_prefix);
removeIp2MeRoute(vrf_id, ip_prefix);
}
if (m_syncdIntfses[alias].ip_addresses.size() == 0)
{
m_syncdIntfses.erase(alias);
}
}

it = consumer.m_toSync.erase(it);
continue;
}
Expand Down

0 comments on commit 8c60787

Please sign in to comment.