Skip to content
Snippets Groups Projects
Unverified Commit b6234b13 authored by takt's avatar takt Committed by GitHub
Browse files

RIS: Implement cleanup on BMP down event (#280)


* RIS: Implement cleanup on BMP down event

* Cleanup

Co-authored-by: default avatarMaximilian Wilhelm <max@sdn.clinic>
parent d8737e47
No related branches found
No related tags found
No related merge requests found
......@@ -104,6 +104,8 @@ func (r *Router) Address() net.IP {
}
func (r *Router) serve(con net.Conn) error {
defer r.cleanup()
r.con = con
r.runMu.Lock()
defer r.con.Close()
......@@ -125,6 +127,11 @@ func (r *Router) serve(con net.Conn) error {
}
}
func (r *Router) cleanup() {
r.vrfRegistry.UnregisterAll()
r.neighborManager.disposeAll()
}
func (r *Router) processMsg(msg []byte) {
bmpMsg, err := bmppkt.Decode(msg)
if err != nil {
......
......@@ -129,7 +129,7 @@ func (b *BMPServer) deleteRouter(addr net.IP) {
func (b *BMPServer) RemoveRouter(addr net.IP) {
id := addr.String()
r := b.routers[id]
r.stop <- struct{}{}
close(r.stop)
b.deleteRouter(addr)
}
......
......@@ -59,6 +59,16 @@ func (r *VRFRegistry) UnregisterVRF(v *VRF) {
delete(r.vrfs, v.routeDistinguisher)
}
// UnregisterAll unregisters all VRFs
func (r *VRFRegistry) UnregisterAll() {
r.mu.Lock()
defer r.mu.Unlock()
for id := range r.vrfs {
delete(r.vrfs, id)
}
}
func (r *VRFRegistry) List() []*VRF {
r.mu.Lock()
defer r.mu.Unlock()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment