Skip to content

Commit

Permalink
fix(NRC): ensure local addr IP is bindable early
Browse files Browse the repository at this point in the history
  • Loading branch information
aauren committed Jan 23, 2023
1 parent bd0d00f commit 8183b18
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/controllers/routing/network_routes_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,13 @@ func NewNetworkRoutingController(clientset kubernetes.Interface,
if ip == nil {
klog.Fatalf("Invalid IP address %s specified in `kube-router.io/bgp-local-addresses`.", addr)
}
// Ensure that the IP address is able to bind on this host
if l, err := net.Listen("tcp", "["+addr+"]:0"); err == nil {
_ = l.Close()
} else {
klog.Fatalf("IP address %s specified in `kube-router.io/bgp-local-addresses` is not able to "+
"be bound on this host", addr)
}
}
nrc.localAddressList = append(nrc.localAddressList, localAddresses...)
}
Expand Down

0 comments on commit 8183b18

Please sign in to comment.