Skip to content

Commit f81b44f

Browse files
committed
add nxos support to match extcommunities on routingpolicy
Signed-off-by: Ivo Gosemann <ivo.gosemann@sap.com>
1 parent 8c5da07 commit f81b44f

24 files changed

Lines changed: 1442 additions & 1 deletion

‎api/core/v1alpha1/groupversion_info.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ const (
270270
const (
271271
// PrefixSetNotFoundReason indicates that a referenced PrefixSet was not found.
272272
PrefixSetNotFoundReason = "PrefixSetNotFound"
273+
// CommunitySetNotFoundReason indicates that a referenced CommunitySet was not found.
274+
CommunitySetNotFoundReason = "CommunitySetNotFound"
275+
// ExtCommunitySetNotFoundReason indicates that a referenced ExtCommunitySet was not found.
276+
ExtCommunitySetNotFoundReason = "ExtCommunitySetNotFound"
273277
// SecretNotFoundReason indicates that a referenced Secret was not found.
274278
SecretNotFoundReason = "SecretNotFound"
275279
// RemoteEndpointUnreachableReason indicates that the remote object storage endpoint is not reachable.

‎api/core/v1alpha1/routingpolicy_types.go‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ type PolicyConditions struct {
6363
// MatchPrefixSet matches routes against a PrefixSet resource.
6464
// +optional
6565
MatchPrefixSet *PrefixSetMatchCondition `json:"matchPrefixSet,omitempty"`
66+
67+
// MatchCommunitySet matches routes against a CommunitySet resource.
68+
// +optional
69+
MatchCommunitySet *CommunitySetMatchCondition `json:"matchCommunitySet,omitempty"`
70+
71+
// MatchExtCommunitySet matches routes against an ExtCommunitySet resource.
72+
// +optional
73+
MatchExtCommunitySet *ExtCommunitySetMatchCondition `json:"matchExtCommunitySet,omitempty"`
6674
}
6775

6876
// PrefixSetMatchCondition defines the condition for matching against a PrefixSet.
@@ -73,6 +81,47 @@ type PrefixSetMatchCondition struct {
7381
PrefixSetRef LocalObjectReference `json:"prefixSetRef"`
7482
}
7583

84+
// CommunitySetMatchCondition defines the condition for matching against a CommunitySet.
85+
type CommunitySetMatchCondition struct {
86+
// CommunitySetRef references a CommunitySet in the same namespace.
87+
// The CommunitySet must exist and belong to the same device.
88+
// +required
89+
CommunitySetRef LocalObjectReference `json:"communitySetRef"`
90+
91+
// MatchSetOptions defines how a route's communities are compared against the referenced set.
92+
// ANY matches a route carrying at least one member of the set; ALL matches only a route
93+
// carrying every member of the set.
94+
// +optional
95+
// +kubebuilder:default=ANY
96+
MatchSetOptions MatchSetOptions `json:"matchSetOptions,omitempty"`
97+
}
98+
99+
// ExtCommunitySetMatchCondition defines the condition for matching against an ExtCommunitySet.
100+
type ExtCommunitySetMatchCondition struct {
101+
// ExtCommunitySetRef references an ExtCommunitySet in the same namespace.
102+
// The ExtCommunitySet must exist and belong to the same device.
103+
// +required
104+
ExtCommunitySetRef LocalObjectReference `json:"extCommunitySetRef"`
105+
106+
// MatchSetOptions defines how a route's extended communities are compared against the referenced set.
107+
// ANY matches a route carrying at least one member of the set; ALL matches only a route
108+
// carrying every member of the set.
109+
// +optional
110+
// +kubebuilder:default=ANY
111+
MatchSetOptions MatchSetOptions `json:"matchSetOptions,omitempty"`
112+
}
113+
114+
// MatchSetOptions defines how a route's attributes are compared against a referenced set.
115+
// +kubebuilder:validation:Enum=ANY;ALL
116+
type MatchSetOptions string
117+
118+
const (
119+
// MatchSetOptionsAny matches a route carrying at least one member of the referenced set.
120+
MatchSetOptionsAny MatchSetOptions = "ANY"
121+
// MatchSetOptionsAll matches only a route carrying every member of the referenced set.
122+
MatchSetOptionsAll MatchSetOptions = "ALL"
123+
)
124+
76125
// PolicyActions defines the actions to take when a policy statement matches.
77126
// +kubebuilder:validation:XValidation:rule="self.routeDisposition == 'AcceptRoute' || !has(self.bgpActions)",message="bgpActions cannot be specified when routeDisposition is RejectRoute"
78127
type PolicyActions struct {

‎api/core/v1alpha1/zz_generated.deepcopy.go‎

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎charts/network-operator/templates/crd/routingpolicies.networking.metal.ironcore.dev.yaml‎

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎config/crd/bases/networking.metal.ironcore.dev_routingpolicies.yaml‎

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎config/samples/v1alpha1_routingpolicy.yaml‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ spec:
7272
bgpActions:
7373
setASPath:
7474
asNumber: 65000
75+
- sequence: 80
76+
conditions:
77+
matchCommunitySet:
78+
communitySetRef:
79+
name: communityset
80+
matchSetOptions: ALL
81+
actions:
82+
routeDisposition: AcceptRoute
83+
- sequence: 90
84+
conditions:
85+
matchExtCommunitySet:
86+
extCommunitySetRef:
87+
name: extcommunityset
88+
actions:
89+
routeDisposition: AcceptRoute
7590
- sequence: 100
7691
actions:
7792
routeDisposition: AcceptRoute
@@ -129,3 +144,37 @@ spec:
129144
maskLengthRange:
130145
min: 25
131146
max: 32
147+
---
148+
apiVersion: networking.metal.ironcore.dev/v1alpha1
149+
kind: CommunitySet
150+
metadata:
151+
labels:
152+
app.kubernetes.io/name: network-operator
153+
app.kubernetes.io/managed-by: kustomize
154+
name: communityset
155+
spec:
156+
deviceRef:
157+
name: leaf1
158+
name: WIREAPI
159+
members:
160+
- sequence: 5
161+
regex: "50000:[0-9][0-9]"
162+
- sequence: 10
163+
regex: "65001:[0-9]+"
164+
---
165+
apiVersion: networking.metal.ironcore.dev/v1alpha1
166+
kind: ExtCommunitySet
167+
metadata:
168+
labels:
169+
app.kubernetes.io/name: network-operator
170+
app.kubernetes.io/managed-by: kustomize
171+
name: extcommunityset
172+
spec:
173+
deviceRef:
174+
name: leaf1
175+
name: WIREAPI
176+
members:
177+
- sequence: 5
178+
regex: "65200:[0-9][0-9]"
179+
- sequence: 15
180+
regex: "65300:[0-9]+"

0 commit comments

Comments
 (0)