osrg / goplane

an agent for configuring linux network stack via GoBGP
http://osrg.github.io/gobgp/
119 stars 26 forks source link

Goplane panics when FSM state gets reaches Established #5

Closed nerdalert closed 8 years ago

nerdalert commented 8 years ago

Hi all! When running ./demo.py I get a nil pointer panic when the FSM state reaches Established. The workaround I used was to comment out a chunk of code in osrg/gobgp I listed below.

DEBU[0000] start sniff eth3
DEBU[0000] monitoring: eth3, index: 50                   Etag=20 Topic=VirtualNetwork
DEBU[0007] accepted a new passive connection from 192.168.10.2
DEBU[0007] state changed                                 Key=192.168.10.2 Topic=Peer new=BGP_FSM_OPENSENT old=BGP_FSM_ACTIVE
DEBU[0007] received                                      Key=192.168.10.2 Topic=Peer data=&{Header:{Marker:[] Len:51 Type:1} Body:0xc8203d8780}
DEBU[0007] state changed                                 Key=192.168.10.2 Topic=Peer new=BGP_FSM_OPENCONFIRM old=BGP_FSM_OPENSENT
INFO[0007] Peer Up                                       Key=192.168.10.2 State=BGP_FSM_OPENCONFIRM Topic=Peer
DEBU[0007] state changed                                 Key=192.168.10.2 Topic=Peer new=BGP_FSM_ESTABLISHED old=BGP_FSM_OPENCONFIRM
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x5100ae]

goroutine 24 [running]:
github.com/osrg/gobgp/server.(*BgpServer).handleFSMMessage(0xc8200edc00, 0xc820172680, 0xc8203bcba0, 0xc82005b8c0, 0x0, 0x0, 0x0)
    /home/brent/go/src/github.com/osrg/gobgp/server/server.go:799 +0x84e
github.com/osrg/gobgp/server.(*BgpServer).Serve(0xc8200edc00)
    /home/brent/go/src/github.com/osrg/gobgp/server/server.go:420 +0x3d21
created by main.main
    /home/brent/go/src/github.com/osrg/goplane/goplaned/main.go:152 +0x8ba

goroutine 1 [select]:
main.main()
    /home/brent/go/src/github.com/osrg/goplane/goplaned/main.go:164 +0x234f

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:1696 +0x1

goroutine 22 [select, locked to thread]:
runtime.gopark(0xc2b690, 0xc82001cf28, 0xaf7538, 0x6, 0x412418, 0x2)
    /usr/local/go/src/runtime/proc.go:185 +0x163
runtime.selectgoImpl(0xc82001cf28, 0x0, 0x18)
    /usr/local/go/src/runtime/select.go:392 +0xa64
runtime.selectgo(0xc82001cf28)
    /usr/local/go/src/runtime/select.go:212 +0x12
runtime.ensureSigM.func1()
    /usr/local/go/src/runtime/signal1_unix.go:227 +0x353
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:1696 +0x1

The workaround I found to avoid the nil reference was to comment out the following in osrg/gobgp in the file server.go. With that commented out the Goplane demo works. Not sure if there is anything that could be changed in Goplane to resolve the issue but figured it made sense to open it here since (de)/serializing EVPN seems to work great in osrg/gobgp

if ch := server.bmpClient.send(); ch != nil {
    bm := &broadcastBMPMsg{
        ch:      ch,
        msgList: []*bgp.BMPMessage{bmpPeerRoute(bgp.BMP_PEER_TYPE_GLOBAL, false, 0, peer.peerInfo, time.Now().Unix(), m)},
    }
    server.broadcastMsgs = append(server.broadcastMsgs, bm)
}

Thanks and let me know if I can provide any more information that can assist!

ishidawataru commented 8 years ago

Hi, Thanks for the report !

Think this fixes the issue https://github.com/osrg/goplane/commit/0e1099889a95397ec2b7b995bea219c6eda64eab