(t *testing.T)
| 331 | } |
| 332 | |
| 333 | func TestRouterNet4A_OverlappingServiceHoldLoop(t *testing.T) { |
| 334 | tunables := ConfigureConstants() |
| 335 | // This test is for the following network with our router being A: |
| 336 | // Note, X is a service that both S and D advertise |
| 337 | |
| 338 | // C |
| 339 | // | 1 |
| 340 | // (S,X) --- A --- B --- (D,X) |
| 341 | // 1 1 1 |
| 342 | |
| 343 | h := &RouterHarness{} |
| 344 | rs := &state.RouterState{ |
| 345 | RouterTunables: tunables, |
| 346 | Id: "A", |
| 347 | SelfSeqno: make(map[netip.Prefix]uint16), |
| 348 | Routes: make(map[netip.Prefix]state.SelRoute), |
| 349 | Sources: make(map[state.Source]state.FD), |
| 350 | Neighbours: MakeNeighbours("S", "B", "C"), |
| 351 | Advertised: map[netip.Prefix]state.Advertisement{nodeToPrefix("A"): {NodeId: state.NodeId("A"), Expiry: maxTime}}, |
| 352 | } |
| 353 | |
| 354 | SA := AddLink(rs, NewMockEndpoint("S", 1)) |
| 355 | _ = AddLink(rs, NewMockEndpoint("C", 1)) |
| 356 | _ = AddLink(rs, NewMockEndpoint("B", 1)) |
| 357 | |
| 358 | // S's advertised routes |
| 359 | h.NeighUpdate(rs, "S", "S", nodeToPrefix("S"), 0, 0) |
| 360 | h.NeighUpdateSvc(rs, "S", "S", nodeToPrefix("X"), 0, 0) |
| 361 | |
| 362 | // B's advertised routes |
| 363 | h.NeighUpdate(rs, "B", "B", nodeToPrefix("B"), 0, 0) |
| 364 | h.NeighUpdateSvc(rs, "B", "D", nodeToPrefix("X"), 0, 1) |
| 365 | |
| 366 | // C's advertised routes |
| 367 | h.NeighUpdate(rs, "C", "C", nodeToPrefix("C"), 0, 0) |
| 368 | |
| 369 | ComputeRoutes(rs, h) |
| 370 | a := h.GetActions() |
| 371 | a.AssertEqual(t, |
| 372 | BroadcastUpdateRoute(MakePubRoute("A", nodeToPrefix("A"), 0, 0)), |
| 373 | BroadcastUpdateRoute(MakePubRoute("B", nodeToPrefix("B"), 0, 1)), |
| 374 | BroadcastUpdateRoute(MakePubRoute("C", nodeToPrefix("C"), 0, 1)), |
| 375 | BroadcastUpdateRoute(MakePubRoute("S", nodeToPrefix("S"), 0, 1)), |
| 376 | BroadcastUpdateRoute(MakePubRoute("S", nodeToPrefix("X"), 0, 1)), |
| 377 | ) |
| 378 | assert.Equal(t, `10.0.0.1/32 via (nh: A, router: A, prefix: 10.0.0.1/32, seqno: 0, metric: 0) |
| 379 | 10.0.0.19/32 via (nh: S, router: S, prefix: 10.0.0.19/32, seqno: 0, metric: 1) |
| 380 | 10.0.0.2/32 via (nh: B, router: B, prefix: 10.0.0.2/32, seqno: 0, metric: 1) |
| 381 | 10.0.0.24/32 via (nh: S, router: S, prefix: 10.0.0.24/32, seqno: 0, metric: 1) |
| 382 | 10.0.0.3/32 via (nh: C, router: C, prefix: 10.0.0.3/32, seqno: 0, metric: 1)`, rs.StringRoutes()) |
| 383 | |
| 384 | // Now, lets cut off both S from A and D from B, to see if we can produce a routing loop |
| 385 | // C |
| 386 | // | 1 |
| 387 | // (S,X) A --- B (D,X) |
| 388 | // 1 |
| 389 | RemoveLink(rs, SA) |
| 390 | ComputeRoutes(rs, h) |
nothing calls this directly
no test coverage detected