@@ -22,6 +22,7 @@ import (
2222 ctesting "k8s.io/client-go/testing"
2323 "k8s.io/client-go/tools/cache"
2424 "k8s.io/client-go/util/workqueue"
25+ "k8s.io/utils/ptr"
2526
2627 "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config"
2728 controllerutil "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/controller"
@@ -102,14 +103,16 @@ func (tn testNode) Node() *corev1.Node {
102103type testNeighbor struct {
103104 ASN uint32
104105 Address string
106+ DisableMP * bool
105107 Receive []string
106108 Advertise []string
107109}
108110
109111func (tn testNeighbor ) Neighbor () frrapi.Neighbor {
110112 n := frrapi.Neighbor {
111- ASN : tn .ASN ,
112- Address : tn .Address ,
113+ ASN : tn .ASN ,
114+ Address : tn .Address ,
115+ DisableMP : true ,
113116 ToReceive : frrapi.Receive {
114117 Allowed : frrapi.AllowedInPrefixes {
115118 Mode : frrapi .AllowRestricted ,
@@ -122,6 +125,9 @@ func (tn testNeighbor) Neighbor() frrapi.Neighbor {
122125 },
123126 },
124127 }
128+ if tn .DisableMP != nil {
129+ n .DisableMP = * tn .DisableMP
130+ }
125131 for _ , receive := range tn .Receive {
126132 sep := strings .LastIndex (receive , "/" )
127133 if sep == - 1 {
@@ -365,6 +371,39 @@ func TestController_reconcile(t *testing.T) {
365371 },
366372 expectNADAnnotations : map [string ]map [string ]string {"default" : {types .OvnRouteAdvertisementsKey : "[\" ra\" ]" }},
367373 },
374+ {
375+ name : "reconciles dual-stack pod+eip RouteAdvertisement for a single FRR config, node and default network and target VRF" ,
376+ ra : & testRA {Name : "ra" , AdvertisePods : true , AdvertiseEgressIPs : true },
377+ frrConfigs : []* testFRRConfig {
378+ {
379+ Name : "frrConfig" ,
380+ Namespace : frrNamespace ,
381+ Routers : []* testRouter {
382+ {ASN : 1 , Prefixes : []string {"1.1.1.0/24" }, Neighbors : []* testNeighbor {
383+ {ASN : 1 , Address : "1.0.0.100" },
384+ {ASN : 1 , Address : "fd02::ffff:100:64" },
385+ }},
386+ },
387+ },
388+ },
389+ nodes : []* testNode {{Name : "node" , SubnetsAnnotation : "{\" default\" :[\" 1.1.0.0/24\" ,\" fd01::/64\" ]}" }},
390+ eips : []* testEIP {{Name : "eipv4" , EIPs : map [string ]string {"node" : "1.0.1.1" }}, {Name : "eipv6" , EIPs : map [string ]string {"node" : "fd03::ffff:100:101" }}},
391+ reconcile : "ra" ,
392+ expectAcceptedStatus : metav1 .ConditionTrue ,
393+ expectFRRConfigs : []* testFRRConfig {
394+ {
395+ Labels : map [string ]string {types .OvnRouteAdvertisementsKey : "ra" },
396+ Annotations : map [string ]string {types .OvnRouteAdvertisementsKey : "ra/frrConfig/node" },
397+ NodeSelector : map [string ]string {"kubernetes.io/hostname" : "node" },
398+ Routers : []* testRouter {
399+ {ASN : 1 , Prefixes : []string {"1.0.1.1/32" , "1.1.0.0/24" , "fd01::/64" , "fd03::ffff:100:101/128" }, Neighbors : []* testNeighbor {
400+ {ASN : 1 , Address : "1.0.0.100" , Advertise : []string {"1.0.1.1/32" , "1.1.0.0/24" }, Receive : []string {"1.1.0.0/16/24" }},
401+ {ASN : 1 , Address : "fd02::ffff:100:64" , Advertise : []string {"fd01::/64" , "fd03::ffff:100:101/128" }, Receive : []string {"fd01::/48/64" }},
402+ }},
403+ }},
404+ },
405+ expectNADAnnotations : map [string ]map [string ]string {"default" : {types .OvnRouteAdvertisementsKey : "[\" ra\" ]" }},
406+ },
368407 {
369408 name : "reconciles pod RouteAdvertisement for a single FRR config, node, non default networks and default target VRF" ,
370409 ra : & testRA {Name : "ra" , AdvertisePods : true , NetworkSelector : map [string ]string {"selected" : "true" }},
@@ -785,6 +824,24 @@ func TestController_reconcile(t *testing.T) {
785824 reconcile : "ra" ,
786825 expectAcceptedStatus : metav1 .ConditionFalse ,
787826 },
827+ {
828+ name : "fails to reconcile if DisableMP is unset" ,
829+ ra : & testRA {Name : "ra" , AdvertisePods : true },
830+ frrConfigs : []* testFRRConfig {
831+ {
832+ Name : "frrConfig" ,
833+ Namespace : frrNamespace ,
834+ Routers : []* testRouter {
835+ {ASN : 1 , Prefixes : []string {"1.1.1.0/24" }, Neighbors : []* testNeighbor {
836+ {ASN : 1 , Address : "1.0.0.100" , DisableMP : ptr .To (false )},
837+ }},
838+ },
839+ },
840+ },
841+ nodes : []* testNode {{Name : "node" , SubnetsAnnotation : "{\" default\" :\" 1.1.0.0/24\" }" }},
842+ reconcile : "ra" ,
843+ expectAcceptedStatus : metav1 .ConditionFalse ,
844+ },
788845 }
789846 for _ , tt := range tests {
790847 t .Run (tt .name , func (t * testing.T ) {
@@ -798,6 +855,10 @@ func TestController_reconcile(t *testing.T) {
798855 CIDR : ovntest .MustParseIPNet ("1.1.0.0/16" ),
799856 HostSubnetLength : 24 ,
800857 },
858+ {
859+ CIDR : ovntest .MustParseIPNet ("fd01::/48" ),
860+ HostSubnetLength : 64 ,
861+ },
801862 }
802863 config .OVNKubernetesFeature .EnableMultiNetwork = true
803864 config .OVNKubernetesFeature .EnableRouteAdvertisements = true
@@ -885,7 +946,7 @@ func TestController_reconcile(t *testing.T) {
885946 g .Expect (err ).ToNot (gomega .HaveOccurred ())
886947 accepted := meta .FindStatusCondition (ra .Status .Conditions , "Accepted" )
887948 g .Expect (accepted ).NotTo (gomega .BeNil ())
888- g .Expect (accepted .Status ).To (gomega .Equal (tt .expectAcceptedStatus ))
949+ g .Expect (accepted .Status ).To (gomega .Equal (tt .expectAcceptedStatus ), accepted . Message )
889950 }
890951
891952 // verify FRRConfigurations have been created/updated/deleted as expected
0 commit comments