contiv / ofnet

Ofnet is openflow networking library
Other
79 stars 73 forks source link

ofctrl/ofctrl.go: fixed a race condition where the AppInterface could be cleared while connections were still being handled #88

Closed dseevr closed 7 years ago

dseevr commented 7 years ago

This should fix the nil pointer dereferences we're occasionally seeing on CI. Example: https://contiv-ci.ngrok.io/job/Netplugin_CI/6902/console

Excerpt:

time="2017-04-11T22:31:55Z" level=info msg="New connection.." 
time="2017-04-11T22:31:55Z" level=info msg="Received Openflow 1.3 Hello message" 
time="2017-04-11T22:31:55Z" level=info msg="Removed uplink uplinkPort([eth2 eth3]) from OVS switch contivVlanBridge." 
time="2017-04-11T22:31:55Z" level=info msg="OfnetAgent: Received Delete" 
time="2017-04-11T22:31:55Z" level=info msg="Received ofp1.3 Switch feature response: {Header:{Version:4 Type:6 Length:32 Xid:434} DPID:00:00:ee:81:a2:88:b1:40 Buffers:256 NumTables:254 AuxilaryId:0 pad:[0 0] Capabilities:79 Actions:0 Ports:[]}" 
time="2017-04-11T22:31:55Z" level=info msg="Openflow Connection for new switch: 00:00:ee:81:a2:88:b1:40" 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x69767a]

goroutine 2001 [running]:
panic(0xe17200, 0xc420012140)
    /usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/contiv/netplugin/vendor/github.com/contiv/ofnet/ofctrl.(*OFSwitch).switchConnected(0xc4208a0f00)
    /opt/gopath/src/github.com/contiv/netplugin/vendor/github.com/contiv/ofnet/ofctrl/ofSwitch.go:110 +0x2a
github.com/contiv/netplugin/vendor/github.com/contiv/ofnet/ofctrl.NewSwitch(0xc4207b8050, 0xc420458c40, 0x8, 0x8, 0x0, 0x0, 0xc4207bf290)
    /opt/gopath/src/github.com/contiv/netplugin/vendor/github.com/contiv/ofnet/ofctrl/ofSwitch.go:78 +0x224
github.com/contiv/netplugin/vendor/github.com/contiv/ofnet/ofctrl.(*Controller).handleConnection(0xc4208f1b40, 0x16992a0, 0xc4201229c0)
    /opt/gopath/src/github.com/contiv/netplugin/vendor/github.com/contiv/ofnet/ofctrl/ofctrl.go:148 +0x409
created by github.com/contiv/netplugin/vendor/github.com/contiv/ofnet/ofctrl.(*Controller).Listen
    /opt/gopath/src/github.com/contiv/netplugin/vendor/github.com/contiv/ofnet/ofctrl/ofctrl.go:93 +0x23b
exit status 2
jojimt commented 7 years ago

Good catch @dseevr