wgengine/monitor: fix crash on Linux on type 21 messages

Fixes #532
This commit is contained in:
Brad Fitzpatrick 2020-07-07 10:44:54 -07:00
parent c1cabe75dc
commit 4b75a27969
3 changed files with 9 additions and 7 deletions

View File

@ -20,6 +20,13 @@ type message interface {
ignore() bool
}
// unspecifiedMessage is a minimal message implementation that should not
// be ignored. In general, OS-specific implementations should use better
// types and avoid this if they can.
type unspecifiedMessage struct{}
func (unspecifiedMessage) ignore() bool { return false }
// osMon is the interface that each operating system-specific
// implementation of the link monitor must implement.
type osMon interface {

View File

@ -48,9 +48,3 @@ func (c *devdConn) Receive() (message, error) {
return unspecifiedMessage{}, nil
}
}
// unspecifiedMessage is a minimal message implementation that should not
// be ignored. TODO: make specific messages like monitor_linux.go.
type unspecifiedMessage struct{}
func (unspecifiedMessage) ignore() bool { return false }

View File

@ -92,8 +92,9 @@ func (c *nlConn) Receive() (message, error) {
Gateway: netaddrIP(rmsg.Attributes.Gateway),
}, nil
default:
// TODO(bradfitz): parse type 21 too (https://github.com/tailscale/tailscale/issues/532)
c.logf("netlink msg %+v, %q", msg.Header, msg.Data)
return nil, nil
return unspecifiedMessage{}, nil
}
}