Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync lo address to the asic #103

Merged
merged 1 commit into from
Oct 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ void IntfsOrch::doTask(Consumer &consumer)
string alias(keys[0]);
IpPrefix ip_prefix(kfvKey(t).substr(kfvKey(t).find(':')+1));

/* TODO: Sync loopback address and trap all IP packets to loopback address */
if (alias == "lo" || alias == "eth0" || alias == "docker0")
if (alias == "eth0" || alias == "docker0")
{
it = consumer.m_toSync.erase(it);
continue;
Expand All @@ -64,6 +63,13 @@ void IntfsOrch::doTask(Consumer &consumer)
string op = kfvOp(t);
if (op == SET_COMMAND)
{
if (alias == "lo")
{
addIp2MeRoute(ip_prefix);
it = consumer.m_toSync.erase(it);
continue;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest move 'alias == lo' block to outside, because it is similar to eth0/docker0. Then 'getPort' can be also outside.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is moved to outside, then there will be if/else for the op == SET/DEL.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. it is clearer.

Port port;
if (!gPortsOrch->getPort(alias, port))
{
Expand All @@ -82,7 +88,7 @@ void IntfsOrch::doTask(Consumer &consumer)
m_syncdIntfses[alias] = intfs_entry;

addSubnetRoute(port, ip_prefix);
addIp2MeRoute(port, ip_prefix);
addIp2MeRoute(ip_prefix);

m_syncdIntfses[alias].ip_addresses.add(ip_prefix.getIp());
it = consumer.m_toSync.erase(it);
Expand All @@ -96,6 +102,13 @@ void IntfsOrch::doTask(Consumer &consumer)
}
else if (op == DEL_COMMAND)
{
if (alias == "lo")
{
removeIp2MeRoute(ip_prefix);
it = consumer.m_toSync.erase(it);
continue;
}

Port port;
if (!gPortsOrch->getPort(alias, port))
{
Expand All @@ -108,7 +121,7 @@ void IntfsOrch::doTask(Consumer &consumer)
if (m_syncdIntfses[alias].ip_addresses.contains(ip_prefix.getIp()))
{
removeSubnetRoute(port, ip_prefix);
removeIp2MeRoute(port, ip_prefix);
removeIp2MeRoute(ip_prefix);

m_syncdIntfses[alias].ip_addresses.remove(ip_prefix.getIp());
}
Expand Down Expand Up @@ -267,7 +280,7 @@ void IntfsOrch::removeSubnetRoute(const Port &port, const IpPrefix &ip_prefix)
decreaseRouterIntfsRefCount(port.m_alias);
}

void IntfsOrch::addIp2MeRoute(const Port &port, const IpPrefix &ip_prefix)
void IntfsOrch::addIp2MeRoute(const IpPrefix &ip_prefix)
{
sai_unicast_route_entry_t unicast_route_entry;
unicast_route_entry.vr_id = gVirtualRouterId;
Expand All @@ -292,10 +305,9 @@ void IntfsOrch::addIp2MeRoute(const Port &port, const IpPrefix &ip_prefix)
}

SWSS_LOG_NOTICE("Create IP2me route ip:%s", ip_prefix.getIp().to_string().c_str());
increaseRouterIntfsRefCount(port.m_alias);
}

void IntfsOrch::removeIp2MeRoute(const Port &port, const IpPrefix &ip_prefix)
void IntfsOrch::removeIp2MeRoute(const IpPrefix &ip_prefix)
{
sai_unicast_route_entry_t unicast_route_entry;
unicast_route_entry.vr_id = gVirtualRouterId;
Expand All @@ -309,5 +321,4 @@ void IntfsOrch::removeIp2MeRoute(const Port &port, const IpPrefix &ip_prefix)
}

SWSS_LOG_NOTICE("Remove packet action trap route ip:%s", ip_prefix.getIp().to_string().c_str());
decreaseRouterIntfsRefCount(port.m_alias);
}
4 changes: 2 additions & 2 deletions orchagent/intfsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class IntfsOrch : public Orch
void addSubnetRoute(const Port &port, const IpPrefix &ip_prefix);
void removeSubnetRoute(const Port &port, const IpPrefix &ip_prefix);

void addIp2MeRoute(const Port &port, const IpPrefix &ip_prefix);
void removeIp2MeRoute(const Port &port, const IpPrefix &ip_prefix);
void addIp2MeRoute(const IpPrefix &ip_prefix);
void removeIp2MeRoute(const IpPrefix &ip_prefix);
};

#endif /* SWSS_INTFSORCH_H */