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

Fixes #532
pull/533/head
Brad Fitzpatrick 4 years ago
parent c1cabe75dc
commit 4b75a27969

@ -20,6 +20,13 @@ type message interface {
ignore() bool 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 // osMon is the interface that each operating system-specific
// implementation of the link monitor must implement. // implementation of the link monitor must implement.
type osMon interface { type osMon interface {

@ -48,9 +48,3 @@ func (c *devdConn) Receive() (message, error) {
return unspecifiedMessage{}, nil 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 }

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

Loading…
Cancel
Save