Conditional advertisement and outbound route filtering

Two features advertise less, and they differ on who decides. Conditional advertisement reads your own BGP table: advertise-map names the route to announce, and exist-map or non-exist-map the prefix to watch. It runs on the BGP scanner every 60 seconds, so it can react up to a minute late. Outbound route filtering is a filter the peer writes and hands to you.

In Daveth Pro (Network)5 min video · lab: BGP policy

By , founder of Daveth · Updated

Opening frame of the video walkthrough of Conditional advertisement and outbound route filtering

Watch this lesson

5 min · Video walkthrough

In Daveth Pro (Network)

The full 5 min walkthrough is in Daveth Pro (Network). See what the plan opens

Upcoming practical lab

Lab C8: BGP policy

What the lab covers

What this page answers

How does BGP conditional advertisement work?

neighbor advertise-map names the route to announce, and a non-exist-map or exist-map names a prefix to watch in your own BGP table. With non-exist-map, the route is announced only when the watched prefix is not present. Read it in “Two map forms, opposite triggers”

How long does BGP conditional advertisement take to react?

Up to 60 seconds: the process is triggered by the BGP scanner, which runs every 60 seconds, and nothing in the configuration mentions that timer. Read it in “And it reacts up to 60 seconds later”

Why does BGP conditional advertisement never trigger?

The watched prefix may still be in the table from another peer. If it returns through the second provider, the condition never goes false and the backup route is never advertised. Read it in “The condition that never goes false”

Two ways to advertise less

R1 has three peers and a BGP table it does not want to hand over whole. Two items in this blueprint do that job, and they are worth learning together because they differ on exactly one thing.

Who makes the decision. One is a condition you write, evaluated against your own table. The other is a filter the peer writes and hands to you, which you then apply to what you send them.

Everything else about them follows from that: what triggers each, how fast it reacts, whether the peer has to agree, and where each one is allowed to be used at all.

A condition in your own table

What does the feature actually read?

"The Border Gateway Protocol (BGP) conditional advertisement feature provides additional control of route advertisement, depending on the existence of other prefixes in the BGP table."

So the table becomes an input to policy. R1 learns 192.168.50.0/24 from PROV-A, and whether that prefix is present decides whether 172.16.16.0/24 is advertised to PROV-B.

The feature "uses the non-exist-map and the advertise-map keywords of the neighbor advertise-map command": two maps, one naming the route to announce and one naming the prefix to watch for. And the Command Reference prints the whole line, which is worth reading before you type a shorter one:

neighbor {ipv4-address | ipv6-address} advertise-map map-name {exist-map map-name | non-exist-map map-name} [check-all-paths]

Configuration: the conditional advertisement on the PROV-B peering. The command syntax, the keywords, the restrictions, the scanner interval and the capability semantics are cited; the prefixes, the map names, the prefix-list name and the AS numbers are this course's own.

R1# configure terminal
R1(config)# router bgp 65001
R1(config-router)# address-family ipv4 unicast
R1(config-router-af)# neighbor 198.51.100.20 advertise-map ADVERTISE-BACKUP non-exist-map WATCH-PROVIDER-A
R1(config-router-af)# end

ADVERTISE-BACKUP names the route; WATCH-PROVIDER-A names the prefix to watch. Both are route maps, and how a route map or a prefix list is built is 1.2.g.

One thing the syntax line tells you that the prose does not: it takes an IPv4 address or an IPv6 one. Which matters later on this page.

Two map forms, opposite triggers

Which way round does each one fire?

"If a route prefix is not present in output of the non-exist-map command, then the route specified by the advertise-map command is announced."

And the other form is the other way round. The documented example states both halves of it:

"If 192.168.50.0/24 exists in the R102 BGP table, advertise the 172.16.16.0/24 network to R101. If 192.168.50.0/24 does not exist in the R102 BGP table, do not advertise the 172.16.16.0/24 network to R101."

Computed from the state: both forms against a table that contains 192.168.50.0/24. No command prints it.

map form          watched prefix      in the table?  announced?
non-exist-map     192.168.50.0/24     yes            no
exist-map         192.168.50.0/24     yes            yes

the configured form is non-exist-map, and 192.168.50.0/24 is present, and a
non-exist-map announces the advertise-map route only when the watched prefix is
absent

These are not one keyword with a negation available. They are two behaviours, and the form that detects a failure is non-exist-map, because what you want to react to is a prefix going away.

Computed from the state, and both forms again once 192.168.50.0/24 has gone from it. No command prints it.

map form          watched prefix      in the table?  announced?
non-exist-map     192.168.50.0/24     no             yes
exist-map         192.168.50.0/24     no             no

the configured form is non-exist-map, and 192.168.50.0/24 is not present in the
output of the non-exist-map command, so the route the advertise-map names is
announced

Two conditions of the feature that are easy to miss. The first is what happens when the condition is not met; the second rules out a design people reach for, where the advertise-map route is generated only in the failure case:

"If the condition is not met, the route is withdrawn and conditional advertisement does not occur. All routes that may be dynamically advertised or not advertised need to exist in the BGP routing table for conditional advertisement to occur."

Read the second sentence twice. The route you are conditionally advertising has to be in the BGP table the whole time. The condition decides whether it is announced, not whether it exists.

And the conditional announcement does not replace the normal one:

"The conditional BGP announcements are sent in addition to the normal announcements that a BGP router sends to its peers."

So 172.16.16.0/24 going to PROV-B is an addition to whatever R1 already advertises there, not a substitution for it. People read advertise-map as "advertise only this". It is not.

One optional keyword, for the exist-map form: check-all-paths. "(Optional) Enables checking of all paths by the exist-map with a prefix in the BGP table."

The table as a failure detector

PROV-A stops advertising 192.168.50.0/24. The peering has failed, or reachability through it has gone partial: the document names both, and it names this as the use case:

"This feature is useful for multihomed networks, in which some prefixes are advertised to one of the providers only if information from the other provider is not present (this indicates a failure in the peering session or partial reachability)."

Which is a real and good use of it. A prefix you learn from one provider is evidence about that provider, and turning that evidence into policy is exactly what this feature is for.

Designing the multihomed edge that this sits inside is 1.5.c.v, and is not this page.

And it reacts up to 60 seconds later

How quickly does the advertisement change?

"The conditional advertisement process is triggered by the BGP scanner process, which runs every 60 seconds."

Nothing in the configuration of this feature says that. You write two maps and a neighbor statement, and none of it mentions a timer.

The document puts both ends of the range on the record, which is worth having in the words that were published rather than inferred:

"This means that the maximum time for the conditional advertisement to take effect is 60 seconds. The conditional advertisement can take effect sooner, depending on when the tracked route is removed from the BGP table and when the next instance of the BGP scanner occurs."

Computed from the state: what the interval costs, for a withdrawal 7 seconds into the cycle. No command prints it.

the scanner interval                        60 seconds
the watched prefix was withdrawn at         7s into the cycle
the next scanner run is at                  60s
so the advertisement changes after          53 seconds

a withdrawal immediately after a scan waits 60 seconds
and one just before a scan waits            1 second

nothing in the configuration of this feature states the interval, and the wait can
be anything up to 60 seconds. A failover requirement measured in seconds is not
met by a mechanism measured in this one

And the document shows one real interval, in a debug ip bgp updates trace taken while the condition changed. Read the two timestamps:

Output from elsewhere: the scanner acting on a withdrawal, 46 seconds after it arrived. The addresses and map names in it are that document’s, not this scenario’s.

*Mar  1 02:39:18.059: BGP(0): 10.10.20.3 rcv UPDATE about 192.168.50.0/24
-- withdrawn
*Mar  1 02:39:18.059: BGP(0): no valid path for 192.168.50.0/24
*Mar  1 02:39:18.079: BGP(0): nettable_walker 192.168.50.0/24 no best path

*Mar  1 02:40:04.747: BPG(0): Condition NON-EXIST changes to Advertise
*Mar  1 02:40:04.747: BGP(0): net 172.16.16.0/24 matches ADV MAP ADVERTISE:
bump version to 12

Withdraw at 02:39:18, condition change at 02:40:04. Forty-six seconds, inside the published maximum of 60.

So the mechanism people reach for to detect a BGP failure checks whether anything has failed about as often as you check your watch in a meeting. Which is fine for what it is, and is not a failover mechanism.

A requirement written in seconds is not met by this. The reaction can be anything up to 60 seconds, and where you land in that range depends on where in the cycle the prefix went away.

Computed from the state, and the same delay in the other direction, when the prefix returns. No command prints it.

the prefix came back at                     53s into the cycle
the next scanner run is at                  60s
so the advertisement is withdrawn after     7 seconds

the same interval, in the other direction: the advertisement stops on a scanner
run rather than on the prefix returning

Is the condition met, right now?

One line of show ip bgp neighbors answers it. Run against the peer the condition is configured for, the neighbor detail carries the condition map, the advertise-map and the state of the pair. The support document prints it for its neighbor 10.10.10.1:

Output from elsewhere: show ip bgp neighbors 10.10.10.1, with the conditional advertisement withheld and the watched prefix still in the table. The addresses and map names in it are that document’s, not this scenario’s.

BGP neighbor is 10.10.10.1,  remote AS 1, external link
  BGP version 4, remote router ID 10.200.200.1
  BGP state = Established, up for 02:27:07
  Last read 00:00:07, hold time is 180, keepalive interval is 60 seconds

 For address family: IPv4 Unicast
  BGP table version 6, neighbor version 6
  Index 1, Offset 0, Mask 0x2
  Condition-map NON-EXIST, Advertise-map ADVERTISE, status: Withdraw
  1 accepted prefixes consume 36 bytes
  Prefix advertised 3, suppressed 0, withdrawn 1
  Number of NLRIs in the update sent: max 1, min 0

status: Withdraw means the condition is not met, and the advertise-map route is not being announced. Here is the same block from the same document once the watched prefix has gone:

Output from elsewhere: the same command, after the tracked prefix left the table. The addresses and map names in it are that document’s, not this scenario’s.

 For address family: IPv4 Unicast
  BGP table version 12, neighbor version 12
  Index 1, Offset 0, Mask 0x2
  Condition-map NON-EXIST, Advertise-map ADVERTISE, status: Advertise
  1 accepted prefixes consume 36 bytes
  Prefix advertised 6, suppressed 0, withdrawn 4
  Number of NLRIs in the update sent: max 1, min 0

Read status first: it flipped to Advertise. Other numbers moved as well: the table version from 6 to 12, Prefix advertised from 3 to 6, withdrawn from 1 to 4. None of them names a condition. status is the one line in the block that says which condition changed, and which way.

And on R1, once the scanner has run?

This course's output, drawn in the published layout: the same command on R1, against PROV-B, after the scanner has run, in the shape the sample above prints. The addresses and names are this course’s own.

R1# show ip bgp neighbors 198.51.100.20
BGP neighbor is 198.51.100.20,  remote AS 65020, external link

 For address family: IPv4 Unicast
  Condition-map WATCH-PROVIDER-A, Advertise-map ADVERTISE-BACKUP, status: Advertise

And what is actually leaving, which is the other half of the question. The same document prints show ip bgp neighbors 10.10.10.1 advertised-routes with the conditional route absent:

Output from elsewhere: the advertised routes with the conditional one absent. The addresses and map names in it are that document’s, not this scenario’s.

BGP table version is 6, local router ID is 172.16.16.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.31.130.0      0.0.0.0                  0         32768 i
*> 192.168.50.0     10.10.20.3               0             0 3 i

One neighbor can carry more than one condition. The 17.x chapter prints the same neighbor detail for a VPNv4 peering with four on it, three advertising and one not: they are independent, and each has its own pair of maps:

Output from elsewhere: four conditions on one neighbor. The addresses and map names in it are that document’s, not this scenario’s.

 For address family: VPNv4 Unicast
  Translates address family IPv4 Unicast for VRF red
  Session: 198.51.100.3
  BGP table version 48, neighbor version 48/0
  Output queue size : 0
  Index 3, Advertise bit 0
  3 update-group member
  Condition-map EXIST-1, Advertise-map ADV-1, status: Advertise
  Condition-map EXIST-2, Advertise-map ADV-2, status: Withdraw
  Condition-map EXIST-3, Advertise-map ADV-3, status: Advertise
  Condition-map EXIST-4, Advertise-map ADV-4, status: Advertise
  Slow-peer detection is disabled

Proves: the neighbor detail shows the state of each condition on that peering and which advertise-map it belongs to; advertised-routes shows which prefixes are being advertised to that neighbor right now. Does not prove: when the condition last changed or when the scanner will next run, and, on its own, nothing about why a condition is false.

The condition that never goes false

PROV-A goes away again, and this time nothing happens. Same configuration, same maps, same watched prefix, and status stays on Withdraw.

Before reading on: what could keep 192.168.50.0/24 in the table after the peer advertising it has gone?

Another peer advertising it. In a real edge, 192.168.50.0/24 propagates through the global mesh and comes back from PROV-B, which is not a misconfiguration, is invisible in the conditional advertisement's own configuration, and is fatal to it:

"However, since the prefix 192.168.50.0/24 continues to exist in the R102 BGP table (learned from R101), the conditional advertisement breaks because the prefix in the non-exist map still exists in the R102 BGP table."

Computed from the state: what the map can see, with the direct path gone and PROV-B still sending it. No command prints it.

path in the BGP table learned from    in the table?  the map sees it?
192.168.50.0/24       AS 65020        yes            yes

the non-exist-map condition is false, so 172.16.16.0/24 is not announced

The prefix is in the table, so the non-exist condition is false, so the backup advertisement never fires. Every command you would run says the feature is configured correctly, because it is.

The published fix is to make the map more specific: match the prefix and the AS path it has to have arrived by.

Configuration: the non-exist map, supplemented with an AS-path match. The command syntax, the keywords, the restrictions, the scanner interval and the capability semantics are cited; the prefixes, the map names, the prefix-list name and the AS numbers are this course's own.

R1# configure terminal
R1(config)# ip as-path access-list 1 permit ^65010
R1(config)# route-map WATCH-PROVIDER-A permit 10
R1(config-route-map)# match ip address prefix-list WATCHED-PREFIX
R1(config-route-map)# match as-path 1
R1(config-route-map)# end

Output from elsewhere: the same fix as the document prints it. The addresses and map names in it are that document’s, not this scenario’s.

ip as-path access-list 1 permit ^3
!
route-map NON-EXIST permit 10
 match ip address 65
  match as-path 1

Computed from the state: what the map can see once it matches the path from AS 65010. No command prints it.

path in the BGP table learned from    in the table?  the map sees it?
192.168.50.0/24       AS 65020        yes            no: the map matches AS 65010 only

the non-exist-map condition is true, so 172.16.16.0/24 is announced: 
192.168.50.0/24 is still in the table, learned from AS 65020, but the map matches
only the path from AS 65010, so the condition is true

Now the condition is true with 192.168.50.0/24 still in the table, because the map is no longer asking "is this prefix here" but "is this prefix here from the provider I am watching".

And one limit on that, stated plainly by the document:

"Beware that you cannot match just the as-path, and not match the prefix. The match as-path can only supplement the matching criteria for the matched prefix. In other words, you cannot advertise some prefixes to a neighbor if no prefix exists from a certain AS #."

Which is the transferable move. On a multihomed edge, "the prefix is gone" and "the path I care about is gone" are different questions, and a non-exist map answers whichever one you wrote. Check what your non-exist map matches before you trust what it detects.