Skip to content

Commit

Permalink
mtu: fix possible race condition with enable-node-port config.
Browse files Browse the repository at this point in the history
The MTU cell relies on option.Config.NodePortEnabled which as
described in commit c2d65fe61a9231ee961097f894466727a2438768 is
prone to a race where the daemon changes this configuration at runtime.

This uses the newly introduced option.(*FinalDaemonConfig) type as a
parameter dependency to prevent such issues with MTU.

Signed-off-by: Tom Hadlaw <tom.hadlaw@isovalent.com>
  • Loading branch information
tommyp1ckles committed May 1, 2024
1 parent ea798df commit e77a166
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/mtu/cell.go
Expand Up @@ -33,6 +33,7 @@ type mtuParams struct {
IPsec types.IPsecKeyCustodian
CNI cni.CNIConfigManager
TunnelConfig tunnel.Config
Config *option.FinalDaemonConfig
}

func newForCell(lc cell.Lifecycle, p mtuParams) MTU {
Expand All @@ -57,7 +58,7 @@ func newForCell(lc cell.Lifecycle, p mtuParams) MTU {
option.Config.EnableIPSec,
p.TunnelConfig.ShouldAdaptMTU(),
option.Config.EnableWireguard,
option.Config.EnableHighScaleIPcache && option.Config.EnableNodePort,
option.Config.EnableHighScaleIPcache && p.Config.NodePortEnabled(),
configuredMTU,
externalIP,
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/option/config.go
Expand Up @@ -1358,7 +1358,8 @@ func LogRegisteredOptions(vp *viper.Viper, entry *logrus.Entry) {

// FinalDaemonConfig is a alias for DaemonConfig used to differentiate what stage of daemon option init
// the config is when it is provided.
// Any accessor functions on this type should be guarenteed
// Any accessor functions on this type should be guarenteed to be "final" within the scope of a hive

Check failure on line 1361 in pkg/option/config.go

View workflow job for this annotation

GitHub Actions / Lint Source Code

`guarenteed` is a misspelling of `guaranteed` (misspell)
// provider (i.e. values should not be modified later).
type FinalDaemonConfig DaemonConfig

func (c *FinalDaemonConfig) NodePortEnabled() bool {
Expand Down

0 comments on commit e77a166

Please sign in to comment.