Support overlapping TG prefixes with longest-prefix-match routing

isSharedTG now finds the longest matching remote prefix and verifies
no other prefix in the mesh is more specific. Each TrunkLink receives
the full set of all prefixes at startup via setAllPrefixes().
initTrunkLinks is split into two passes: collect all prefixes first,
then create links with full knowledge.
This commit is contained in:
Audric committed 2026-03-26 10:55:47 +01:00
1 parent dda6ac5531
commit 53a9a6fc75
4 files changed
+60 -6

No files matched your search

+8 -1
View File
@@ -1994,14 +1994,16 @@ void Reflector::initTrunkLinks(void)
}
}
// First pass: collect all remote prefixes so we can do longest-prefix-match
std::vector<std::string> trunk_sections;
for (const auto& section : m_cfg->listSections())
{
if (section.substr(0, 6) != "TRUNK_")
{
continue;
}
trunk_sections.push_back(section);
// Collect remote prefixes for validation
std::string remote_prefix_str;
m_cfg->getValue(section, "REMOTE_PREFIX", remote_prefix_str);
{
@@ -2014,10 +2016,15 @@ void Reflector::initTrunkLinks(void)
if (!token.empty()) all_prefixes.push_back(token);
}
}
}
// Second pass: create trunk links with full prefix knowledge
for (const auto& section : trunk_sections)
{
auto* link = new TrunkLink(this, *m_cfg, section);
if (link->initialize())
{
link->setAllPrefixes(all_prefixes);
m_trunk_links.push_back(link);
}
else