[Xorp-hackers] Fix for some bgp crashes (xorp.ct)

Ben Greear greearb at candelatech.com
Thu Apr 29 12:28:03 PDT 2010


While playing around with xorp-bgp and our network emulator, I killed the
connection between two bgp peers for 10 seconds and restarted the network.

xorp_bgp asserted and crashed.  One of the crashes is below..the other was similar.

This patch appears to fix things.  I've committed these to xorp.ct, but posting
here for review in case I've made a mistake.

[greearb at ben-dt2 xorp.ct]$ git diff bf465857d2000f76fa5268e058c3f3617a3c1ee1
diff --git a/bgp/socket.cc b/bgp/socket.cc
index c0152e2..4c08188 100644
--- a/bgp/socket.cc
+++ b/bgp/socket.cc
@@ -243,6 +243,10 @@ SocketClient::connected(XorpFd s)

      XLOG_ASSERT(!get_sock().is_valid());
      XLOG_ASSERT(!_connecting);
+    // Clean up any old reader/writers we might have around.
+    // This can happen if you kill network connection between two peers
+    // for 10 seconds and then re-start it.
+    async_remove();
      set_sock(s);
      async_add(s);
  }
@@ -562,7 +566,6 @@ SocketClient::connect_socket_complete(XorpFd sock, IoEventType type,
  void
  SocketClient::connect_socket_break()
  {
-    XLOG_ASSERT(_connecting);
      _connecting = false;

      eventloop().remove_ioevent_cb(get_sock());



#0  0x0000003b07c332f5 in *__GI_raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x0000003b07c34b20 in *__GI_abort () at abort.c:88
#2  0x00007fd5dc5fe6bd in xlog_fatal (module_name=0x7fd5ddfd1215 "BGP", line=<value optimized out>, file=<value optimized out>,
     function=<value optimized out>, fmt=0x7fd5dc61feac "Assertion (%s) failed") at libxorp/xlog.c:467
#3  0x00007fd5dc5fe75d in xlog_assert (module_name=0x4f62 <Address 0x4f62 out of bounds>, line=20322, file=0x6 <Address 0x6 out of bounds>,
     function=0xffffffffffffffff <Address 0xffffffffffffffff out of bounds>, failedexpr=<value optimized out>) at libxorp/xlog.c:480
#4  0x00007fd5ddfb5da2 in SocketClient::async_add (this=0x14937d0, sock=<value optimized out>) at bgp/socket.cc:577
#5  0x00007fd5ddfb5f05 in SocketClient::connected (this=0x14937d0, s=<value optimized out>) at bgp/socket.cc:247
#6  0x00007fd5ddf37da6 in BGPPeer::event_open (this=0x1494a10, sock=<value optimized out>) at bgp/peer.cc:1258
#7  0x00007fd5ddf384bf in AcceptSession::start (this=0x14d8ce0) at bgp/peer.cc:2293
#8  0x00007fd5ddf385cc in BGPPeer::connected (this=0x1494a10, sock=<value optimized out>) at bgp/peer.cc:1762
#9  0x00007fd5dded9a81 in BGPMain::connect_attempt (this=<value optimized out>, fd=<value optimized out>, type=<value optimized out>,
     laddr=<value optimized out>, lport=<value optimized out>) at bgp/bgp.cc:874
#10 0x00007fd5ddee12df in XorpMemberCallback2B2<void, BGPMain, XorpFd, IoEventType, std::string, unsigned short>::dispatch (this=0x14d9370,
     a1=<value optimized out>, a2=IOT_ACCEPT) at ./libxorp/callback_nodebug.hh:5226
#11 0x00007fd5dc61350d in SelectorList::Node::run_hooks (fd=<value optimized out>, m=<value optimized out>, this=<value optimized out>)
     at libxorp/selector.cc:198
#12 SelectorList::wait_and_dispatch (fd=<value optimized out>, m=<value optimized out>, this=<value optimized out>) at libxorp/selector.cc:533
#13 0x00007fd5dc602506 in EventLoop::do_work (this=0x7fff51e7e270, can_block=<value optimized out>) at libxorp/eventloop.cc:143
#14 0x00007fd5dc6025c8 in EventLoop::run (this=0x7fff51e7e270) at libxorp/eventloop.cc:96
#15 0x00007fd5dded8be5 in BGPMain::main_loop (this=0x7fff51e7e760) at bgp/bgp.cc:758
#16 0x00000000004015f8 in main (argv=0x7fff51e7ead8) at bgp/main.cc:93

Thanks,
Ben

-- 
Ben Greear <greearb at candelatech.com>
Candela Technologies Inc  http://www.candelatech.com



More information about the Xorp-hackers mailing list