static int
bgp_check_as_path(struct bgp_proto *p, byte *a, int len)
{
- return bgp_check_path(a, len, (bgp_as4_support && p->as4_support) ? 4 : 2, 11);
+ return bgp_check_path(a, len, p->as4_session ? 4 : 2, 11);
}
static int
bgp_check_as4_path(struct bgp_proto *p, byte *a, int len)
{
- if (bgp_as4_support && (! p->as4_support))
+ if (bgp_as4_support && (! p->as4_session))
return bgp_check_path(a, len, 4, 9);
else
return 0;
static int
bgp_check_aggregator(struct bgp_proto *p, UNUSED byte *a, int len)
{
- int exp_len = (bgp_as4_support && p->as4_support) ? 8 : 6;
+ int exp_len = p->as4_session ? 8 : 6;
return (len == exp_len) ? 0 : 5;
}
* 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_support))
+ if ((code == BA_AS_PATH) && bgp_as4_support && (! p->as4_session))
{
len = a->u.ptr->length;
}
/* The same issue with AGGREGATOR attribute */
- if ((code == BA_AGGREGATOR) && bgp_as4_support && (! p->as4_support))
+ if ((code == BA_AGGREGATOR) && bgp_as4_support && (! p->as4_session))
{
int new_used;
if ((fid == id1) || (fid == id2))
{
*el = (*el)->next;
- if (p->as4_support)
+ if (p->as4_session)
log(L_WARN "BGP: Unexpected AS4_* attributes received");
}
else
/* 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_support))
+ if (bgp_as4_support && (! bgp->as4_session))
bgp_reconstruct_4b_atts(bgp, a, pool);
if (bgp_as4_support)
cf_error("Local AS number must be set");
if (!c->remote_as)
cf_error("Neighbor must be configured");
- if (!bgp_as4_support && (c->local_as > 0xFFFF))
+ if (!bgp_as4_support && c->enable_as4)
+ cf_error("AS4 support disabled globbaly");
+ if (!c->enable_as4 && (c->local_as > 0xFFFF))
cf_error("Local AS number out of range");
- if (!bgp_as4_support && (c->remote_as > 0xFFFF))
+ if (!c->enable_as4 && (c->remote_as > 0xFFFF))
cf_error("Neighbor AS number out of range");
if ((c->local_as != c->remote_as) && (c->rr_client))
cf_error("Only internal neighbor can be RR client");
int compare_path_lengths; /* Use path lengths when selecting best route */
u32 default_local_pref; /* Default value for LOCAL_PREF attribute */
u32 default_med; /* Default value for MULTI_EXIT_DISC attribute */
+ int enable_as4; /* Enable local support for 4B AS numbers [RFC4893] */
u32 rr_cluster_id; /* Route reflector cluster ID, if different from local ID */
int rr_client; /* Whether neighbor is RR client of me */
unsigned connect_retry_time;
u32 local_as, remote_as;
int is_internal; /* Internal BGP connection (local_as == remote_as) */
int as4_support; /* Peer supports 4B AS numbers [RFC4893] */
+ int as4_session; /* Session uses 4B AS numbers in AS_PATH (both sides support it) */
u32 local_id; /* BGP identifier of this router */
u32 remote_id; /* BGP identifier of the neighbor */
u32 rr_cluster_id; /* Route reflector cluster ID */
CF_KEYWORDS(BGP, LOCAL, NEIGHBOR, AS, HOLD, TIME, CONNECT, RETRY, KEEPALIVE,
MULTIHOP, STARTUP, VIA, NEXT, HOP, SELF, DEFAULT, PATH, METRIC,
- ERROR, START, DELAY, FORGET, WAIT, DISABLE, AFTER,
+ ERROR, START, DELAY, FORGET, WAIT, ENABLE, DISABLE, AFTER,
BGP_PATH, BGP_LOCAL_PREF, BGP_MED, BGP_ORIGIN, BGP_NEXT_HOP,
BGP_ATOMIC_AGGR, BGP_AGGREGATOR, BGP_COMMUNITY, SOURCE, ADDRESS,
- PASSWORD, RR, CLIENT, CLUSTER, ID)
+ PASSWORD, RR, CLIENT, CLUSTER, ID, AS4)
CF_GRAMMAR
BGP_CFG->error_amnesia_time = 300;
BGP_CFG->error_delay_time_min = 60;
BGP_CFG->error_delay_time_max = 300;
+ BGP_CFG->enable_as4 = bgp_as4_support;
}
;
| bgp_proto ERROR FORGET TIME expr ';' { BGP_CFG->error_amnesia_time = $5; }
| bgp_proto ERROR WAIT TIME expr ',' expr ';' { BGP_CFG->error_delay_time_min = $5; BGP_CFG->error_delay_time_max = $7; }
| bgp_proto DISABLE AFTER ERROR bool ';' { BGP_CFG->disable_after_error = $5; }
+ | bgp_proto ENABLE AS4 bool ';' { BGP_CFG->enable_as4 = $4; }
| bgp_proto PASSWORD TEXT ';' { BGP_CFG->password = $3; }
;
#ifdef IPV6
cap = bgp_put_cap_ipv6(conn, cap);
#endif
- if (bgp_as4_support)
+ if (p->cf->enable_as4)
cap = bgp_put_cap_as4(conn, cap);
cap_len = cap - buf - 12;
if (cl != 4)
goto err;
p->as4_support = 1;
- if (bgp_as4_support)
+ p->as4_session = p->cf->enable_as4;
+ if (p->as4_session)
conn->advertised_as = get_u32(opt + 2);
break;