mirror of
https://gitee.com/willfree/mlsr.git
synced 2026-06-03 15:56:13 +08:00
名称前缀表:移除表项
This commit is contained in:
@@ -117,6 +117,22 @@ func (t *NamePrefixTable) findNamePrefix(name *component.Identifier) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
//
|
||||
// deleteNamePrefix
|
||||
// @Description: 根据名称前缀的索引坐标,删除指定名称前缀
|
||||
// @receiver t
|
||||
// @param nameIndex
|
||||
//
|
||||
func (t *NamePrefixTable) deleteNamePrefix(nameIndex int) {
|
||||
var newList []*NamePrefixTableEntry
|
||||
for i := 0; i < len(t.nptEntryList); i++ {
|
||||
if i != nameIndex {
|
||||
newList = append(newList, t.nptEntryList[i])
|
||||
}
|
||||
}
|
||||
t.nptEntryList = newList
|
||||
}
|
||||
|
||||
//
|
||||
// AddEntry
|
||||
// @Description: 此方法将路由器添加到名称前缀表条目中。如果名称前缀表条目不存在,则会创建它。
|
||||
@@ -212,7 +228,50 @@ func (t *NamePrefixTable) AddEntry(name *component.Identifier, destRouter *compo
|
||||
// @param destRouter
|
||||
//
|
||||
func (t *NamePrefixTable) RemoveEntry(name *component.Identifier, destRouter *component.Identifier) {
|
||||
common2.LogDebug()
|
||||
common2.LogDebug("Removing origin: " + destRouter.ToUri() + " from " + name.ToUri())
|
||||
|
||||
// 根据目的路由器标识,获取其在路由条目缓存池中的条目
|
||||
rtpe, ok := t.m_rtpool[destRouter.ToUri()]
|
||||
if !ok {
|
||||
// 如果没有找到,则不进行后续处理
|
||||
common2.LogDebug("No entry for origin: " + destRouter.ToUri() +
|
||||
" found, so it cannot be removed from prefix: " + name.ToUri())
|
||||
return
|
||||
}
|
||||
|
||||
// 查找名称前缀
|
||||
nameIndex := t.findNamePrefix(name)
|
||||
if nameIndex >= 0 {
|
||||
common2.LogDebug("Removing origin: " + rtpe.GetDestination().ToUri() +
|
||||
" from prefix: " + name.ToUri())
|
||||
|
||||
// 判断该缓存表项在被删除一个与某前缀的关联之后,其使用数是否为零,如果是,则删除该引用。
|
||||
useCount := t.nptEntryList[nameIndex].RemoveRoutingTableEntry(rtpe)
|
||||
if useCount == 0 {
|
||||
t.DeleteRtpeFromPool(rtpe)
|
||||
}
|
||||
|
||||
// 1 如果前缀是路由器前缀,并且没有任何其他路由表条目,则已从LSDB中删除与该原始路由器关联的邻接/坐标LSA,
|
||||
// 因此应从名称前缀表中删除路由器前缀。
|
||||
// 2 如果前缀是播发的名称前缀:如果另一个路由器播发此名称前缀,
|
||||
// 则RteList应具有该路由器的另一个条目;下一个跃点应重新计算并安装在FIB中。
|
||||
// 3 如果没有其他路由器播发此名称前缀,则RteList应为空,并且可以从名称前缀表中删除前缀。
|
||||
// 一旦新名称LSA播发此前缀,将创建前缀的新条目。
|
||||
if t.nptEntryList[nameIndex].GetRteListSize() == 0 {
|
||||
common2.LogDebug(name.ToUri() + " has no routing table entries;" +
|
||||
" removing from table and FIB")
|
||||
t.deleteNamePrefix(nameIndex)
|
||||
// todo 删除fib中的该name m_fib.remove(name);
|
||||
} else {
|
||||
common2.LogDebug(name.ToUri() + " has other routing table entries;" +
|
||||
" updating FIB with next hops")
|
||||
t.nptEntryList[nameIndex].GenerateNhlfromRteList()
|
||||
// todo 更新fib m_fib.update(name, (*nameItr)->getNexthopList());
|
||||
}
|
||||
} else {
|
||||
common2.LogDebug("Attempted to remove origin: " + rtpe.GetDestination().ToUri() +
|
||||
" from non-existent prefix: " + name.ToUri())
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user