Once a routing loop occurs on a Layer 3 network, packets cannot be forwarded, which may cause losses to carriers or users.
To detect potential routing loops on the network, BGP defines the Loop-detection attribute. The fundamentals of BGP routing loop detection are as follows:
Routing loop records are affected by the following commands:
The Loop-detection attribute is a private BGP attribute. It uses a reserved value (type=255) to implement routing loop detection in some scenarios. Figure 1 shows the Loop-detection attribute TLV, and Table 1 describes the fields in it.
Currently, the Loop-detection attribute is supported only in the BGP IPv4 public network, BGP IPv4 private network, BGP IPv6 public network, BGP IPv6 private network, BGP VPNv4, and BGP VPNv6 address families.
Field |
Description |
---|---|
Attr.Flags |
Attribute flag, which occupies one byte (eight bits). The meaning of each bit is as follows: O (Optional bit): defines whether the attribute is optional. The value 1 indicates an optional attribute, whereas the value 0 indicates a well-known attribute. T (Transitive bit): Defines whether the attribute is transitive. For an optional attribute, the value 1 indicates that the attribute is transitive, whereas the value 0 indicates that the attribute is non-transitive. For a well-known attribute, the value must be set to 1. P (Partial bit): Defines whether the information in an optional-transitive attribute is partial. If the information is partial, P must be set to 1; if the information is complete, P must be set to 0. For well-known attributes and for optional non-transitive attributes, P must be set to 0. E (Extended Length bit): defines whether the length (Attr. Length) of the attribute needs to be extended. If the attribute length does not need to be extended, E must be set to 0 and the attribute length is 1 octet. If the attribute length needs to be extended, E must be set to 1 and the attribute length is 2 octets. U (Unused bits): Indicates that the lower-order four bits of Attr. Flags are not used. These bits are ignored on receipt and must be set to 0. |
Attr.Type Code |
Attribute type, which occupies one byte. The value is an unsigned integer, with the initial value being 0xFF. |
Attr.Length |
Length of the attribute. |
Attr.Value |
Huawei's organizationally unique identifier (OUI), with the value being 0x0030FBB8, which is used to differentiate Huawei from other vendors. |
BGP also defines a sub-TLV for Attr.Value to identify the device that detects a routing loop. Figure 2 shows the sub-TLV, and Table 2 describes the fields in the sub-TLV.
A maximum of four Loop-detection attribute sub-TLVs can be carried. If more than four sub-TLVs exist, they are overwritten according to the first-in-first-out rule.
Field |
Description |
---|---|
Attr.Type |
The value is 0xFF. |
Attr.Length |
Length of the attribute. The value is 0x08, 0x10, 0x18, or 0x20. |
Attr.Value |
0 31 63 +-------------+-------------+ | vrfID | Random number | +-------------+-------------+ vrfID specifies a system-allocated VPN ID. The value ranges from 0 to 0xFFFFFFFF. NOTE:
For BGP VPNv4 and BGP VPNv6 routes, the system only checks the random number when determining whether a routing loop occurs; that is, it does not check the vrfID. |
BGP routing loops may occur in the following scenarios. You are advised to enable BGP routing loop detection during network planning.
To avoid this problem, enable BGP routing loop detection on DeviceC. After BGP routing loop detection is enabled, DeviceC adds Loop-detection attribute 1 to the BGP route imported from OSPF and advertises the BGP route to the RR. After receiving this BGP route, the RR advertises it (carrying Loop-detection attribute 1) to DeviceB. As OSPF routing loop detection is enabled by default, when the BGP route is imported to become an OSPF route on DeviceB, the OSPF route inherits the routing loop attribute of the BGP route and has an OSPF routing loop attribute added as well before the OSPF route is advertised to DeviceC. Upon receipt of the OSPF route, DeviceC imports it to convert it to a BGP route. Because BGP routing loop detection is enabled, the BGP route inherits the routing loop attributes of the OSPF route. Upon receipt of the route, DeviceC finds that the received route carries its own routing loop attribute and therefore determines that a routing loop has occurred. In this case, DeviceC generates an alarm, and reduces the local preference and increases the MED value of the route before advertising the route to the RR. After receiving the route, the RR compares this route with the route advertised by DeviceA. Because the route advertised by DeviceC has a lower local preference and a larger MED value, the RR preferentially selects the route advertised by DeviceA. The routing loop is then resolved.
When the OSPF route is transmitted to DeviceC again, DeviceC imports it to convert it to a BGP route. At this point, the route carries only the OSPF routing loop attribute added by DeviceB. However, DeviceC still considers the route as a looped route because the route has a routing loop record. In this case, the RR does not preferentially select the route after receiving it from DeviceC. Then routes converge normally.
This function is not supported in the following scenarios: