MCPcopy Create free account
hub / github.com/encodeous/nylon / ComputeSysRouteTable

Method ComputeSysRouteTable

core/router.go:211–234  ·  view source on GitHub ↗

ComputeSysRouteTable computes: computed = prefixes - (((n.CentralCfg.ExcludeIPs U selected self prefixes) - n.LocalCfg.UnexcludeIPs) U n.LocalCfg.ExcludeIPs)

()

Source from the content-addressed store, hash-verified

209
210// ComputeSysRouteTable computes: computed = prefixes - (((n.CentralCfg.ExcludeIPs U selected self prefixes) - n.LocalCfg.UnexcludeIPs) U n.LocalCfg.ExcludeIPs)
211func (n *Nylon) ComputeSysRouteTable() []netip.Prefix {
212 prefixes := make([]netip.Prefix, 0)
213 selectedSelf := make([]netip.Prefix, 0)
214 for entry, v := range n.RouterState.Routes {
215 prefixes = append(prefixes, entry)
216 if v.Nh == n.LocalCfg.Id {
217 selectedSelf = append(selectedSelf, entry)
218 }
219 }
220
221 excludes := netipx.IPSetBuilder{}
222 excludes.AddSet(state.MakeSet(n.CentralCfg.ExcludeIPs))
223 excludes.AddSet(state.MakeSet(selectedSelf))
224 excludes.RemoveSet(state.MakeSet(n.LocalCfg.UnexcludeIPs))
225 excludes.AddSet(state.MakeSet(n.LocalCfg.ExcludeIPs))
226
227 final := netipx.IPSetBuilder{}
228 final.AddSet(state.MakeSet(prefixes))
229 res, _ := excludes.IPSet()
230 final.RemoveSet(res)
231
232 res, _ = final.IPSet()
233 return res.Prefixes()
234}
235
236func (n *Nylon) updatePassiveClient(prefix state.PrefixHealthWrapper, node state.NodeId, passiveHold bool) {
237 // inserts an artificial route into the table

Calls 1

MakeSetFunction · 0.92