From cae6edf485cada2afc4f1d6c83cd77ccae328334 Mon Sep 17 00:00:00 2001 From: Andrew Dunham Date: Thu, 21 Dec 2023 21:19:13 -0500 Subject: [PATCH] ipn/ipnlocal: fix data race with capForcedNetfilter field Updates #cleanup Signed-off-by: Andrew Dunham Change-Id: I1fdad454198d7ea4a898dbff3062818b0db35167 --- ipn/ipnlocal/local.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index fe17198c5..cc904b18e 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -4011,10 +4011,13 @@ func (b *LocalBackend) routerConfig(cfg *wgcfg.Config, prefs ipn.PrefsView, oneC singleRouteThreshold = 1 } - netfilterKind := b.capForcedNetfilter + b.mu.Lock() + netfilterKind := b.capForcedNetfilter // protected by b.mu + b.mu.Unlock() + if prefs.NetfilterKind() != "" { - if b.capForcedNetfilter != "" { - b.logf("nodeattr netfilter preference %s overridden by c2n pref %s", b.capForcedNetfilter, prefs.NetfilterKind()) + if netfilterKind != "" { + b.logf("nodeattr netfilter preference %s overridden by c2n pref %s", netfilterKind, prefs.NetfilterKind()) } netfilterKind = prefs.NetfilterKind() }