Skip to content

Commit 8c60787

Browse files
jipanyanglguohan
authored andcommitted
Don't add loopback ip2me route again if already configured (#656)
* Don't add loopback ip2me route again if already configured Signed-off-by: Jipan Yang <[email protected]> * Handle case of multiple ip/ipv6 addresses on lo interface Signed-off-by: Jipan Yang <[email protected]> * Empty check for lo interface data Signed-off-by: Jipan Yang <[email protected]> * TODO: handle case for which lo is not in default vrf gVirtualRouterId Signed-off-by: Jipan Yang <[email protected]>
1 parent 6eb1613 commit 8c60787

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

orchagent/intfsorch.cpp

+46-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,38 @@ void IntfsOrch::doTask(Consumer &consumer)
174174
{
175175
if (alias == "lo")
176176
{
177-
addIp2MeRoute(vrf_id, ip_prefix);
177+
if (!ip_prefix_in_key)
178+
{
179+
it = consumer.m_toSync.erase(it);
180+
continue;
181+
}
182+
183+
bool addIp2Me = false;
184+
// set request for lo may come after warm start restore.
185+
// It is also to prevent dupicate set requests in normal running case.
186+
auto it_intfs = m_syncdIntfses.find(alias);
187+
if (it_intfs == m_syncdIntfses.end())
188+
{
189+
IntfsEntry intfs_entry;
190+
191+
intfs_entry.ref_count = 0;
192+
intfs_entry.ip_addresses.insert(ip_prefix);
193+
m_syncdIntfses[alias] = intfs_entry;
194+
addIp2Me = true;
195+
}
196+
else
197+
{
198+
if (m_syncdIntfses[alias].ip_addresses.count(ip_prefix) == 0)
199+
{
200+
m_syncdIntfses[alias].ip_addresses.insert(ip_prefix);
201+
addIp2Me = true;
202+
}
203+
}
204+
if (addIp2Me)
205+
{
206+
addIp2MeRoute(vrf_id, ip_prefix);
207+
}
208+
178209
it = consumer.m_toSync.erase(it);
179210
continue;
180211
}
@@ -261,7 +292,20 @@ void IntfsOrch::doTask(Consumer &consumer)
261292
{
262293
if (alias == "lo")
263294
{
264-
removeIp2MeRoute(vrf_id, ip_prefix);
295+
// TODO: handle case for which lo is not in default vrf gVirtualRouterId
296+
if (m_syncdIntfses.find(alias) != m_syncdIntfses.end())
297+
{
298+
if (m_syncdIntfses[alias].ip_addresses.count(ip_prefix))
299+
{
300+
m_syncdIntfses[alias].ip_addresses.erase(ip_prefix);
301+
removeIp2MeRoute(vrf_id, ip_prefix);
302+
}
303+
if (m_syncdIntfses[alias].ip_addresses.size() == 0)
304+
{
305+
m_syncdIntfses.erase(alias);
306+
}
307+
}
308+
265309
it = consumer.m_toSync.erase(it);
266310
continue;
267311
}

0 commit comments

Comments
 (0)