If no NLRI's are present in an UPDATE message, parse the attributes, but
don't check presence of mandatory attributes. [draft-09]
This commit is contained in:
parent
f380aa60fa
commit
2a9e064d7b
3 changed files with 16 additions and 13 deletions
|
@ -676,7 +676,7 @@ bgp_path_loopy(struct bgp_proto *p, eattr *a)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct rta *
|
struct rta *
|
||||||
bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct linpool *pool)
|
bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct linpool *pool, int mandatory)
|
||||||
{
|
{
|
||||||
struct bgp_proto *bgp = conn->bgp;
|
struct bgp_proto *bgp = conn->bgp;
|
||||||
rta *a = lp_alloc(pool, sizeof(struct rta));
|
rta *a = lp_alloc(pool, sizeof(struct rta));
|
||||||
|
@ -800,6 +800,8 @@ bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct lin
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if all mandatory attributes are present */
|
/* Check if all mandatory attributes are present */
|
||||||
|
if (mandatory)
|
||||||
|
{
|
||||||
for(i=0; i < sizeof(bgp_mandatory_attrs)/sizeof(bgp_mandatory_attrs[0]); i++)
|
for(i=0; i < sizeof(bgp_mandatory_attrs)/sizeof(bgp_mandatory_attrs[0]); i++)
|
||||||
{
|
{
|
||||||
code = bgp_mandatory_attrs[i];
|
code = bgp_mandatory_attrs[i];
|
||||||
|
@ -809,6 +811,7 @@ bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct lin
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If the AS path attribute contains our AS, reject the routes */
|
/* If the AS path attribute contains our AS, reject the routes */
|
||||||
e = ea_find(a->eattrs, EA_CODE(EAP_BGP, BA_AS_PATH));
|
e = ea_find(a->eattrs, EA_CODE(EAP_BGP, BA_AS_PATH));
|
||||||
|
@ -831,7 +834,7 @@ bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct lin
|
||||||
neigh = neigh_find(&bgp->p, &nexthop, 0) ? : bgp->neigh;
|
neigh = neigh_find(&bgp->p, &nexthop, 0) ? : bgp->neigh;
|
||||||
a->gw = neigh->addr;
|
a->gw = neigh->addr;
|
||||||
a->iface = neigh->iface;
|
a->iface = neigh->iface;
|
||||||
return rta_lookup(a);
|
return a;
|
||||||
|
|
||||||
malformed:
|
malformed:
|
||||||
bgp_error(conn, 3, 1, len, 0);
|
bgp_error(conn, 3, 1, len, 0);
|
||||||
|
|
|
@ -94,7 +94,7 @@ void bgp_close_conn(struct bgp_conn *c);
|
||||||
|
|
||||||
/* attrs.c */
|
/* attrs.c */
|
||||||
|
|
||||||
struct rta *bgp_decode_attrs(struct bgp_conn *conn, byte *a, unsigned int len, struct linpool *pool);
|
struct rta *bgp_decode_attrs(struct bgp_conn *conn, byte *a, unsigned int len, struct linpool *pool, int mandatory);
|
||||||
int bgp_get_attr(struct eattr *e, byte *buf);
|
int bgp_get_attr(struct eattr *e, byte *buf);
|
||||||
int bgp_rte_better(struct rte *, struct rte *);
|
int bgp_rte_better(struct rte *, struct rte *);
|
||||||
void bgp_rt_notify(struct proto *, struct network *, struct rte *, struct rte *, struct ea_list *);
|
void bgp_rt_notify(struct proto *, struct network *, struct rte *, struct rte *, struct ea_list *);
|
||||||
|
|
|
@ -305,6 +305,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 *a0;
|
||||||
rta *a = NULL;
|
rta *a = NULL;
|
||||||
|
|
||||||
DBG("BGP: UPDATE\n");
|
DBG("BGP: UPDATE\n");
|
||||||
|
@ -341,11 +342,10 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, int len)
|
||||||
rte_update(bgp->p.table, n, &bgp->p, NULL);
|
rte_update(bgp->p.table, n, &bgp->p, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nlri_len)
|
a0 = bgp_decode_attrs(conn, attrs, attr_len, bgp_linpool, nlri_len);
|
||||||
|
if (a0 && nlri_len)
|
||||||
{
|
{
|
||||||
a = bgp_decode_attrs(conn, attrs, attr_len, bgp_linpool);
|
a = rta_lookup(a0);
|
||||||
if (!a)
|
|
||||||
return;
|
|
||||||
while (nlri_len)
|
while (nlri_len)
|
||||||
{
|
{
|
||||||
rte *e;
|
rte *e;
|
||||||
|
@ -357,9 +357,9 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, int len)
|
||||||
e->pflags = 0;
|
e->pflags = 0;
|
||||||
rte_update(bgp->p.table, n, &bgp->p, e);
|
rte_update(bgp->p.table, n, &bgp->p, e);
|
||||||
}
|
}
|
||||||
lp_flush(bgp_linpool);
|
|
||||||
rta_free(a);
|
rta_free(a);
|
||||||
}
|
}
|
||||||
|
lp_flush(bgp_linpool);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
malformed:
|
malformed:
|
||||||
|
|
Loading…
Reference in a new issue