From d6f809f2b9c055168b9fcdc988b33b4daff8c840 Mon Sep 17 00:00:00 2001 From: Wenying Dong Date: Wed, 16 Oct 2024 13:23:39 -0700 Subject: [PATCH] [VM Agent] Fix agent crash issue with nil pointer exception (#6748) Set default value on config.Egress.SNATFullyRandomPorts with VM Agent scenario to avoid agent crash, although routeClient is not really consumed. Fixes #6747 Signed-off-by: Wenying Dong --- cmd/antrea-agent/options.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/antrea-agent/options.go b/cmd/antrea-agent/options.go index cd7c981f3ee..a091fdd7068 100644 --- a/cmd/antrea-agent/options.go +++ b/cmd/antrea-agent/options.go @@ -690,6 +690,10 @@ func (o *Options) setExternalNodeDefaultOptions() { if o.config.ExternalNode.ExternalNodeNamespace == "" { o.config.ExternalNode.ExternalNodeNamespace = "default" } + // Regardless of whether the egress feature is enabled, o.config.Egress.SNATFullyRandomPorts should not be nil to prevent a crash in NewClient(). + if o.config.Egress.SNATFullyRandomPorts == nil { + o.config.Egress.SNATFullyRandomPorts = ptr.To(o.config.SNATFullyRandomPorts) + } } func (o *Options) setMulticlusterDefaultOptions() {