Fixes a crash caused by missing error hook on BGP listening socket.

Error happened when too many BGP connections arrived in one moment
(ECONNABORTED).
This commit is contained in:
Ondrej Zajicek 2010-02-11 11:12:58 +01:00
parent fa5a99c766
commit 2af25a971a
2 changed files with 13 additions and 2 deletions

View file

@ -55,6 +55,8 @@
#undef LOCAL_DEBUG #undef LOCAL_DEBUG
#include <errno.h>
#include "nest/bird.h" #include "nest/bird.h"
#include "nest/iface.h" #include "nest/iface.h"
#include "nest/protocol.h" #include "nest/protocol.h"
@ -614,6 +616,15 @@ bgp_incoming_connection(sock *sk, int dummy UNUSED)
return 0; return 0;
} }
static void
bgp_listen_sock_err(sock *sk, int err)
{
if (err == ECONNABORTED)
log(L_WARN "BGP: Incoming connection aborted");
else
log(L_ERR "BGP: Error on incoming socket: %M", err);
}
static sock * static sock *
bgp_setup_listen_sk(ip_addr addr, unsigned port, u32 flags) bgp_setup_listen_sk(ip_addr addr, unsigned port, u32 flags)
{ {
@ -627,9 +638,10 @@ bgp_setup_listen_sk(ip_addr addr, unsigned port, u32 flags)
s->rbsize = BGP_RX_BUFFER_SIZE; s->rbsize = BGP_RX_BUFFER_SIZE;
s->tbsize = BGP_TX_BUFFER_SIZE; s->tbsize = BGP_TX_BUFFER_SIZE;
s->rx_hook = bgp_incoming_connection; s->rx_hook = bgp_incoming_connection;
s->err_hook = bgp_listen_sock_err;
if (sk_open(s)) if (sk_open(s))
{ {
log(L_ERR "Unable to open incoming BGP socket"); log(L_ERR "BGP: Unable to open incoming socket");
rfree(s); rfree(s);
return NULL; return NULL;
} }

View file

@ -947,7 +947,6 @@ sk_passive_connected(sock *s, struct sockaddr *sa, int al, int type)
} }
else if (errno != EINTR && errno != EAGAIN) else if (errno != EINTR && errno != EAGAIN)
{ {
log(L_ERR "accept: %m");
s->err_hook(s, errno); s->err_hook(s, errno);
} }
return 0; return 0;