@@ -838,12 +838,15 @@ var _ = Describe("Multi Homing", func() {
838838 excludedSubnetLowerRange2 = "60.128.0.128/26" // Excludes IPs from 60.128.0.128 to 60.128.0.191
839839 excludedSubnetUpperRange1 = "60.128.0.208/28" // Excludes IPs from 60.128.0.208 to 60.128.0.223
840840 excludedSubnetUpperRange2 = "60.128.0.224/27" // Excludes IPs from 60.128.0.224 to 60.128.0.255
841+ newLocalnetVLANID = 30
841842 )
842843 BeforeEach (func () {
843844 By ("setting new MTU" )
844845 netConfig .mtu = expectedChangedMTU
845846 By ("setting new subnets to leave a smaller range" )
846847 netConfig .excludeCIDRs = []string {excludedSubnetLowerRange1 , excludedSubnetLowerRange2 , excludedSubnetUpperRange1 , excludedSubnetUpperRange2 }
848+ By ("setting new VLAN-ID" )
849+ netConfig .vlanID = newLocalnetVLANID
847850 p := []byte (fmt .Sprintf (`[{"op":"replace","path":"/spec/config","value":%q}]` , generateNADSpec (netConfig )))
848851 Expect (patchNADSpec (nadClient , netConfig .name , netConfig .namespace , p )).To (Succeed ())
849852 })
@@ -896,6 +899,55 @@ var _ = Describe("Multi Homing", func() {
896899 return nil
897900 }).Should (Succeed (), "pod's secondary NIC is not allocated in the desired range" )
898901 })
902+
903+ It ("can no longer communicate over a localnet secondary network from pod to the underlay service" , func () {
904+ Eventually (func () error {
905+ clientPodConfig := podConfiguration {
906+ name : clientPodName ,
907+ namespace : f .Namespace .Name ,
908+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
909+ }
910+ kickstartPod (cs , clientPodConfig )
911+
912+ By ("asserting the *client* pod can no longer contact the underlay service" )
913+ var err error
914+ if err = connectToServer (clientPodConfig , underlayServiceIP , servicePort ); err != nil && strings .Contains (err .Error (), "exit code 28" ) {
915+ return nil
916+ }
917+ err = fmt .Errorf ("expected exit code 28 from underlay service, got err %w" , err )
918+
919+ if delErr := cs .CoreV1 ().Pods (clientPodConfig .namespace ).Delete (context .Background (), clientPodConfig .name , metav1.DeleteOptions {}); delErr != nil {
920+ err = errors .Join (err , fmt .Errorf ("pod delete failed: %w" , delErr ))
921+ }
922+ return err
923+ }).Should (Succeed (), "pod should be disconnected from underlay" )
924+ })
925+
926+ Context ("and the service connected to the underlay is reconfigured to connect to the new VLAN-ID" , func () {
927+ BeforeEach (func () {
928+ Expect (ovsRemoveSwitchPort (nodes , secondaryInterfaceName , newLocalnetVLANID )).To (Succeed ())
929+ })
930+
931+ It ("can now communicate over a localnet secondary network from pod to the underlay service" , func () {
932+ Eventually (func () error {
933+ clientPodConfig := podConfiguration {
934+ name : clientPodName ,
935+ namespace : f .Namespace .Name ,
936+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
937+ }
938+ kickstartPod (cs , clientPodConfig )
939+
940+ By ("asserting the *client* pod can contact the underlay service" )
941+ if err := connectToServer (clientPodConfig , underlayServiceIP , servicePort ); err != nil {
942+ if delErr := cs .CoreV1 ().Pods (clientPodConfig .namespace ).Delete (context .Background (), clientPodConfig .name , metav1.DeleteOptions {}); delErr != nil {
943+ err = errors .Join (err , fmt .Errorf ("pod delete failed: %w" , delErr ))
944+ }
945+ return err
946+ }
947+ return nil
948+ }).Should (Succeed (), "pod should be connected to underlay" )
949+ })
950+ })
899951 })
900952
901953 Context ("with multi network policy blocking the traffic" , func () {
0 commit comments