Validate GAR switch IDs at startup Summary: Context GAR policies encode the local switch identifier into a field of the link-bandwidth extended community. Today BGP discovers that the value does not fit only when a route reaches LbwExtCommunityAction::applyAction, where encodeValue terminates the process through an XCHECK. Startup ordering All three BGP entry points construct Config, load the policy bundle, and call Config::createPolicyManager before constructing or starting RIB. This diff validates at that common boundary. A bad switch/policy pair therefore raises BgpError during BGP startup, before any RIB thread or route processing begins. The runtime check remains only as an invariant backstop. Which policies apply The policy bundle is shared and may contain statements for other switch roles. Validating the whole bundle would reject an STSW because of an RTSW-only policy. getReferencedPolicyNames therefore seeds validation from the resolved static-peer and dynamic-peer configs, which already include peer-group inheritance and peer overrides, plus policies attached to originated IPv4/IPv6 networks. Policy traversal validateSwitchIdEncoding builds a name index and walks only the reachable policy graph. NEXT_POLICY edges are followed transitively, and a visited set handles repeated references and cycles. Missing root names remain the responsibility of the existing Config::verifyIfPoliciesExist validation. Encoding check For each reachable ENCODE_SWITCH_ID action, encoding_id selects a field position in the configured encoding scheme. This supports either rack-ID or plane-ID layouts without hard-coding a field name. BGP rejects missing switch IDs, incomplete schemes, invalid field indices, and values outside the selected unsigned bit width. The shared hostname parser consumes the complete trailing decimal run, so rtsw1024 is ID 1024 rather than 24. Reviewed By: xiangxu1121 Differential Revision: D113616754 fbshipit-source-id: 25d4fa61c20293a04b6e957ae704e897a1acc6e2
Validate GAR switch IDs at startup
Summary: Context
GAR policies encode the local switch identifier into a field of the link-bandwidth extended community. Today BGP discovers that the value does not fit only when a route reaches LbwExtCommunityAction::applyAction, where encodeValue terminates the process through an XCHECK.
LbwExtCommunityAction::applyAction
encodeValue
XCHECK
Startup ordering
All three BGP entry points construct Config, load the policy bundle, and call Config::createPolicyManager before constructing or starting RIB. This diff validates at that common boundary. A bad switch/policy pair therefore raises BgpError during BGP startup, before any RIB thread or route processing begins. The runtime check remains only as an invariant backstop.
Config
Config::createPolicyManager
BgpError
Which policies apply
The policy bundle is shared and may contain statements for other switch roles. Validating the whole bundle would reject an STSW because of an RTSW-only policy. getReferencedPolicyNames therefore seeds validation from the resolved static-peer and dynamic-peer configs, which already include peer-group inheritance and peer overrides, plus policies attached to originated IPv4/IPv6 networks.
getReferencedPolicyNames
Policy traversal
validateSwitchIdEncoding builds a name index and walks only the reachable policy graph. NEXT_POLICY edges are followed transitively, and a visited set handles repeated references and cycles. Missing root names remain the responsibility of the existing Config::verifyIfPoliciesExist validation.
validateSwitchIdEncoding
NEXT_POLICY
Config::verifyIfPoliciesExist
Encoding check
For each reachable ENCODE_SWITCH_ID action, encoding_id selects a field position in the configured encoding scheme. This supports either rack-ID or plane-ID layouts without hard-coding a field name. BGP rejects missing switch IDs, incomplete schemes, invalid field indices, and values outside the selected unsigned bit width. The shared hostname parser consumes the complete trailing decimal run, so rtsw1024 is ID 1024 rather than 24.
ENCODE_SWITCH_ID
encoding_id
rtsw1024
Reviewed By: xiangxu1121
Differential Revision: D113616754
fbshipit-source-id: 25d4fa61c20293a04b6e957ae704e897a1acc6e2
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802047560号