Skip to content

Commit e4b3a36

Browse files
committed
Add Fabric spec.bum.defaultMulticastGroup for VTEP NVE L2 group
Add spec.bum.defaultMulticastGroup to the Fabric API. It is programmed as the global L2 BUM mcast-group on every VTEP NVE, so the NX-OS provider emits "global mcast-group <addr> L2" on nve1. Previously the Fabric controller never set NVE spec.multicastGroups, so no global mcast-group was configured and L2 VNIs stayed down. When the field is unset, the value is derived from the first entry of the first PIM rendezvous-point group as a migration fallback. A CEL rule requires the explicit field when the first RP group serves more than one multicastGroups entry, where the fallback would be ambiguous. Per-VNI mcast-group overrides are not supported. Signed-off-by: Sebastian Wagner <sebastian.wagner02@sap.com>
1 parent 8c6e97c commit e4b3a36

7 files changed

Lines changed: 112 additions & 2 deletions

File tree

‎api/evpn/v1alpha1/fabric_types.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ const (
182182
// FabricBUMSpec defines how BUM (Broadcast, Unknown unicast, Multicast) traffic
183183
// is forwarded across the fabric.
184184
// +kubebuilder:validation:XValidation:rule="self.type != 'Multicast' || has(self.pim)",message="pim must be set when type is Multicast"
185+
// +kubebuilder:validation:XValidation:rule="self.type != 'Multicast' || !has(self.pim) || size(self.pim.anycastRendezvousPoints[0].multicastGroups) <= 1 || has(self.defaultMulticastGroup)",message="defaultMulticastGroup is required when the first rendezvous point serves more than one multicastGroups entry"
185186
type FabricBUMSpec struct {
186187
// type selects the BUM forwarding mechanism.
187188
// +required
@@ -190,6 +191,15 @@ type FabricBUMSpec struct {
190191
// pim configures PIM sparse mode when type is Multicast.
191192
// +optional
192193
PIM *FabricPIMSpec `json:"pim,omitempty"`
194+
195+
// defaultMulticastGroup is the IPv4 multicast group programmed as the global
196+
// Layer 2 BUM mcast-group on every VTEP NVE. If unset, it is derived from the
197+
// first entry of the first pim.anycastRendezvousPoints group; this derivation
198+
// is a migration fallback for fabrics authored before this field existed and
199+
// is only allowed when that group serves a single multicastGroups entry,
200+
// otherwise the field is required. Per-VNI mcast-group overrides are not supported.
201+
// +optional
202+
DefaultMulticastGroup *corev1alpha1.IPPrefix `json:"defaultMulticastGroup,omitempty"`
193203
}
194204

195205
// FabricPIMSpec configures PIM sparse mode for BUM traffic.

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

Lines changed: 4 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/fabrics.evpn.networking.metal.ironcore.dev.yaml‎

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

‎config/crd/bases/evpn.networking.metal.ironcore.dev_fabrics.yaml‎

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

‎docs/api-reference/index.md‎

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

‎internal/controller/evpn/fabric_controller.go‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,22 @@ func (r *FabricReconciler) reconcilePIM(ctx context.Context, deviceName string,
13151315
return nil
13161316
}
13171317

1318+
// nveL2MulticastGroup resolves the global Layer 2 BUM mcast-group for VTEP NVEs:
1319+
// spec.bum.defaultMulticastGroup if set, else the first PIM RP group as a fallback.
1320+
// Returns nil when BUM is not Multicast.
1321+
// FIXME: the RP-derivation fallback is migration-only; remove once all fabrics set
1322+
// spec.bum.defaultMulticastGroup.
1323+
func nveL2MulticastGroup(fabric *evpnv1alpha1.Fabric) *v1alpha1.IPPrefix {
1324+
if fabric.Spec.BUM.Type != evpnv1alpha1.BUMTypeMulticast {
1325+
return nil
1326+
}
1327+
if fabric.Spec.BUM.DefaultMulticastGroup != nil {
1328+
return fabric.Spec.BUM.DefaultMulticastGroup
1329+
}
1330+
// API validation guarantees PIM, an RP, and a group exist in the fallback case.
1331+
return &fabric.Spec.BUM.PIM.AnycastRendezvousPoints[0].MulticastGroups[0]
1332+
}
1333+
13181334
// reconcileVTEPNVE creates one NetworkVirtualizationEdge resource per VTEP device.
13191335
// The NVE references lo1 (primary VTEP) as source, and lo2 (anycast VTEP) as anycast
13201336
// source when spec.vtep.anycastVTEP is enabled.
@@ -1329,6 +1345,8 @@ func (r *FabricReconciler) reconcileVTEPNVE(ctx context.Context, fabric *evpnv1a
13291345
return ctrl.Result{}, fmt.Errorf("listing VTEP devices: %w", err)
13301346
}
13311347

1348+
l2Group := nveL2MulticastGroup(fabric)
1349+
13321350
for i := range devices.Items {
13331351
device := &devices.Items[i]
13341352

@@ -1342,15 +1360,15 @@ func (r *FabricReconciler) reconcileVTEPNVE(ctx context.Context, fabric *evpnv1a
13421360
continue
13431361
}
13441362

1345-
if err := r.reconcileNVE(ctx, device, fabric, lo1Name, lo2Name); err != nil {
1363+
if err := r.reconcileNVE(ctx, device, fabric, lo1Name, lo2Name, l2Group); err != nil {
13461364
return ctrl.Result{}, err
13471365
}
13481366
}
13491367
return ctrl.Result{}, nil
13501368
}
13511369

13521370
// reconcileNVE creates or updates the NetworkVirtualizationEdge resource for a VTEP device.
1353-
func (r *FabricReconciler) reconcileNVE(ctx context.Context, device *v1alpha1.Device, fabric *evpnv1alpha1.Fabric, lo1Name, lo2Name string) error {
1371+
func (r *FabricReconciler) reconcileNVE(ctx context.Context, device *v1alpha1.Device, fabric *evpnv1alpha1.Fabric, lo1Name, lo2Name string, l2Group *v1alpha1.IPPrefix) error {
13541372
name := fmt.Sprintf("%s-%s-nve", fabric.Name, device.Name)
13551373

13561374
nve := &v1alpha1.NetworkVirtualizationEdge{
@@ -1372,6 +1390,11 @@ func (r *FabricReconciler) reconcileNVE(ctx context.Context, device *v1alpha1.De
13721390
} else {
13731391
nve.Spec.AnycastSourceInterfaceRef = nil
13741392
}
1393+
// Explicit nil self-corrects when BUM leaves Multicast.
1394+
nve.Spec.MulticastGroups = nil
1395+
if l2Group != nil {
1396+
nve.Spec.MulticastGroups = &v1alpha1.MulticastGroups{L2: l2Group}
1397+
}
13751398
if fabric.Spec.VTEP.AnycastGateway != nil {
13761399
nve.Spec.AnycastGateway = &v1alpha1.AnycastGateway{
13771400
VirtualMAC: fabric.Spec.VTEP.AnycastGateway.VirtualMAC,

‎internal/controller/evpn/fabric_controller_test.go‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,13 @@ var _ = Describe("Fabric Controller", func() {
538538
g.Expect(nve.Spec.AnycastSourceInterfaceRef).NotTo(BeNil())
539539
g.Expect(nve.Spec.AnycastSourceInterfaceRef.Name).To(Equal(fabric.Name + "-" + leaf.Name + "-lo2"))
540540

541+
// L2 BUM mcast-group falls back to the PIM RP group when
542+
// spec.bum.defaultMulticastGroup is unset.
543+
g.Expect(nve.Spec.MulticastGroups).NotTo(BeNil())
544+
g.Expect(nve.Spec.MulticastGroups.L2).NotTo(BeNil())
545+
g.Expect(nve.Spec.MulticastGroups.L2.String()).To(Equal("224.0.0.0/4"))
546+
g.Expect(nve.Spec.MulticastGroups.L3).To(BeNil())
547+
541548
g.Expect(nve.OwnerReferences).To(ContainElement(SatisfyAll(
542549
HaveField("Kind", "Fabric"),
543550
HaveField("Name", fabric.Name),
@@ -1119,3 +1126,39 @@ var _ = Describe("Fabric Controller", func() {
11191126
})
11201127
})
11211128
})
1129+
1130+
var _ = Describe("nveL2MulticastGroup", func() {
1131+
rpGroup := func(groups ...string) evpnv1alpha1.FabricPIMSpec {
1132+
prefixes := make([]corev1alpha1.IPPrefix, 0, len(groups))
1133+
for _, g := range groups {
1134+
prefixes = append(prefixes, corev1alpha1.MustParsePrefix(g))
1135+
}
1136+
return evpnv1alpha1.FabricPIMSpec{
1137+
AnycastRendezvousPoints: []evpnv1alpha1.AnycastRendezvousPoint{{Name: "rp", MulticastGroups: prefixes}},
1138+
}
1139+
}
1140+
1141+
It("returns the explicit defaultMulticastGroup when set", func() {
1142+
explicit := corev1alpha1.MustParsePrefix("239.0.0.1/32")
1143+
pim := rpGroup("224.0.0.0/4")
1144+
fabric := &evpnv1alpha1.Fabric{Spec: evpnv1alpha1.FabricSpec{BUM: evpnv1alpha1.FabricBUMSpec{
1145+
Type: evpnv1alpha1.BUMTypeMulticast, PIM: &pim, DefaultMulticastGroup: &explicit,
1146+
}}}
1147+
Expect(nveL2MulticastGroup(fabric)).To(Equal(&explicit))
1148+
})
1149+
1150+
It("falls back to the first RP multicastGroups entry when the field is unset", func() {
1151+
pim := rpGroup("224.0.0.0/4")
1152+
fabric := &evpnv1alpha1.Fabric{Spec: evpnv1alpha1.FabricSpec{BUM: evpnv1alpha1.FabricBUMSpec{
1153+
Type: evpnv1alpha1.BUMTypeMulticast, PIM: &pim,
1154+
}}}
1155+
Expect(nveL2MulticastGroup(fabric).String()).To(Equal("224.0.0.0/4"))
1156+
})
1157+
1158+
It("returns nil when no group is configured", func() {
1159+
fabric := &evpnv1alpha1.Fabric{Spec: evpnv1alpha1.FabricSpec{BUM: evpnv1alpha1.FabricBUMSpec{
1160+
Type: evpnv1alpha1.BUMTypeMulticast,
1161+
}}}
1162+
Expect(nveL2MulticastGroup(fabric)).To(BeNil())
1163+
})
1164+
})

0 commit comments

Comments
 (0)