mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 01:31:55 +00:00
The bgp_list is gone. Incomming connections are now handled in a much
more straightforward manner by scanning the active configuration for matching protocols.
This commit is contained in:
parent
5d86aefb6c
commit
93d6bf38a6
@ -22,7 +22,6 @@
|
|||||||
struct linpool *bgp_linpool; /* Global temporary pool */
|
struct linpool *bgp_linpool; /* Global temporary pool */
|
||||||
static sock *bgp_listen_sk; /* Global listening socket */
|
static sock *bgp_listen_sk; /* Global listening socket */
|
||||||
static int bgp_counter; /* Number of protocol instances using the listening socket */
|
static int bgp_counter; /* Number of protocol instances using the listening socket */
|
||||||
static list bgp_list; /* List of active BGP instances */
|
|
||||||
static char *bgp_state_names[] = { "Idle", "Connect", "Active", "OpenSent", "OpenConfirm", "Established" };
|
static char *bgp_state_names[] = { "Idle", "Connect", "Active", "OpenSent", "OpenConfirm", "Established" };
|
||||||
|
|
||||||
static void bgp_connect(struct bgp_proto *p);
|
static void bgp_connect(struct bgp_proto *p);
|
||||||
@ -32,7 +31,6 @@ static void bgp_setup_listen_sk(void);
|
|||||||
void
|
void
|
||||||
bgp_close(struct bgp_proto *p)
|
bgp_close(struct bgp_proto *p)
|
||||||
{
|
{
|
||||||
rem_node(&p->bgp_node);
|
|
||||||
ASSERT(bgp_counter);
|
ASSERT(bgp_counter);
|
||||||
bgp_counter--;
|
bgp_counter--;
|
||||||
if (!bgp_counter)
|
if (!bgp_counter)
|
||||||
@ -284,14 +282,19 @@ bgp_initiate(struct bgp_proto *p)
|
|||||||
static int
|
static int
|
||||||
bgp_incoming_connection(sock *sk, int dummy)
|
bgp_incoming_connection(sock *sk, int dummy)
|
||||||
{
|
{
|
||||||
|
struct proto_config *pc;
|
||||||
node *n;
|
node *n;
|
||||||
|
int match = 0;
|
||||||
|
|
||||||
DBG("BGP: Incoming connection from %I port %d\n", sk->daddr, sk->dport);
|
DBG("BGP: Incoming connection from %I port %d\n", sk->daddr, sk->dport);
|
||||||
WALK_LIST(n, bgp_list)
|
WALK_LIST(pc, config->protos)
|
||||||
|
if (pc->protocol == &proto_bgp && pc->proto)
|
||||||
{
|
{
|
||||||
struct bgp_proto *p = SKIP_BACK(struct bgp_proto, bgp_node, n);
|
struct bgp_proto *p = (struct bgp_proto *) pc->proto;
|
||||||
if (ipa_equal(p->cf->remote_ip, sk->daddr) &&
|
if (ipa_equal(p->cf->remote_ip, sk->daddr))
|
||||||
(p->p.proto_state == PS_START || p->p.proto_state == PS_UP))
|
{
|
||||||
|
match = 1;
|
||||||
|
if (p->p.proto_state == PS_START || p->p.proto_state == PS_UP)
|
||||||
{
|
{
|
||||||
BGP_TRACE(D_EVENTS, "Incoming connection from %I port %d", sk->daddr, sk->dport);
|
BGP_TRACE(D_EVENTS, "Incoming connection from %I port %d", sk->daddr, sk->dport);
|
||||||
if (p->incoming_conn.sk)
|
if (p->incoming_conn.sk)
|
||||||
@ -305,6 +308,8 @@ bgp_incoming_connection(sock *sk, int dummy)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!match)
|
||||||
log(L_AUTH "BGP: Unauthorized connect from %I port %d", sk->daddr, sk->dport);
|
log(L_AUTH "BGP: Unauthorized connect from %I port %d", sk->daddr, sk->dport);
|
||||||
rfree(sk);
|
rfree(sk);
|
||||||
return 0;
|
return 0;
|
||||||
@ -395,12 +400,10 @@ bgp_start(struct proto *P)
|
|||||||
p->incoming_conn.state = BS_IDLE;
|
p->incoming_conn.state = BS_IDLE;
|
||||||
p->startup_delay = 0;
|
p->startup_delay = 0;
|
||||||
|
|
||||||
if (!bgp_counter++)
|
bgp_counter++;
|
||||||
init_list(&bgp_list);
|
|
||||||
bgp_setup_listen_sk();
|
bgp_setup_listen_sk();
|
||||||
if (!bgp_linpool)
|
if (!bgp_linpool)
|
||||||
bgp_linpool = lp_new(&root_pool, 4080);
|
bgp_linpool = lp_new(&root_pool, 4080);
|
||||||
add_tail(&bgp_list, &p->bgp_node);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Before attempting to create the connection, we need to lock the
|
* Before attempting to create the connection, we need to lock the
|
||||||
|
@ -53,7 +53,6 @@ struct bgp_conn {
|
|||||||
struct bgp_proto {
|
struct bgp_proto {
|
||||||
struct proto p;
|
struct proto p;
|
||||||
struct bgp_config *cf; /* Shortcut to BGP configuration */
|
struct bgp_config *cf; /* Shortcut to BGP configuration */
|
||||||
node bgp_node; /* Node in global BGP protocol list */
|
|
||||||
unsigned local_as, remote_as;
|
unsigned local_as, remote_as;
|
||||||
int is_internal; /* Internal BGP connection (local_as == remote_as) */
|
int is_internal; /* Internal BGP connection (local_as == remote_as) */
|
||||||
u32 local_id; /* BGP identifier of this router */
|
u32 local_id; /* BGP identifier of this router */
|
||||||
|
Loading…
Reference in New Issue
Block a user