]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: Fix handling of transitive extended communities
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Thu, 24 Oct 2019 15:47:45 +0000 (17:47 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Thu, 24 Oct 2019 15:50:19 +0000 (17:50 +0200)
Transitive extended communities should be removed on external sessions,
the old code them in all cases.

Thanks to Jean-Daniel Pauget for the original patch.

proto/bgp/attrs.c

index b892136387f4752425dc7811107f06c74e3ad0e5..9a4e12d2ead3ed4322cd1616722fc3cd5aa7295e 100644 (file)
@@ -717,13 +717,23 @@ bgp_decode_mp_unreach_nlri(struct bgp_parse_state *s, uint code UNUSED, uint fla
 static void
 bgp_export_ext_community(struct bgp_export_state *s, eattr *a)
 {
-  struct adata *ad = ec_set_del_nontrans(s->pool, a->u.ptr);
+  if (!s->proto->is_interior)
+  {
+    struct adata *ad = ec_set_del_nontrans(s->pool, a->u.ptr);
 
-  if (ad->length == 0)
-    UNSET(a);
+    if (ad->length == 0)
+      UNSET(a);
 
-  ec_set_sort_x(ad);
-  a->u.ptr = ad;
+    ec_set_sort_x(ad);
+    a->u.ptr = ad;
+  }
+  else
+  {
+    if (a->u.ptr->length == 0)
+      UNSET(a);
+
+    a->u.ptr = ec_set_sort(s->pool, a->u.ptr);
+  }
 }
 
 static void