d/libnetwork: fix (*Controller).getLBIndex panics

Check the serviceBinding's deleted flag to guard against the service
getting deleted before we locked its mutex, which would make it futile
to look up the load balancers. And guard against dereferencing a nil
*loadBalancer in general.

Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Cory Snider
2026-01-29 18:14:56 -05:00
parent 6772371a2d
commit 21dd960a73

View File

@@ -160,9 +160,14 @@ func (c *Controller) getLBIndex(sid, nid string, ingressPorts []*PortConfig) int
}
s.Lock()
defer s.Unlock()
if s.deleted {
return 0
}
lb := s.loadBalancers[nid]
s.Unlock()
if lb == nil {
return 0
}
return int(lb.fwMark)
}