summaryrefslogtreecommitdiffstats
path: root/proto/bgp
diff options
context:
space:
mode:
Diffstat (limited to 'proto/bgp')
-rw-r--r--proto/bgp/attrs.c44
-rw-r--r--proto/bgp/bgp.c6
-rw-r--r--proto/bgp/bgp.h2
-rw-r--r--proto/bgp/config.Y3
4 files changed, 18 insertions, 37 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c
index 7b49bdf..5316481 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;
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index 24cd202..3cbcb6d 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -884,12 +884,6 @@ bgp_check(struct bgp_config *c)
if (!c->remote_as)
cf_error("Neighbor must be configured");
- if (!bgp_as4_support && c->enable_as4)
- cf_error("AS4 support disabled globally");
-
- if (!bgp_as4_support && (c->local_as > 0xFFFF))
- cf_error("Local AS number out of range");
-
if (!(c->capabilities && c->enable_as4) && (c->remote_as > 0xFFFF))
cf_error("Neighbor AS number out of range (AS4 not available)");
diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h
index 59ec9c1..7cbd655 100644
--- a/proto/bgp/bgp.h
+++ b/proto/bgp/bgp.h
@@ -132,8 +132,6 @@ struct bgp_bucket {
extern struct linpool *bgp_linpool;
-extern int bgp_as4_support;
-
void bgp_start_timer(struct timer *t, int value);
void bgp_check(struct bgp_config *c);
diff --git a/proto/bgp/config.Y b/proto/bgp/config.Y
index 3c73d60..b2061a1 100644
--- a/proto/bgp/config.Y
+++ b/proto/bgp/config.Y
@@ -41,9 +41,10 @@ bgp_proto_start: proto_start BGP {
BGP_CFG->error_delay_time_min = 60;
BGP_CFG->error_delay_time_max = 300;
BGP_CFG->enable_refresh = 1;
- BGP_CFG->enable_as4 = bgp_as4_support;
+ BGP_CFG->enable_as4 = 1;
BGP_CFG->capabilities = 2;
BGP_CFG->advertise_ipv4 = 1;
+ BGP_CFG->default_local_pref = 100;
}
;