fix(ospf): показать конфликт состояний OSPF и BFD

This commit is contained in:
Denozordec committed 2026-10-11 22:42:14 +07:00
1 parent 4d3cb659c1
commit 12ead0b6c2
15 files changed
+6321 -18

No files matched your search

+15
View File
@@ -12,3 +12,18 @@ export function ospfNodeState(states: OspfNeighborState[]): "Full" | "2-Way" | "
if (states.some(state => state !== "Down")) return "Pending"
return "Down"
}
/** Correlate only a single observed direct BFD session on an explicitly configured interface. */
export function ospfBfdConflicts<T extends { localRouter: string; localIface: string; neighborAddress?: string; state: OspfNeighborState; dataUnknown?: boolean }>(
neighbors: T[],
interfaces: Array<{ serverId: string; interfaceName: string; useBfd?: boolean | null; active?: boolean | null; dataUnknown?: boolean }>,
sessions: Array<{ serverId: string; iface: string; remoteAddr: string; state: BfdState; multihop?: boolean | null; dataUnknown?: boolean }>,
): T[] {
const ip = (value: string) => value.split("%")[0]?.toLowerCase() ?? ""
return neighbors.filter(n => {
if (n.dataUnknown || n.state !== "Full" || !n.neighborAddress || !n.localIface) return false
if (!interfaces.some(i => !i.dataUnknown && i.active === true && i.useBfd === true && i.serverId === n.localRouter && i.interfaceName === n.localIface)) return false
const matching = sessions.filter(s => !s.dataUnknown && s.multihop === false && s.serverId === n.localRouter && s.iface === n.localIface && ip(s.remoteAddr) === ip(n.neighborAddress!))
return matching.length === 1 && (matching[0]!.state === "Down" || matching[0]!.state === "AdminDown")
})
}