Skip to content

Adding a DNAT rule to an Edge Gateway causes a segmentation fault #585

Open
@dlipovetsky

Description

@dlipovetsky

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/[email protected]/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/[email protected]/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

  1. 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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions