capability and accepts such requests. Even when disabled, BIRD
can send route refresh requests. Default: on.
+ <tag>ignore communities <m/switch/</tag> RFC 1997 demands that
+ BGP speaker should process well-known communities like
+ no-export (65535, 65281) or no-advertise (65535, 65282). For
+ example, received route carrying a no-adverise community
+ should not be advertised to any of its neighbors. BIRD has
+ such behavior hardwired (it is evaluated when a route is
+ exported to the protocol just before the export filter). This
+ option allows to disable such hardwired processing of
+ well-known communities (in that case, similar behavior can be
+ implemented in the export filter). Default: off.
+
<tag>enable as4 <m/switch/</tag> BGP protocol was designed to use 2B AS numbers
and was extended later to allow 4B AS number. BIRD supports 4B AS extension,
but by disabling this option it can be persuaded not to advertise it and
return b;
}
-static int
-bgp_export_check(struct bgp_proto *p, ea_list *new)
-{
- eattr *a;
- struct adata *d;
-
- /* Check if next hop is valid */
- a = ea_find(new, EA_CODE(EAP_BGP, BA_NEXT_HOP));
- if (!a || ipa_equal(p->next_hop, *(ip_addr *)a->u.ptr))
- {
- DBG("\tInvalid NEXT_HOP\n");
- return 0;
- }
-
- /* Check if we aren't forbidden to export the route by communities */
- a = ea_find(new, EA_CODE(EAP_BGP, BA_COMMUNITY));
- if (a)
- {
- d = a->u.ptr;
- if (int_set_contains(d, BGP_COMM_NO_ADVERTISE))
- {
- DBG("\tNO_ADVERTISE\n");
- return 0;
- }
- if (!p->is_internal &&
- (int_set_contains(d, BGP_COMM_NO_EXPORT) ||
- int_set_contains(d, BGP_COMM_NO_EXPORT_SUBCONFED)))
- {
- DBG("\tNO_EXPORT\n");
- return 0;
- }
- }
-
- return 1;
-}
-
static struct bgp_bucket *
-bgp_get_bucket(struct bgp_proto *p, ea_list *attrs, int originate)
+bgp_get_bucket(struct bgp_proto *p, net *n, ea_list *attrs, int originate)
{
ea_list *new;
unsigned i, cnt, hash, code;
for(i=0; i<ARRAY_SIZE(bgp_mandatory_attrs); i++)
if (!(seen & (1 << bgp_mandatory_attrs[i])))
{
- log(L_ERR "%s: Mandatory attribute %s missing", p->p.name, bgp_attr_table[bgp_mandatory_attrs[i]].name);
+ log(L_ERR "%s: Mandatory attribute %s missing in route %I/%d", p->p.name, bgp_attr_table[bgp_mandatory_attrs[i]].name, n->n.prefix, n->n.pxlen);
return NULL;
}
- if (!bgp_export_check(p, new))
- return NULL;
+ /* Check if next hop is valid */
+ a = ea_find(new, EA_CODE(EAP_BGP, BA_NEXT_HOP));
+ if (!a || ipa_equal(p->next_hop, *(ip_addr *)a->u.ptr->data))
+ {
+ log(L_ERR "%s: Invalid NEXT_HOP attribute in route %I/%d", p->p.name, n->n.prefix, n->n.pxlen);
+ return NULL;
+ }
/* Create new bucket */
DBG("Creating bucket.\n");
if (new)
{
- buck = bgp_get_bucket(p, attrs, new->attrs->source != RTS_BGP);
+ buck = bgp_get_bucket(p, n, attrs, new->attrs->source != RTS_BGP);
if (!buck) /* Inconsistent attribute list */
return;
}
return 0; /* Leave decision to the filters */
}
+static int
+bgp_community_filter(struct bgp_proto *p, rte *e)
+{
+ eattr *a;
+ struct adata *d;
+
+ /* Check if we aren't forbidden to export the route by communities */
+ a = ea_find(e->attrs->eattrs, EA_CODE(EAP_BGP, BA_COMMUNITY));
+ if (a)
+ {
+ d = a->u.ptr;
+ if (int_set_contains(d, BGP_COMM_NO_ADVERTISE))
+ {
+ DBG("\tNO_ADVERTISE\n");
+ return 1;
+ }
+ if (!p->is_internal &&
+ (int_set_contains(d, BGP_COMM_NO_EXPORT) ||
+ int_set_contains(d, BGP_COMM_NO_EXPORT_SUBCONFED)))
+ {
+ DBG("\tNO_EXPORT\n");
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
int
bgp_import_control(struct proto *P, rte **new, ea_list **attrs, struct linpool *pool)
{
if (bgp_cluster_list_loopy(p, e->attrs))
return -1;
+ if (!p->cf->ignore_communities && bgp_community_filter(p, e))
+ return -1;
+
if (p->local_as == new_bgp->local_as && p->is_internal && new_bgp->is_internal)
{
/* Redistribution of internal routes with IBGP */
BGP_ATOMIC_AGGR, BGP_AGGREGATOR, BGP_COMMUNITY, SOURCE, ADDRESS,
PASSWORD, RR, RS, CLIENT, CLUSTER, ID, AS4, ADVERTISE, IPV4,
CAPABILITIES, LIMIT, PASSIVE, PREFER, OLDER, MISSING, LLADDR,
- DROP, IGNORE, ROUTE, REFRESH)
+ DROP, IGNORE, ROUTE, REFRESH, COMMUNITIES)
CF_GRAMMAR
| bgp_proto PASSWORD TEXT ';' { BGP_CFG->password = $3; }
| bgp_proto ROUTE LIMIT expr ';' { BGP_CFG->route_limit = $4; }
| bgp_proto PASSIVE bool ';' { BGP_CFG->passive = $3; }
+ | bgp_proto IGNORE COMMUNITIES bool ';' { BGP_CFG->ignore_communities = $4; }
;
CF_ADDTO(dynamic_attr, BGP_PATH