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

Method TableInsertRoute

core/router.go:100–129  ·  view source on GitHub ↗
(prefix netip.Prefix, route state.SelRoute)

Source from the content-addressed store, hash-verified

98}
99
100func (n *Nylon) TableInsertRoute(prefix netip.Prefix, route state.SelRoute) {
101 nh := route.Nh
102 nf := n.router.ForwardTable.Load().Clone()
103 ne := n.router.ExitTable.Load().Clone()
104 if route.Metric == state.INF {
105 nf.Insert(prefix, RouteTableEntry{
106 Nh: nh,
107 Blackhole: true,
108 })
109 ne.Delete(prefix)
110 n.router.ForwardTable.Store(nf)
111 n.router.ExitTable.Store(ne)
112 return
113 }
114 peer := n.Device.LookupPeer(device.NoisePublicKey(n.GetNode(nh).PubKey))
115 nf.Insert(prefix, RouteTableEntry{
116 Nh: nh,
117 Peer: peer,
118 })
119 if route.Nh == n.LocalCfg.Id {
120 ne.Insert(prefix, RouteTableEntry{
121 Nh: nh,
122 Peer: peer,
123 })
124 } else {
125 ne.Delete(prefix)
126 }
127 n.router.ForwardTable.Store(nf)
128 n.router.ExitTable.Store(ne)
129}
130
131func (n *Nylon) TableDeleteRoute(prefix netip.Prefix) {
132 nf := n.router.ForwardTable.Load().Clone()

Callers

nothing calls this directly

Calls 6

NoisePublicKeyTypeAlias · 0.92
CloneMethod · 0.80
DeleteMethod · 0.80
LookupPeerMethod · 0.80
InsertMethod · 0.45
GetNodeMethod · 0.45

Tested by

no test coverage detected