Skip to content

Commit 82262b9

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

26 files changed

Lines changed: 1268 additions & 7 deletions

‎api/core/v1alpha1/groupversion_info.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ const (
285285
const (
286286
// PrefixSetNotFoundReason indicates that a referenced PrefixSet was not found.
287287
PrefixSetNotFoundReason = "PrefixSetNotFound"
288+
// CommunitySetNotFoundReason indicates that a referenced CommunitySet was not found.
289+
CommunitySetNotFoundReason = "CommunitySetNotFound"
290+
// InvalidCommunitySetTypeReason indicates that a referenced CommunitySet is of the wrong type (standard vs extended).
291+
InvalidCommunitySetTypeReason = "InvalidCommunitySetType"
288292
// SecretNotFoundReason indicates that a referenced Secret was not found.
289293
SecretNotFoundReason = "SecretNotFound"
290294
// RemoteEndpointUnreachableReason indicates that the remote object storage endpoint is not reachable.

‎api/core/v1alpha1/routingpolicy_types.go‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ type PolicyConditions struct {
6363
// MatchPrefixSet matches routes against a PrefixSet resource.
6464
// +optional
6565
MatchPrefixSet *PrefixSetMatchCondition `json:"matchPrefixSet,omitempty"`
66+
67+
// MatchCommunitySets matches routes against CommunitySet resource(s).
68+
// +optional
69+
MatchCommunitySets []CommunitySetMatchCondition `json:"matchCommunitySets,omitempty"`
6670
}
6771

6872
// PrefixSetMatchCondition defines the condition for matching against a PrefixSet.
@@ -73,6 +77,32 @@ type PrefixSetMatchCondition struct {
7377
PrefixSetRef LocalObjectReference `json:"prefixSetRef"`
7478
}
7579

80+
// CommunitySetMatchCondition defines the condition for matching against a CommunitySet.
81+
type CommunitySetMatchCondition struct {
82+
// CommunitySetRef references a CommunitySet in the same namespace.
83+
// The CommunitySet must exist and belong to the same device.
84+
// +required
85+
CommunitySetRef LocalObjectReference `json:"communitySetRef"`
86+
87+
// MatchSetOptions defines how a route's communities are compared against the referenced set.
88+
// ANY matches a route carrying at least one member of the set; ALL matches only a route
89+
// carrying every member of the set.
90+
// +optional
91+
// +kubebuilder:default=ANY
92+
MatchSetOptions MatchSetOptions `json:"matchSetOptions,omitempty"`
93+
}
94+
95+
// MatchSetOptions defines how a route's attributes are compared against a referenced set.
96+
// +kubebuilder:validation:Enum=ANY;ALL
97+
type MatchSetOptions string
98+
99+
const (
100+
// MatchSetOptionsAny matches a route carrying at least one member of the referenced set.
101+
MatchSetOptionsAny MatchSetOptions = "ANY"
102+
// MatchSetOptionsAll matches only a route carrying every member of the referenced set.
103+
MatchSetOptionsAll MatchSetOptions = "ALL"
104+
)
105+
76106
// PolicyActions defines the actions to take when a policy statement matches.
77107
// +kubebuilder:validation:XValidation:rule="self.routeDisposition == 'AcceptRoute' || !has(self.bgpActions)",message="bgpActions cannot be specified when routeDisposition is RejectRoute"
78108
type PolicyActions struct {

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

Lines changed: 21 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: 37 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/rbac/manager-role.yaml‎

Lines changed: 8 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: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎config/rbac/role.yaml‎

Lines changed: 8 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-rp
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-rp
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]+"

‎docs/api-reference/index.md‎

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

0 commit comments

Comments
 (0)