work around fd re-use bug in vishvananda/netlink
Closing a subscription can cause the associated fd to be re-used while the subscription goroutine is also still trying to use it. Which can have disastrous consequences. So as a work around we don't close subscriptions. This means we leak an fd, some buffer space, and goroutine. The latter will eventually block in a channel send of a subscription event, since nothing is left reading ont the other end. So at least it won't be consuming cycles.
This commit is contained in:
1 parent
ec167554c5
commit
495a35a6a6
1 file changed
+5
-6
@@ -19,9 +19,10 @@ func EnsureInterface(ifaceName string) (*net.Interface, error) {
|
||||
|
||||
func ensureInterface(ifaceName string) (*net.Interface, error) {
|
||||
ch := make(chan netlink.LinkUpdate)
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
if err := netlink.LinkSubscribe(ch, done); err != nil {
|
||||
// NB: We do not supply (and eventually close) a 'done' channel
|
||||
// here since that can cause incorrect file descriptor
|
||||
// re-usage. See https://github.com/weaveworks/weave/issues/2120
|
||||
if err := netlink.LinkSubscribe(ch, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// check for currently-existing interface after subscribing, to avoid race
|
||||
@@ -46,9 +47,7 @@ func EnsureInterfaceAndMcastRoute(ifaceName string) (*net.Interface, error) {
|
||||
return nil, err
|
||||
}
|
||||
ch := make(chan netlink.RouteUpdate)
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
if err := netlink.RouteSubscribe(ch, done); err != nil {
|
||||
if err := netlink.RouteSubscribe(ch, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dest := net.IPv4(224, 0, 0, 0)
|
||||
|
||||
Reference in new issue
Block a user