BGP AS_PATH when using aggregate-address
According to RFC 4271, the AS_PATH is a BGP attribute that is composed of a sequence of AS path segments. Found within the update packet, there are the following fields:
- path segment type - This can be a value of 1 which indicates AS_SET or 2 which indicates AS_SEQUENCE
- path segment length - contains the number of ASes in the path segment value field
- path segment value - one or more AS numbers, each encoded as a 2 octet length field.
Within a BGP update, sometimes the AS_SET is used, sometimes the AS_SEQUENCE is used. According to the RFC:
- AS_SET: unordered set of ASes a route in the UPDATE message has traversed
- AS_SEQUENCE: ordered set of ASes a route in the UPDATE message has traversed
Under “normal” circumstances, AS_SEQUENCE is used, because it is useful and often necessary to know the order in which the ASes have been traversed. However, in the event that somewhere downstream BGP's aggregate address feature is being used using the
aggregate-address command, it can be useful to maintain the AS_PATH information. This is done using the
as-set keyword at the end of the
If this is done, then the BGP update will use an AS_SET. The way in which this is formatted is further described in the 5.1.2 AS_PATH section of the RFC.