|
| 1 | +From e2dbe69dd830d01af5bf0202b347524b3151e4e6 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Kyrylo Yatsenko <hedrok@gmail.com> |
| 3 | +Date: Fri, 19 Sep 2025 09:17:03 +0300 |
| 4 | +Subject: [PATCH] isis: fix advertise-passive-only routes install |
| 5 | + |
| 6 | +When advertise-passive-only is set don't ignore active circuits |
| 7 | +completely - we still need to install routes from those interfaces. |
| 8 | + |
| 9 | +Update test to check this. |
| 10 | + |
| 11 | +Fixes #16325 |
| 12 | + |
| 13 | +Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com> |
| 14 | +--- |
| 15 | + isisd/isis_lsp.c | 43 ++++++++----------- |
| 16 | + tests/topotests/isis_topo1/test_isis_topo1.py | 30 ++++++++++--- |
| 17 | + 2 files changed, 42 insertions(+), 31 deletions(-) |
| 18 | + |
| 19 | +diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c |
| 20 | +index d588af314c..0aefba95a2 100644 |
| 21 | +--- a/isisd/isis_lsp.c |
| 22 | ++++ b/isisd/isis_lsp.c |
| 23 | +@@ -1308,37 +1308,30 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) |
| 24 | + continue; |
| 25 | + } |
| 26 | + |
| 27 | +- if (area->advertise_passive_only && !circuit->is_passive) { |
| 28 | +- lsp_debug( |
| 29 | +- "ISIS (%s): Circuit is not passive, ignoring.", |
| 30 | +- area->area_tag); |
| 31 | +- continue; |
| 32 | +- } |
| 33 | +- |
| 34 | + uint32_t metric = area->oldmetric |
| 35 | + ? circuit->metric[level - 1] |
| 36 | + : circuit->te_metric[level - 1]; |
| 37 | + |
| 38 | +- if (circuit->ip_router && circuit->ip_addrs->count > 0) { |
| 39 | +- lsp_debug( |
| 40 | +- "ISIS (%s): Circuit has IPv4 active, adding respective TLVs.", |
| 41 | +- area->area_tag); |
| 42 | +- struct listnode *ipnode; |
| 43 | +- struct prefix_ipv4 *ipv4; |
| 44 | +- for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, ipnode, |
| 45 | +- ipv4)) |
| 46 | +- lsp_build_internal_reach_ipv4(lsp, area, ipv4, |
| 47 | +- metric); |
| 48 | +- } |
| 49 | ++ if (area->advertise_passive_only && !circuit->is_passive) { |
| 50 | ++ lsp_debug("ISIS (%s): Circuit is not passive, don't add prefixes.", |
| 51 | ++ area->area_tag); |
| 52 | ++ } else { |
| 53 | ++ if (circuit->ip_router && circuit->ip_addrs->count > 0) { |
| 54 | ++ lsp_debug("ISIS (%s): Circuit has IPv4 active, adding respective TLVs.", |
| 55 | ++ area->area_tag); |
| 56 | ++ struct listnode *ipnode; |
| 57 | ++ struct prefix_ipv4 *ipv4; |
| 58 | ++ for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, ipnode, ipv4)) |
| 59 | ++ lsp_build_internal_reach_ipv4(lsp, area, ipv4, metric); |
| 60 | ++ } |
| 61 | + |
| 62 | +- if (circuit->ipv6_router && circuit->ipv6_non_link->count > 0) { |
| 63 | +- struct listnode *ipnode; |
| 64 | +- struct prefix_ipv6 *ipv6; |
| 65 | ++ if (circuit->ipv6_router && circuit->ipv6_non_link->count > 0) { |
| 66 | ++ struct listnode *ipnode; |
| 67 | ++ struct prefix_ipv6 *ipv6; |
| 68 | + |
| 69 | +- for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, |
| 70 | +- ipnode, ipv6)) |
| 71 | +- lsp_build_internal_reach_ipv6(lsp, area, ipv6, |
| 72 | +- metric); |
| 73 | ++ for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, ipnode, ipv6)) |
| 74 | ++ lsp_build_internal_reach_ipv6(lsp, area, ipv6, metric); |
| 75 | ++ } |
| 76 | + } |
| 77 | + |
| 78 | + switch (circuit->circ_type) { |
| 79 | +diff --git a/tests/topotests/isis_topo1/test_isis_topo1.py b/tests/topotests/isis_topo1/test_isis_topo1.py |
| 80 | +index 1cec2f16f0..5d65b353cf 100644 |
| 81 | +--- a/tests/topotests/isis_topo1/test_isis_topo1.py |
| 82 | ++++ b/tests/topotests/isis_topo1/test_isis_topo1.py |
| 83 | +@@ -148,12 +148,9 @@ def test_isis_route_installation(): |
| 84 | + filename = "{0}/{1}/{1}_route.json".format(CWD, rname) |
| 85 | + expected = json.loads(open(filename, "r").read()) |
| 86 | + |
| 87 | +- def compare_isis_installed_routes(router, expected): |
| 88 | +- "Helper function to test ISIS routes installed in rib." |
| 89 | +- actual = router.vtysh_cmd("show ip route json", isjson=True) |
| 90 | +- return topotest.json_cmp(actual, expected) |
| 91 | +- |
| 92 | +- test_func = functools.partial(compare_isis_installed_routes, router, expected) |
| 93 | ++ test_func = functools.partial( |
| 94 | ++ _helper_compare_isis_installed_routes, router, expected |
| 95 | ++ ) |
| 96 | + (result, _) = topotest.run_and_expect(test_func, None, wait=1, count=10) |
| 97 | + assertmsg = "Router '{}' routes mismatch".format(rname) |
| 98 | + assert result, assertmsg |
| 99 | +@@ -565,6 +562,21 @@ def test_isis_advertise_passive_only(): |
| 100 | + ) |
| 101 | + assert result is True, result |
| 102 | + |
| 103 | ++ logger.info("Checking router for installed ISIS routes with advertise-passive-only") |
| 104 | ++ |
| 105 | ++ # routes must be installed |
| 106 | ++ rname = "r1" |
| 107 | ++ router = r1 |
| 108 | ++ filename = "{0}/{1}/{1}_route.json".format(CWD, rname) |
| 109 | ++ expected = json.loads(open(filename, "r").read()) |
| 110 | ++ |
| 111 | ++ test_func = functools.partial( |
| 112 | ++ _helper_compare_isis_installed_routes, router, expected |
| 113 | ++ ) |
| 114 | ++ (result, _) = topotest.run_and_expect(test_func, None, wait=1, count=10) |
| 115 | ++ assertmsg = "Router '{}' routes mismatch:\n{}".format(rname, _) |
| 116 | ++ assert result, assertmsg |
| 117 | ++ |
| 118 | + |
| 119 | + def test_isis_hello_padding_during_adjacency_formation(): |
| 120 | + """Check that IIH packets is only padded when adjacency is still being formed |
| 121 | +@@ -842,3 +854,9 @@ def parse_topology(lines, level): |
| 122 | + continue |
| 123 | + |
| 124 | + return areas |
| 125 | ++ |
| 126 | ++ |
| 127 | ++def _helper_compare_isis_installed_routes(router, expected): |
| 128 | ++ "Helper function to test ISIS routes installed in rib." |
| 129 | ++ actual = router.vtysh_cmd("show ip route json", isjson=True) |
| 130 | ++ return topotest.json_cmp(actual, expected) |
| 131 | +-- |
| 132 | +2.50.1 |
| 133 | + |
0 commit comments