From 4b75a279696f7bab74d85832db65762d03922d87 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 7 Jul 2020 10:44:54 -0700 Subject: [PATCH] wgengine/monitor: fix crash on Linux on type 21 messages Fixes #532 --- wgengine/monitor/monitor.go | 7 +++++++ wgengine/monitor/monitor_freebsd.go | 6 ------ wgengine/monitor/monitor_linux.go | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/wgengine/monitor/monitor.go b/wgengine/monitor/monitor.go index 38cdbaa54..2fc503596 100644 --- a/wgengine/monitor/monitor.go +++ b/wgengine/monitor/monitor.go @@ -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 { diff --git a/wgengine/monitor/monitor_freebsd.go b/wgengine/monitor/monitor_freebsd.go index cb77ac095..832772f09 100644 --- a/wgengine/monitor/monitor_freebsd.go +++ b/wgengine/monitor/monitor_freebsd.go @@ -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 } diff --git a/wgengine/monitor/monitor_linux.go b/wgengine/monitor/monitor_linux.go index d67cac381..7368bdc88 100644 --- a/wgengine/monitor/monitor_linux.go +++ b/wgengine/monitor/monitor_linux.go @@ -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 } }