Implement BGP Peering for IOS XR#363
Conversation
6328280 to
01e5837
Compare
| // +optional | ||
| AddressFamilies *BGPPeerAddressFamilies `json:"addressFamilies,omitempty"` | ||
|
|
||
| // LocalAS specifies a local AS number to present to the BGP peer without changing the main BGP process ASN. |
There was a problem hiding this comment.
| // LocalAS specifies a local AS number to present to the BGP peer without changing the main BGP process ASN. | |
| // LocalAS specifies a local AS number to present to the BGP peer, masking the global BGP process ASN. |
Could you also extend the current validation webhook to verify this AS Number, same as the remote as number field?
|
|
||
| // LocalAS specifies a local AS number to present to the BGP peer without changing the main BGP process ASN. | ||
| // +optional | ||
| LocalAS intstr.IntOrString `json:"localAS,omitempty"` |
There was a problem hiding this comment.
We probably want this to make this a pointer as this type does not have built-in nil value. As described in the k8s API conventions in more detail, a pointer helps to distinguish if the this is just not set or it is set but empty.
I guess it would be possible to keep the type as it is assuming that ASN0 is reserved and must not be used anyway. However, I think the pointer would be cleaner.
There was a problem hiding this comment.
Valid point, made this a pointer of type int.
|
|
||
| // LocalAS specifies a local AS number to present to the BGP peer without changing the main BGP process ASN. | ||
| // +optional | ||
| LocalAS intstr.IntOrString `json:"localAS,omitempty"` |
There was a problem hiding this comment.
On a second thought, in BGP Process, we called the field "ASNumber". So should this naturally be "LocalASNumber"? How would the capitalization then look for the json/yaml key? "localASNumber"?
There was a problem hiding this comment.
LocalASNumber it is.
Signed-off-by: Sven Rosenzweig <sven.rosenzweig@sap.com>
Signed-off-by: Sven Rosenzweig <sven.rosenzweig@sap.com>
Merging this branch will decrease overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
|
|
||
| // LocalASNumber specifies a local AS number to present to the BGP peer, masking the global BGP process ASN. | ||
| // +optional | ||
| LocalASNumber *int `json:"localAS,omitempty"` |
There was a problem hiding this comment.
LocalASNumber only applies to eBGP neighbors (i.e. BGPPeer.asNumber != BGP.asNumber). As this check goes across multiple resources, we should put that into the controller for the BGPPeer (internal/controller/core/bgp_peer_controller.go#( to check for this condition, i.e. something like:
diff --git a/internal/controller/core/bgp_peer_controller.go b/internal/controller/core/bgp_peer_controller.go
index 39645e1c..8891da8a 100644
--- a/internal/controller/core/bgp_peer_controller.go
+++ b/internal/controller/core/bgp_peer_controller.go
@@ -441,6 +441,16 @@ func (r *BGPPeerReconciler) reconcile(ctx context.Context, s *bgpPeerScope) (ret
sourceInterface = intf.Spec.Name
}
+ if s.BGPPeer.Spec.LocalASNumber != nil && s.BGPPeer.Spec.ASNumber.String() == bgp.Spec.ASNumber.String() {
+ conditions.Set(s.BGPPeer, metav1.Condition{
+ Type: v1alpha1.ConfiguredCondition,
+ Status: metav1.ConditionFalse,
+ Reason: v1alpha1.ErrorReason,
+ Message: "local-as cannot be configured on iBGP peers",
+ })
+ return reconcile.TerminalError(fmt.Errorf("local-as cannot be configured on iBGP peers"))
+ }
+
if err := s.Provider.Connect(ctx, s.Connection); err != nil {
return fmt.Errorf("failed to connect to provider: %w", err)
}Returning a terminal error, if that validation fails.
No description provided.