Skip to content

Commit b34f783

Browse files
authored
Resolve neighbor when nexthop does not exist (sonic-net#1704)
What I did Resolve neighbor entries if nexthop does not exist when adding routes. Why I did it In some scenarios, such as adding static routes, the nexthop may not be available, this PR would trigger an attempt to resolve the neighbor. Note that routeorch would only trigger resolution of a neighbor once even if it fails. The arp_update script would find the unresolved neighbor and retry neighbor resolution.
1 parent 500e2e9 commit b34f783

File tree

6 files changed

+368
-6
lines changed

6 files changed

+368
-6
lines changed

cfgmgr/nbrmgr.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,13 @@ void NbrMgr::doResolveNeighTask(Consumer &consumer)
234234
while (it != consumer.m_toSync.end())
235235
{
236236
KeyOpFieldsValuesTuple t = it->second;
237+
if (kfvOp(t) == DEL_COMMAND)
238+
{
239+
SWSS_LOG_INFO("Received DEL operation for %s, skipping", kfvKey(t).c_str());
240+
it = consumer.m_toSync.erase(it);
241+
continue;
242+
}
243+
237244
vector<string> keys = parseAliasIp(kfvKey(t), consumer.getConsumerTable()->getTableNameSeparator().c_str());
238245

239246
MacAddress mac;

orchagent/neighorch.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,25 @@ bool NeighOrch::resolveNeighborEntry(const NeighborEntry &entry, const MacAddres
7373
return true;
7474
}
7575

76+
void NeighOrch::resolveNeighbor(const NeighborEntry &entry)
77+
{
78+
if (m_neighborToResolve.find(entry) == m_neighborToResolve.end()) // TODO: Allow retry for unresolved neighbors
79+
{
80+
resolveNeighborEntry(entry, MacAddress());
81+
m_neighborToResolve.insert(entry);
82+
}
83+
84+
return;
85+
}
86+
87+
void NeighOrch::clearResolvedNeighborEntry(const NeighborEntry &entry)
88+
{
89+
string key, alias = entry.alias;
90+
key = alias + ":" + entry.ip_address.to_string();
91+
m_appNeighResolveProducer.del(key);
92+
return;
93+
}
94+
7695
/*
7796
* Function Name: processFDBFlushUpdate
7897
* Description:
@@ -214,6 +233,12 @@ bool NeighOrch::addNextHop(const IpAddress &ipAddress, const string &alias)
214233

215234
SWSS_LOG_NOTICE("Created next hop %s on %s",
216235
ipAddress.to_string().c_str(), alias.c_str());
236+
if (m_neighborToResolve.find(nexthop) != m_neighborToResolve.end())
237+
{
238+
clearResolvedNeighborEntry(nexthop);
239+
m_neighborToResolve.erase(nexthop);
240+
SWSS_LOG_INFO("Resolved neighbor for %s", nexthop.to_string().c_str());
241+
}
217242

218243
NextHopEntry next_hop_entry;
219244
next_hop_entry.next_hop_id = next_hop_id;

orchagent/neighorch.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class NeighOrch : public Orch, public Subject, public Observer
7474
bool addInbandNeighbor(string alias, IpAddress ip_address);
7575
bool delInbandNeighbor(string alias, IpAddress ip_address);
7676

77+
void resolveNeighbor(const NeighborEntry &);
78+
7779
private:
7880
PortsOrch *m_portsOrch;
7981
IntfsOrch *m_intfsOrch;
@@ -83,6 +85,8 @@ class NeighOrch : public Orch, public Subject, public Observer
8385
NeighborTable m_syncdNeighbors;
8486
NextHopTable m_syncdNextHops;
8587

88+
std::set<NextHopKey> m_neighborToResolve;
89+
8690
bool addNextHop(const IpAddress&, const string&);
8791
bool removeNextHop(const IpAddress&, const string&);
8892

@@ -93,7 +97,6 @@ class NeighOrch : public Orch, public Subject, public Observer
9397
bool clearNextHopFlag(const NextHopKey &, const uint32_t);
9498

9599
void processFDBFlushUpdate(const FdbFlushUpdate &);
96-
bool resolveNeighborEntry(const NeighborEntry &, const MacAddress &);
97100

98101
void doTask(Consumer &consumer);
99102
void doVoqSystemNeighTask(Consumer &consumer);
@@ -104,6 +107,9 @@ class NeighOrch : public Orch, public Subject, public Observer
104107
bool addVoqEncapIndex(string &alias, IpAddress &ip, vector<sai_attribute_t> &neighbor_attrs);
105108
void voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacAddress &mac, sai_neighbor_entry_t &neighbor_entry);
106109
void voqSyncDelNeigh(string &alias, IpAddress &ip_address);
110+
111+
bool resolveNeighborEntry(const NeighborEntry &, const MacAddress &);
112+
void clearResolvedNeighborEntry(const NeighborEntry &);
107113
};
108114

109115
#endif /* SWSS_NEIGHORCH_H */

orchagent/routeorch.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -1436,8 +1436,9 @@ bool RouteOrch::addRoute(RouteBulkContext& ctx, const NextHopGroupKey &nextHops)
14361436
}
14371437
else
14381438
{
1439-
SWSS_LOG_INFO("Failed to get next hop %s for %s",
1439+
SWSS_LOG_INFO("Failed to get next hop %s for %s, resolving neighbor",
14401440
nextHops.to_string().c_str(), ipPrefix.to_string().c_str());
1441+
m_neighOrch->resolveNeighbor(nexthop);
14411442
return false;
14421443
}
14431444
}
@@ -1484,8 +1485,15 @@ bool RouteOrch::addRoute(RouteBulkContext& ctx, const NextHopGroupKey &nextHops)
14841485
return false;
14851486
}
14861487
}
1488+
else
1489+
{
1490+
SWSS_LOG_INFO("Failed to get next hop %s in %s, resolving neighbor",
1491+
nextHop.to_string().c_str(), nextHops.to_string().c_str());
1492+
m_neighOrch->resolveNeighbor(nextHop);
1493+
}
14871494
}
14881495
}
1496+
14891497
/* Failed to create the next hop group and check if a temporary route is needed */
14901498

14911499
/* If the current next hop is part of the next hop group to sync,

0 commit comments

Comments
 (0)