0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-08 20:28:43 +00:00

BGP now handles incoming routes (IPv4 only).

This commit is contained in:
Martin Mares 2000-04-01 09:17:33 +00:00
parent 8581061399
commit f880924990
3 changed files with 13 additions and 8 deletions

View File

@ -99,6 +99,7 @@ proto_item:
imexport: imexport:
FILTER filter { $$ = $2; } FILTER filter { $$ = $2; }
| where_filter
| ALL { $$ = FILTER_ACCEPT; } | ALL { $$ = FILTER_ACCEPT; }
| NONE { $$ = FILTER_REJECT; } | NONE { $$ = FILTER_REJECT; }
; ;

View File

@ -31,6 +31,7 @@ static void bgp_setup_sk(struct bgp_proto *p, struct bgp_conn *conn, sock *s);
static void static void
bgp_rt_notify(struct proto *P, net *n, rte *new, rte *old, ea_list *tmpa) bgp_rt_notify(struct proto *P, net *n, rte *new, rte *old, ea_list *tmpa)
{ {
DBG("BGP: Got route %I/%d\n", n->n.prefix, n->n.pxlen);
} }
static struct proto * static struct proto *

View File

@ -239,6 +239,7 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, int len)
int withdrawn_len, attr_len, nlri_len, pxlen; int withdrawn_len, attr_len, nlri_len, pxlen;
net *n; net *n;
rte e; rte e;
rta *a = NULL;
DBG("BGP: UPDATE\n"); DBG("BGP: UPDATE\n");
if (conn->state != BS_ESTABLISHED) if (conn->state != BS_ESTABLISHED)
@ -254,11 +255,7 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, int len)
withdrawn = pkt + 21; withdrawn = pkt + 21;
withdrawn_len = get_u16(pkt + 19); withdrawn_len = get_u16(pkt + 19);
if (withdrawn_len + 23 > len) if (withdrawn_len + 23 > len)
{ goto malformed;
malformed:
bgp_error(conn, 3, 1, len, 0);
return;
}
attrs = withdrawn + withdrawn_len + 2; attrs = withdrawn + withdrawn_len + 2;
attr_len = get_u16(attrs - 2); attr_len = get_u16(attrs - 2);
if (withdrawn_len + attr_len + 23 > len) if (withdrawn_len + attr_len + 23 > len)
@ -280,15 +277,15 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, int len)
if (nlri_len) if (nlri_len)
{ {
rta *a = bgp_decode_attrs(conn, attrs, attr_len, bgp_linpool); a = bgp_decode_attrs(conn, attrs, attr_len, bgp_linpool);
if (!a) if (!a)
return; return;
while (nlri_len) while (nlri_len)
{ {
rte *e; rte *e;
DECODE_PREFIX(nlri, nlri_len); /* FIXME: Uncache rta ! */ DECODE_PREFIX(nlri, nlri_len);
DBG("Add %I/%d\n", prefix, pxlen); DBG("Add %I/%d\n", prefix, pxlen);
e = rte_get_temp(a); e = rte_get_temp(rta_clone(a));
n = net_get(bgp->p.table, prefix, pxlen); n = net_get(bgp->p.table, prefix, pxlen);
e->net = n; e->net = n;
e->pflags = 0; e->pflags = 0;
@ -297,6 +294,12 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, int len)
lp_flush(bgp_linpool); lp_flush(bgp_linpool);
rta_free(a); rta_free(a);
} }
return;
malformed:
if (a)
rta_free(a);
bgp_error(conn, 3, 1, len, 0);
} }
static void static void