summaryrefslogtreecommitdiffstats
path: root/proto/bgp/attrs.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-04-17 15:13:08 +0200
committerMartin Mares <mj@ucw.cz>2000-04-17 15:13:08 +0200
commitbd2d8190dd79645174beeef1a306c8df53db3b60 (patch)
tree022d1711ce692153a4683872dbe357c0a9b658be /proto/bgp/attrs.c
parent56a2bed46bf7713cd773b0fd0c097bcfc6345cc1 (diff)
downloadbird-bd2d8190dd79645174beeef1a306c8df53db3b60.tar
bird-bd2d8190dd79645174beeef1a306c8df53db3b60.zip
Honor standard communities (no_export, no_advertise, no_export_subconfed)
when exporting routes.
Diffstat (limited to 'proto/bgp/attrs.c')
-rw-r--r--proto/bgp/attrs.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c
index 22c73ca..03f8ed3 100644
--- a/proto/bgp/attrs.c
+++ b/proto/bgp/attrs.c
@@ -297,6 +297,42 @@ bgp_new_bucket(struct bgp_proto *p, ea_list *new, unsigned hash)
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 *old, ea_list *tmp, int originate)
{
@@ -375,10 +411,7 @@ bgp_get_bucket(struct bgp_proto *p, ea_list *old, ea_list *tmp, int originate)
return NULL;
}
- /* Check if next hop is valid */
- a = ea_find(new, EA_CODE(EAP_BGP, BA_NEXT_HOP));
- ASSERT(a);
- if (ipa_equal(p->next_hop, *(ip_addr *)a->u.ptr))
+ if (!bgp_export_check(p, new))
return NULL;
/* Create new bucket */