BGP route policy attribute reference

This page shows example BGP route policies, using the Common Expression Language (CEL) for Cloud Router.

Match attributes

The following table describes match attributes available for BGP route policies:

Attributes

Description

destination

IP range for the BGP route

Match operations

The following table describes match operations available for BGP route policies:

Operation

Description

destination == '192.168.0.0/24'

Returns true if a BGP route matches with 192.168.0.0/24 (exact match).

destination != '192.168.0.0/24'

Returns true if a BGP route doesn't match 192.168.0.0/24 (exact match).

destination.inAnyRange(r)

Returns true if a BGP route is in the range r, where r is either:

  • A string with a CIDER-encoded prefix, such as 192.168.0.0/24.
  • The abstract type returned by prefix(), or one of the fluent methods that you can call on prefix(), such as longer().
  • A heterogenous list where each element must be either of the values previously described.

Negatable with !.

prefix('192.168.0.0/24')

Returns a prefix object representing the CIDR range 192.168.0.0/24, used with destination.inAnyRange().

prefix('192.168.0.0/24').longer()

Returns a prefix range object that's a copy of prefix() with the end of the range set to the input prefix's per-address family max (/32 or /128), and the start of the range set to the input prefix's length plus one.

prefix().orLonger()

Returns a prefix range object that's a copy of prefix() with the end of the range set to the input prefix's per-address family max (/32 or /128).

prefix().lengthRange(20, 30)

Returns a prefix range object that's a copy of prefix() with the start of the range set to /20, and the end set to /30.

prefix().upTo(30)

Returns a prefix range object that's a copy of prefix() with the end of the range set to the input prefix's /30.

x || y

Return true if either x or y is true

x and y must be boolean expressions using the same destination attribute.

Due to the rules for || (OR) operations, all conditions are effectively zero or more destination match operations connected by OR.

(D0 || D1 || ... || Dm)

The following table is an example of using prefix to build complex regular expressions compared to some router vendors:

Cloud Router Cisco Juniper Explanation

'192.168.0.1'

192.168.0.1

192.168.0.1

Exactly match the prefix 192.168.0.1/32

'192.168.0.0/24'

prefix('192.168.0.0/24')

192.168.0.0/24

192.168.0.0/24 exact

Exactly match the prefix 192.168.0.0/24

prefix('192.168.0.0/24').longer()

192.168.0.0/24 ge 25 le 32

192.168.0.0/24 longer

Match the range within 192.168.0.0/25 to 192.168.0.0/32

prefix('192.168.0.0/24').orLonger()

192.168.0.0/24 le 32

192.168.0.0/24 orlonger

Match the range within 192.168.0.0/24 to 192.168.0.0/32

prefix('192.168.0.0/24').lengthRange(25, 30)

192.168.0.0/24 ge 25 le 30

192.168.0.0/24 prefix-length-range /25-/30

Match the range within 192.168.0.0/25 to 192.168.0.0/30

prefix('192.168.0.0/24').upTo(30)

192.168.0.0/24 le 30

192.168.0.0/24 upto /30

Match the range within 192.168.0.0/24 to 192.168.0.0/30

Action attributes

The following table describes action attributes available for BGP route policies:

Attribute

Description

Restrictions

asPath

The list of AS numbers the BGP route update traversed

Export and Import

med

The route's multipath exit discriminator (MED)

Export and Import

Action operations

The following table describes action operations available for BGP route policies:

Operation

Description

accept()

Accepts the BGP routeroute, and stop further evaluation of BGP route policies or terms, including any actions that come after this one.

drop()

Filters out the BGP route, and stops further evaluation of BGP policies or terms, including any actions that come after this one.

nextPolicy()

Stops the execution of remaining terms in this BGP route policy (including any actions after this term), and moves on to the next applied BGP route policy (if any).

asPath.prependSequence([1, 2, 3])

Prepends a list of AS numbers to the AS-PATH attribute, as a sequence.

The arguments must be integers within the range of 32-bits.

med.set(12345)

Sets MED to 12345.

None