Skip to content

Commit 722649b

Browse files
author
Shuotian Cheng
authored
[routeorch]: Set default route's next hop to empty IpAddresses when DROP (sonic-net#219)
- field name fix to match ifname - log more information when next hop cannot be retrieved - when a default route is to be removed, set the next hop to empty IpAddresses
1 parent 3d234e4 commit 722649b

1 file changed

Lines changed: 19 additions & 24 deletions

File tree

orchagent/routeorch.cpp

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ void RouteOrch::detach(Observer *observer, const IpAddress& dstAddr)
144144
}
145145

146146
for (auto iter = observerEntry->second.observers.begin(); iter != observerEntry->second.observers.end(); ++iter)
147-
{
148-
if (observer == *iter)
149-
{
150-
m_observers.erase(iter);
151-
break;
152-
}
153-
}
147+
{
148+
if (observer == *iter)
149+
{
150+
m_observers.erase(iter);
151+
break;
152+
}
153+
}
154154
}
155155

156156
void RouteOrch::doTask(Consumer& consumer)
@@ -215,7 +215,7 @@ void RouteOrch::doTask(Consumer& consumer)
215215
if (fvField(i) == "nexthop")
216216
ip_addresses = IpAddresses(fvValue(i));
217217

218-
if (fvField(i) == "ifindex")
218+
if (fvField(i) == "ifname")
219219
alias = fvValue(i);
220220
}
221221

@@ -415,8 +415,8 @@ bool RouteOrch::addNextHopGroup(IpAddresses ipAddresses)
415415
{
416416
if (!m_neighOrch->hasNextHop(it))
417417
{
418-
SWSS_LOG_INFO("Failed to get next hop entry ip:%s",
419-
it.to_string().c_str());
418+
SWSS_LOG_INFO("Failed to get next hop %s in %s",
419+
it.to_string().c_str(), ipAddresses.to_string().c_str());
420420
return false;
421421
}
422422

@@ -505,8 +505,8 @@ void RouteOrch::addTempRoute(IpPrefix ipPrefix, IpAddresses nextHops)
505505
{
506506
if (!m_neighOrch->hasNextHop(*it))
507507
{
508-
SWSS_LOG_INFO("Failed to get next hop entry ip:%s",
509-
(*it).to_string().c_str());
508+
SWSS_LOG_INFO("Failed to get next hop %s for %s",
509+
(*it).to_string().c_str(), ipPrefix.to_string().c_str());
510510
it = next_hop_set.erase(it);
511511
}
512512
else
@@ -544,8 +544,8 @@ bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops)
544544
}
545545
else
546546
{
547-
SWSS_LOG_INFO("Failed to get next hop entry ip:%s",
548-
nextHops.to_string().c_str());
547+
SWSS_LOG_INFO("Failed to get next hop %s for %s",
548+
nextHops.to_string().c_str(), ipPrefix.to_string().c_str());
549549
return false;
550550
}
551551
}
@@ -707,22 +707,17 @@ bool RouteOrch::removeRoute(IpPrefix ipPrefix)
707707

708708
if (ipPrefix.isDefaultRoute())
709709
{
710-
if (ipPrefix.isV4())
711-
{
712-
m_syncdRoutes[ipPrefix] = IpAddresses("0.0.0.0");
713-
}
714-
else
715-
{
716-
m_syncdRoutes[ipPrefix] = IpAddresses("::");
717-
}
710+
m_syncdRoutes[ipPrefix] = IpAddresses();
718711

719-
/* Notify about default route next hop change. */
712+
/* Notify about default route next hop change */
720713
notifyNextHopChangeObservers(ipPrefix, m_syncdRoutes[ipPrefix], true);
721714
}
722715
else
723716
{
724717
m_syncdRoutes.erase(ipPrefix);
725-
notifyNextHopChangeObservers(ipPrefix, IpAddresses("0.0.0.0"), false);
718+
719+
/* Notify about the route next hop removal */
720+
notifyNextHopChangeObservers(ipPrefix, IpAddresses(), false);
726721
}
727722
return true;
728723
}

0 commit comments

Comments
 (0)