Date created: Monday, October 14, 2024 5:33:18 PM. Last modified: Wednesday, December 11, 2024 5:44:54 PM

Example BIRD Config - Outbound filter to add communities

How many BGP communities can a single BGP update hold?

The maximum size of a BGP UPDATE message is 4096 bytes. Standard / extended / large communities all take up different amounts of space in the UPDATE message. Also 2 byte and 4 byte ASNs make two communities of the same type (e.g. large communities) take up more or less space. So the exact number depends on the type of community and length of the ASNs in the community.

Below an Arista router running EOS 4.31.2F has accepted a BGP route with 253 large BGP communities attached:

lab#show bgp ipv4 unicast 10.0.0.126/32 detail vrf TEST
BGP routing table information for VRF DFZ
Router identifier 192.16.107.5, local AS number 65535
BGP routing table entry for 10.0.0.126/32
 Paths: 1 available
  64600
    192.16.107.19 from 192.16.107.19 (192.16.107.19)
      Origin IGP, metric 0, localpref 100, IGP metric 0, weight 0, tag 0
      Received 00:00:05 ago, valid, external, best, AS Origin not found
      Large Community: 64497:1:0 64497:1:1 64497:1:2 64497:1:3 64497:1:4 64497:1:5 64497:1:6 64497:1:7 64497:1:8 64497:1:9 64497:1:10 64497:1:11 64497:1:12 64497:1:13 64497:1:14 64497:1:15 64497:1:16 64497:1:17 64497:1:18 64497:1:19 64497:1:20 64497:1:21 64497:1:22 64497:1:23 64497:1:24 64497:1:25 64497:1:26 64497:1:27 64497:1:28 64497:1:29 64497:1:30 64497:1:31 64497:1:32 64497:1:33 64497:1:34 64497:1:35 64497:1:36 64497:1:37 64497:1:38 64497:1:39 64497:1:40 64497:1:41 64497:1:42 64497:1:43 64497:1:44 64497:1:45 64497:1:46 64497:1:47 64497:1:48 64497:1:49 64497:1:50 64497:1:51 64497:1:52 64497:1:53 64497:1:54 64497:1:55 64497:1:56 64497:1:57 64497:1:58 64497:1:59 64497:1:60 64497:1:61 64497:1:62 64497:1:63 64497:1:64 64497:1:65 64497:1:66 64497:1:67 64497:1:68 64497:1:69 64497:1:70 64497:1:71 64497:1:72 64497:1:73 64497:1:74 64497:1:75 64497:1:76 64497:1:77 64497:1:78 64497:1:79 64497:1:80 64497:1:81 64497:1:82 64497:1:83 64497:1:84 64497:1:85 64497:1:86 64497:1:87 64497:1:88 64497:1:89 64497:1:90 64497:1:91 64497:1:92 64497:1:93 64497:1:94 64497:1:95 64497:1:96 64497:1:97 64497:1:98 64497:1:99 64497:1:100 64497:1:101 64497:1:102 64497:1:103 64497:1:104 64497:1:105 64497:1:106 64497:1:107 64497:1:108 64497:1:109 64497:1:110 64497:1:111 64497:1:112 64497:1:113 64497:1:114 64497:1:115 64497:1:116 64497:1:117 64497:1:118 64497:1:119 64497:1:120 64497:1:121 64497:1:122 64497:1:123 64497:1:124 64497:1:125 64497:1:126 64497:1:127 64497:1:128 64497:1:129 64497:1:130 64497:1:131 64497:1:132 64497:1:133 64497:1:134 64497:1:135 64497:1:136 64497:1:137 64497:1:138 64497:1:139 64497:1:140 64497:1:141 64497:1:142 64497:1:143 64497:1:144 64497:1:145 64497:1:146 64497:1:147 64497:1:148 64497:1:149 64497:1:150 64497:1:151 64497:1:152 64497:1:153 64497:1:154 64497:1:155 64497:1:156 64497:1:157 64497:1:158 64497:1:159 64497:1:160 64497:1:161 64497:1:162 64497:1:163 64497:1:164 64497:1:165 64497:1:166 64497:1:167 64497:1:168 64497:1:169 64497:1:170 64497:1:171 64497:1:172 64497:1:173 64497:1:174 64497:1:175 64497:1:176 64497:1:177 64497:1:178 64497:1:179 64497:1:180 64497:1:181 64497:1:182 64497:1:183 64497:1:184 64497:1:185 64497:1:186 64497:1:187 64497:1:188 64497:1:189 64497:1:190 64497:1:191 64497:1:192 64497:1:193 64497:1:194 64497:1:195 64497:1:196 64497:1:197 64497:1:198 64497:1:199 64497:1:200 64497:1:201 64497:1:202 64497:1:203 64497:1:204 64497:1:205 64497:1:206 64497:1:207 64497:1:208 64497:1:209 64497:1:210 64497:1:211 64497:1:212 64497:1:213 64497:1:214 64497:1:215 64497:1:216 64497:1:217 64497:1:218 64497:1:219 64497:1:220 64497:1:221 64497:1:222 64497:1:223 64497:1:224 64497:1:225 64497:1:226 64497:1:227 64497:1:228 64497:1:229 64497:1:230 64497:1:231 64497:1:232 64497:1:233 64497:1:234 64497:1:235 64497:1:236 64497:1:237 64497:1:238 64497:1:239 64497:1:240 64497:1:241 64497:1:242 64497:1:243 64497:1:244 64497:1:245 64497:1:246 64497:1:247 64497:1:248 64497:1:249 64497:1:250 64497:1:251 64497:1:252
      Rx SAFI: Unicast
 Not advertised to any peer.

Below is the BIRD configuration which generated this route:

log stderr all;
log syslog all;
debug protocols all;

router id 192.16.107.19;

protocol device {
}

filter add_large {
    bgp_large_community.add((64497,1,0));
    bgp_large_community.add((64497,1,1));
    bgp_large_community.add((64497,1,2));
    bgp_large_community.add((64497,1,3));
    bgp_large_community.add((64497,1,4));
    bgp_large_community.add((64497,1,5));
    bgp_large_community.add((64497,1,6));
    bgp_large_community.add((64497,1,7));
    bgp_large_community.add((64497,1,8));
    bgp_large_community.add((64497,1,9));
    bgp_large_community.add((64497,1,10));
    bgp_large_community.add((64497,1,11));
    bgp_large_community.add((64497,1,12));
    bgp_large_community.add((64497,1,13));
    bgp_large_community.add((64497,1,14));
    bgp_large_community.add((64497,1,15));
    bgp_large_community.add((64497,1,16));
    bgp_large_community.add((64497,1,17));
    bgp_large_community.add((64497,1,18));
    bgp_large_community.add((64497,1,19));
    bgp_large_community.add((64497,1,20));
    bgp_large_community.add((64497,1,21));
    bgp_large_community.add((64497,1,22));
    bgp_large_community.add((64497,1,23));
    bgp_large_community.add((64497,1,24));
    bgp_large_community.add((64497,1,25));
    bgp_large_community.add((64497,1,26));
    bgp_large_community.add((64497,1,27));
    bgp_large_community.add((64497,1,28));
    bgp_large_community.add((64497,1,29));
    bgp_large_community.add((64497,1,30));
    bgp_large_community.add((64497,1,31));
    bgp_large_community.add((64497,1,32));
    bgp_large_community.add((64497,1,33));
    bgp_large_community.add((64497,1,34));
    bgp_large_community.add((64497,1,35));
    bgp_large_community.add((64497,1,36));
    bgp_large_community.add((64497,1,37));
    bgp_large_community.add((64497,1,38));
    bgp_large_community.add((64497,1,39));
    bgp_large_community.add((64497,1,40));
    bgp_large_community.add((64497,1,41));
    bgp_large_community.add((64497,1,42));
    bgp_large_community.add((64497,1,43));
    bgp_large_community.add((64497,1,44));
    bgp_large_community.add((64497,1,45));
    bgp_large_community.add((64497,1,46));
    bgp_large_community.add((64497,1,47));
    bgp_large_community.add((64497,1,48));
    bgp_large_community.add((64497,1,49));
    bgp_large_community.add((64497,1,50));
    bgp_large_community.add((64497,1,51));
    bgp_large_community.add((64497,1,52));
    bgp_large_community.add((64497,1,53));
    bgp_large_community.add((64497,1,54));
    bgp_large_community.add((64497,1,55));
    bgp_large_community.add((64497,1,56));
    bgp_large_community.add((64497,1,57));
    bgp_large_community.add((64497,1,58));
    bgp_large_community.add((64497,1,59));
    bgp_large_community.add((64497,1,60));
    bgp_large_community.add((64497,1,61));
    bgp_large_community.add((64497,1,62));
    bgp_large_community.add((64497,1,63));
    bgp_large_community.add((64497,1,64));
    bgp_large_community.add((64497,1,65));
    bgp_large_community.add((64497,1,66));
    bgp_large_community.add((64497,1,67));
    bgp_large_community.add((64497,1,68));
    bgp_large_community.add((64497,1,69));
    bgp_large_community.add((64497,1,70));
    bgp_large_community.add((64497,1,71));
    bgp_large_community.add((64497,1,72));
    bgp_large_community.add((64497,1,73));
    bgp_large_community.add((64497,1,74));
    bgp_large_community.add((64497,1,75));
    bgp_large_community.add((64497,1,76));
    bgp_large_community.add((64497,1,77));
    bgp_large_community.add((64497,1,78));
    bgp_large_community.add((64497,1,79));
    bgp_large_community.add((64497,1,80));
    bgp_large_community.add((64497,1,81));
    bgp_large_community.add((64497,1,82));
    bgp_large_community.add((64497,1,83));
    bgp_large_community.add((64497,1,84));
    bgp_large_community.add((64497,1,85));
    bgp_large_community.add((64497,1,86));
    bgp_large_community.add((64497,1,87));
    bgp_large_community.add((64497,1,88));
    bgp_large_community.add((64497,1,89));
    bgp_large_community.add((64497,1,90));
    bgp_large_community.add((64497,1,91));
    bgp_large_community.add((64497,1,92));
    bgp_large_community.add((64497,1,93));
    bgp_large_community.add((64497,1,94));
    bgp_large_community.add((64497,1,95));
    bgp_large_community.add((64497,1,96));
    bgp_large_community.add((64497,1,97));
    bgp_large_community.add((64497,1,98));
    bgp_large_community.add((64497,1,99));
    bgp_large_community.add((64497,1,100));
    bgp_large_community.add((64497,1,101));
    bgp_large_community.add((64497,1,102));
    bgp_large_community.add((64497,1,103));
    bgp_large_community.add((64497,1,104));
    bgp_large_community.add((64497,1,105));
    bgp_large_community.add((64497,1,106));
    bgp_large_community.add((64497,1,107));
    bgp_large_community.add((64497,1,108));
    bgp_large_community.add((64497,1,109));
    bgp_large_community.add((64497,1,110));
    bgp_large_community.add((64497,1,111));
    bgp_large_community.add((64497,1,112));
    bgp_large_community.add((64497,1,113));
    bgp_large_community.add((64497,1,114));
    bgp_large_community.add((64497,1,115));
    bgp_large_community.add((64497,1,116));
    bgp_large_community.add((64497,1,117));
    bgp_large_community.add((64497,1,118));
    bgp_large_community.add((64497,1,119));
    bgp_large_community.add((64497,1,120));
    bgp_large_community.add((64497,1,121));
    bgp_large_community.add((64497,1,122));
    bgp_large_community.add((64497,1,123));
    bgp_large_community.add((64497,1,124));
    bgp_large_community.add((64497,1,125));
    bgp_large_community.add((64497,1,126));
    bgp_large_community.add((64497,1,127));
    bgp_large_community.add((64497,1,128));
    bgp_large_community.add((64497,1,129));
    bgp_large_community.add((64497,1,130));
    bgp_large_community.add((64497,1,131));
    bgp_large_community.add((64497,1,132));
    bgp_large_community.add((64497,1,133));
    bgp_large_community.add((64497,1,134));
    bgp_large_community.add((64497,1,135));
    bgp_large_community.add((64497,1,136));
    bgp_large_community.add((64497,1,137));
    bgp_large_community.add((64497,1,138));
    bgp_large_community.add((64497,1,139));
    bgp_large_community.add((64497,1,140));
    bgp_large_community.add((64497,1,141));
    bgp_large_community.add((64497,1,142));
    bgp_large_community.add((64497,1,143));
    bgp_large_community.add((64497,1,144));
    bgp_large_community.add((64497,1,145));
    bgp_large_community.add((64497,1,146));
    bgp_large_community.add((64497,1,147));
    bgp_large_community.add((64497,1,148));
    bgp_large_community.add((64497,1,149));
    bgp_large_community.add((64497,1,150));
    bgp_large_community.add((64497,1,151));
    bgp_large_community.add((64497,1,152));
    bgp_large_community.add((64497,1,153));
    bgp_large_community.add((64497,1,154));
    bgp_large_community.add((64497,1,155));
    bgp_large_community.add((64497,1,156));
    bgp_large_community.add((64497,1,157));
    bgp_large_community.add((64497,1,158));
    bgp_large_community.add((64497,1,159));
    bgp_large_community.add((64497,1,160));
    bgp_large_community.add((64497,1,161));
    bgp_large_community.add((64497,1,162));
    bgp_large_community.add((64497,1,163));
    bgp_large_community.add((64497,1,164));
    bgp_large_community.add((64497,1,165));
    bgp_large_community.add((64497,1,166));
    bgp_large_community.add((64497,1,167));
    bgp_large_community.add((64497,1,168));
    bgp_large_community.add((64497,1,169));
    bgp_large_community.add((64497,1,170));
    bgp_large_community.add((64497,1,171));
    bgp_large_community.add((64497,1,172));
    bgp_large_community.add((64497,1,173));
    bgp_large_community.add((64497,1,174));
    bgp_large_community.add((64497,1,175));
    bgp_large_community.add((64497,1,176));
    bgp_large_community.add((64497,1,177));
    bgp_large_community.add((64497,1,178));
    bgp_large_community.add((64497,1,179));
    bgp_large_community.add((64497,1,180));
    bgp_large_community.add((64497,1,181));
    bgp_large_community.add((64497,1,182));
    bgp_large_community.add((64497,1,183));
    bgp_large_community.add((64497,1,184));
    bgp_large_community.add((64497,1,185));
    bgp_large_community.add((64497,1,186));
    bgp_large_community.add((64497,1,187));
    bgp_large_community.add((64497,1,188));
    bgp_large_community.add((64497,1,189));
    bgp_large_community.add((64497,1,190));
    bgp_large_community.add((64497,1,191));
    bgp_large_community.add((64497,1,192));
    bgp_large_community.add((64497,1,193));
    bgp_large_community.add((64497,1,194));
    bgp_large_community.add((64497,1,195));
    bgp_large_community.add((64497,1,196));
    bgp_large_community.add((64497,1,197));
    bgp_large_community.add((64497,1,198));
    bgp_large_community.add((64497,1,199));
    bgp_large_community.add((64497,1,200));
    bgp_large_community.add((64497,1,201));
    bgp_large_community.add((64497,1,202));
    bgp_large_community.add((64497,1,203));
    bgp_large_community.add((64497,1,204));
    bgp_large_community.add((64497,1,205));
    bgp_large_community.add((64497,1,206));
    bgp_large_community.add((64497,1,207));
    bgp_large_community.add((64497,1,208));
    bgp_large_community.add((64497,1,209));
    bgp_large_community.add((64497,1,210));
    bgp_large_community.add((64497,1,211));
    bgp_large_community.add((64497,1,212));
    bgp_large_community.add((64497,1,213));
    bgp_large_community.add((64497,1,214));
    bgp_large_community.add((64497,1,215));
    bgp_large_community.add((64497,1,216));
    bgp_large_community.add((64497,1,217));
    bgp_large_community.add((64497,1,218));
    bgp_large_community.add((64497,1,219));
    bgp_large_community.add((64497,1,220));
    bgp_large_community.add((64497,1,221));
    bgp_large_community.add((64497,1,222));
    bgp_large_community.add((64497,1,223));
    bgp_large_community.add((64497,1,224));
    bgp_large_community.add((64497,1,225));
    bgp_large_community.add((64497,1,226));
    bgp_large_community.add((64497,1,227));
    bgp_large_community.add((64497,1,228));
    bgp_large_community.add((64497,1,229));
    bgp_large_community.add((64497,1,230));
    bgp_large_community.add((64497,1,231));
    bgp_large_community.add((64497,1,232));
    bgp_large_community.add((64497,1,233));
    bgp_large_community.add((64497,1,234));
    bgp_large_community.add((64497,1,235));
    bgp_large_community.add((64497,1,236));
    bgp_large_community.add((64497,1,237));
    bgp_large_community.add((64497,1,238));
    bgp_large_community.add((64497,1,239));
    bgp_large_community.add((64497,1,240));
    bgp_large_community.add((64497,1,241));
    bgp_large_community.add((64497,1,242));
    bgp_large_community.add((64497,1,243));
    bgp_large_community.add((64497,1,244));
    bgp_large_community.add((64497,1,245));
    bgp_large_community.add((64497,1,246));
    bgp_large_community.add((64497,1,247));
    bgp_large_community.add((64497,1,248));
    bgp_large_community.add((64497,1,249));
    bgp_large_community.add((64497,1,250));
    bgp_large_community.add((64497,1,251));
    bgp_large_community.add((64497,1,252));
    accept;
}

protocol bgp {
    description "IPv4 peering";
    neighbor 192.16.107.18%ens1f1 as 65535;
    local 192.16.107.19 as 64600;
    router id 192.16.107.19;
    source address 192.16.107.19;
    strict bind on; # Default off
    direct; # default enabled for eBGP
    interpret communities off; # default on
    enable route refresh on; # default on
    enable as4 on; # default on
    capabilities on; # default on
    ipv4 {
        # "none" and "all" filters are built-ins
        import none; # Default off
        export filter add_large; # Default off
        mandatory on; # Default off
    };
}

protocol static {
    ipv4;
    route 10.0.0.126/32 via "lo";
}

Trying to add one more community cause BIRD to log the error "Attribute list too long":

me@lab:/opt/bird-2.15.1$ docker compose up
[+] Running 1/0
 ✔ Container bird-2151-bird-1  Created                                                                                                                                                                        0.0s 
Attaching to bird-1
bird-1  | 2024-10-14 15:24:58.420  device1: Initializing
bird-1  | 2024-10-14 15:24:58.420  bgp1: Initializing
bird-1  | 2024-10-14 15:24:58.420  static1: Initializing
bird-1  | 2024-10-14 15:24:58.420  device1: Starting
bird-1  | 2024-10-14 15:24:58.420  device1: Scanning interfaces
bird-1  | 2024-10-14 15:24:58.420  Missing broadcast address for interface ens1f1
bird-1  | 2024-10-14 15:24:58.420  device1: State changed to up
bird-1  | 2024-10-14 15:24:58.420  bgp1: Starting
bird-1  | 2024-10-14 15:24:58.420  bgp1: State changed to start
bird-1  | 2024-10-14 15:24:58.420  static1: Starting
bird-1  | 2024-10-14 15:24:58.420  static1: State changed to up
bird-1  | 2024-10-14 15:24:58.420  static1.ipv4 > added [best] 10.0.0.126/32 0L 2G unicast
bird-1  | 2024-10-14 15:24:58.420  Started
bird-1  | 2024-10-14 15:24:58.423  bgp1: Started
bird-1  | 2024-10-14 15:24:58.423  bgp1: Connect delayed by 5 seconds
bird-1  | 2024-10-14 15:24:58.988  bgp1: Incoming connection from 192.16.107.18 (port 41389) accepted
bird-1  | 2024-10-14 15:24:58.989  bgp1: Sending OPEN(ver=4,as=64600,hold=240,id=b9386b13)
bird-1  | 2024-10-14 15:24:58.989  bgp1: Got OPEN(as=65535,hold=180,id=192.16.107.5)
bird-1  | 2024-10-14 15:24:58.989  bgp1: Got KEEPALIVE
bird-1  | 2024-10-14 15:24:58.989  bgp1: BGP session established
bird-1  | 2024-10-14 15:24:58.989  bgp1: State changed to up
bird-1  | 2024-10-14 15:24:58.989  bgp1: Sending KEEPALIVE
bird-1  | 2024-10-14 15:24:58.989  bgp1.ipv4 < added 10.0.0.126/32 0L 2G unicast
bird-1  | 2024-10-14 15:24:58.990  bgp1: Attribute list too long
bird-1  | 2024-10-14 15:24:58.990  bgp1: - withdrawing 10.0.0.126/32
bird-1  | 2024-10-14 15:24:58.990  bgp1: Sending UPDATE
bird-1  | 2024-10-14 15:24:58.990  bgp1: Sending END-OF-RIB

The route is never sent to the Arista so it seems that is the limit for BIRD. This config produces a BGP update which was 3088 bytes long, so it should be possible to go higher (up to 4096).