diff options
Diffstat (limited to 'proto/bgp/attrs.c')
-rw-r--r-- | proto/bgp/attrs.c | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index 7b49bdfa..5316481d 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -196,16 +196,8 @@ bgp_format_aggregator(eattr *a, byte *buf, int buflen UNUSED) byte *data = ad->data; u32 as; - if (bgp_as4_support) - { - as = get_u32(data); - data += 4; - } - else - { - as = get_u16(data); - data += 2; - } + as = get_u32(data); + data += 4; bsprintf(buf, "%d.%d.%d.%d AS%d", data[0], data[1], data[2], data[3], as); } @@ -279,9 +271,8 @@ static struct attr_desc bgp_attr_table[] = { NULL, NULL } }; -/* BA_AS4_PATH is type EAF_TYPE_OPAQUE and not type EAF_TYPE_AS_PATH because - * EAF_TYPE_AS_PATH is supposed to have different format (2 or 4 B for each ASN) - * depending on bgp_as4_support variable. +/* BA_AS4_PATH is type EAF_TYPE_OPAQUE and not type EAF_TYPE_AS_PATH. + * It does not matter as this attribute does not appear on routes in the routing table. */ #define ATTR_KNOWN(code) ((code) < ARRAY_SIZE(bgp_attr_table) && bgp_attr_table[code].name) @@ -449,7 +440,7 @@ bgp_encode_attrs(struct bgp_proto *p, byte *w, ea_list *attrs, int remains) * we have to convert our 4B AS_PATH to 2B AS_PATH and send our AS_PATH * as optional AS4_PATH attribute. */ - if ((code == BA_AS_PATH) && bgp_as4_support && (! p->as4_session)) + if ((code == BA_AS_PATH) && (! p->as4_session)) { len = a->u.ptr->length; @@ -491,7 +482,7 @@ bgp_encode_attrs(struct bgp_proto *p, byte *w, ea_list *attrs, int remains) } /* The same issue with AGGREGATOR attribute */ - if ((code == BA_AGGREGATOR) && bgp_as4_support && (! p->as4_session)) + if ((code == BA_AGGREGATOR) && (! p->as4_session)) { int new_used; @@ -864,25 +855,23 @@ bgp_create_attrs(struct bgp_proto *p, rte *e, ea_list **attrs, struct linpool *p bgp_set_attr_wa(ea->attrs+1, pool, BA_AS_PATH, 0); else { - z = bgp_set_attr_wa(ea->attrs+1, pool, BA_AS_PATH, bgp_as4_support ? 6 : 4); + z = bgp_set_attr_wa(ea->attrs+1, pool, BA_AS_PATH, 6); z[0] = AS_PATH_SEQUENCE; z[1] = 1; /* 1 AS */ - - if (bgp_as4_support) - put_u32(z+2, p->local_as); - else - put_u16(z+2, p->local_as); + put_u32(z+2, p->local_as); } z = bgp_set_attr_wa(ea->attrs+2, pool, BA_NEXT_HOP, NEXT_HOP_LENGTH); if (p->cf->next_hop_self || rta->dest != RTD_ROUTER || - (!p->is_internal && (e->attrs->iface != p->neigh->iface))) + ipa_equal(e->attrs->gw, IPA_NONE) || + ipa_has_link_scope(rta->gw) || + (!p->is_internal && (rta->iface != p->neigh->iface))) set_next_hop(z, p->source_addr); else - set_next_hop(z, e->attrs->gw); + set_next_hop(z, rta->gw); - bgp_set_attr(ea->attrs+3, BA_LOCAL_PREF, 0); + bgp_set_attr(ea->attrs+3, BA_LOCAL_PREF, p->cf->default_local_pref); return 0; /* Leave decision to the filters */ } @@ -1416,11 +1405,10 @@ bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct lin /* When receiving attributes from non-AS4-aware BGP speaker, * we have to reconstruct 4B AS_PATH and AGGREGATOR attributes */ - if (bgp_as4_support && (! bgp->as4_session)) + if (! bgp->as4_session) bgp_reconstruct_4b_atts(bgp, a, pool); - if (bgp_as4_support) - bgp_remove_as4_attrs(bgp, a); + bgp_remove_as4_attrs(bgp, a); /* If the AS path attribute contains our AS, reject the routes */ if (bgp_as_path_loopy(bgp, a)) @@ -1433,7 +1421,7 @@ bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct lin /* If there's no local preference, define one */ if (!(seen[0] & (1 << BA_LOCAL_PREF))) - bgp_attach_attr(&a->eattrs, pool, BA_LOCAL_PREF, 0); + bgp_attach_attr(&a->eattrs, pool, BA_LOCAL_PREF, bgp->cf->default_local_pref); return a; |