Commit a34b0934 authored by Ondřej Zajíček's avatar Ondřej Zajíček

Disable BGP protocol when cannot open listening socket.

parent 9b061f7e
......@@ -97,6 +97,15 @@ bgp_open(struct bgp_proto *p)
if (!bgp_listen_sk)
bgp_listen_sk = bgp_setup_listen_sk(cfg->listen_bgp_addr, cfg->listen_bgp_port, cfg->listen_bgp_flags);
if (!bgp_listen_sk)
{
bgp_counter--;
p->p.disabled = 1;
bgp_store_error(p, NULL, BE_MISC, BEM_NO_SOCKET);
proto_notify_state(&p->p, PS_DOWN);
return -1;
}
if (!bgp_linpool)
bgp_linpool = lp_new(&root_pool, 4080);
......@@ -630,14 +639,14 @@ bgp_listen_sock_err(sock *sk UNUSED, int err)
if (err == ECONNABORTED)
log(L_WARN "BGP: Incoming connection aborted");
else
log(L_ERR "BGP: Error on incoming socket: %M", err);
log(L_ERR "BGP: Error on listening socket: %M", err);
}
static sock *
bgp_setup_listen_sk(ip_addr addr, unsigned port, u32 flags)
{
sock *s = sk_new(&root_pool);
DBG("BGP: Creating incoming socket\n");
DBG("BGP: Creating listening socket\n");
s->type = SK_TCP_PASSIVE;
s->saddr = addr;
s->sport = port ? port : BGP_PORT;
......@@ -649,7 +658,7 @@ bgp_setup_listen_sk(ip_addr addr, unsigned port, u32 flags)
s->err_hook = bgp_listen_sock_err;
if (sk_open(s))
{
log(L_ERR "BGP: Unable to open incoming socket");
log(L_ERR "BGP: Unable to open listening socket");
rfree(s);
return NULL;
}
......@@ -937,7 +946,7 @@ bgp_check(struct bgp_config *c)
static char *bgp_state_names[] = { "Idle", "Connect", "Active", "OpenSent", "OpenConfirm", "Established", "Close" };
static char *bgp_err_classes[] = { "", "Error: ", "Socket: ", "Received: ", "BGP Error: ", "Automatic shutdown: ", ""};
static char *bgp_misc_errors[] = { "", "Neighbor lost", "Invalid next hop", "Kernel MD5 auth failed" };
static char *bgp_misc_errors[] = { "", "Neighbor lost", "Invalid next hop", "Kernel MD5 auth failed", "No listening socket" };
static char *bgp_auto_errors[] = { "", "Route limit exceeded"};
static const char *
......
......@@ -275,6 +275,7 @@ void bgp_log_error(struct bgp_proto *p, u8 class, char *msg, unsigned code, unsi
#define BEM_NEIGHBOR_LOST 1
#define BEM_INVALID_NEXT_HOP 2
#define BEM_INVALID_MD5 3 /* MD5 authentication kernel request failed (possibly not supported) */
#define BEM_NO_SOCKET 4
/* Automatic shutdown error codes */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment