Describe the bug
I get a segmentation fault when adding a DNAT rule to an Edge Gateway.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x69cf45]
goroutine 1 [running]:
github.com/vmware/go-vcloud-director/v2/govcd.(*EdgeGateway).AddNATRuleAsync(0xc000017200, {{0x766b93, 0x4}, {0x0, 0x0}, {0x7687a5, 0xa}, {0x0, 0x0}, {0x7687b9, ...}, ...})
/go/pkg/mod/github.com/vmware/go-vcloud-director/v2@v2.20.0/govcd/edgegateway.go:474 +0x365
github.com/vmware/go-vcloud-director/v2/govcd.(*EdgeGateway).AddDNATRule(0xc000017200, {{0x766b93, 0x4}, {0x0, 0x0}, {0x7687a5, 0xa}, {0x0, 0x0}, {0x7687b9, ...}, ...})
/go/pkg/mod/github.com/vmware/go-vcloud-director/v2@v2.20.0/govcd/edgegateway.go:289 +0xc5
main.main()
main.go:102 +0x458
The root cause appears to be that the AddNATRuleAsync method assumes that EdgeGateway.Configuration.EdgeGatewayServiceConfiguration is not nil, and references its NatService field:
|
currentEdgeConfig := egw.EdgeGateway.Configuration.EdgeGatewayServiceConfiguration |
|
|
|
// Take care of the NAT service |
|
newNatService := &types.NatService{} |
|
|
|
if currentEdgeConfig.NatService == nil { |
.
Reproduction steps
- Add a DNAT rule using this API method
|
func (egw *EdgeGateway) AddDNATRule(ruleDetails NatRule) (*types.NatRule, error) { |
Expected behavior
A DNAT rule is added to the edge gateway.
Additional context
I have successfully created DNAT rules on the edge gateway using the UI.
VCD version: 10.4.1.21373066
go-vcloud-director version: v2.20.0
Describe the bug
I get a segmentation fault when adding a DNAT rule to an Edge Gateway.
The root cause appears to be that the
AddNATRuleAsyncmethod assumes thatEdgeGateway.Configuration.EdgeGatewayServiceConfigurationis notnil, and references itsNatServicefield:go-vcloud-director/govcd/edgegateway.go
Lines 469 to 474 in c3b8ae8
Reproduction steps
go-vcloud-director/govcd/edgegateway.go
Line 280 in c3b8ae8
Expected behavior
A DNAT rule is added to the edge gateway.
Additional context
I have successfully created DNAT rules on the edge gateway using the UI.
VCD version: 10.4.1.21373066
go-vcloud-director version: v2.20.0