From f4c954b09ee8c8376ea39f32de49406a38597015 Mon Sep 17 00:00:00 2001 From: Yamato Sugawara Date: Tue, 9 Nov 2021 12:35:35 +0000 Subject: [PATCH] zebra: apply the suggestion by reviewer Signed-off-by: Yamato Sugawara --- bgpd/bgp_vty.c | 3 ++- lib/srv6.c | 3 +-- lib/srv6.h | 2 +- .../srv6_locator_chunks/step1/expected_bgpd_chunks.json | 2 +- .../srv6_locator_chunks/step2/expected_bgpd_chunks.json | 2 +- .../srv6_locator_chunks/step3/expected_bgpd_chunks.json | 2 +- .../srv6_locator_chunks/step4/expected_bgpd_chunks.json | 2 +- .../srv6_locator_chunks/step5/expected_bgpd_chunks.json | 2 +- .../srv6_locator_chunks/step6/expected_bgpd_chunks.json | 2 +- .../srv6_locator_chunks/test_srv6_locator_chunks.py | 6 ++++++ zebra/zebra_srv6.c | 2 +- zebra/zebra_srv6_vty.c | 2 +- 12 files changed, 18 insertions(+), 12 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index f15ce787e8f2..00845528035d 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9243,7 +9243,8 @@ DEFPY (no_bgp_srv6_locator, return CMD_SUCCESS; } -DEFPY(show_bgp_srv6, show_bgp_srv6_cmd, "show bgp segment-routing srv6 [json]", +DEFPY(show_bgp_srv6, show_bgp_srv6_cmd, + "show bgp segment-routing srv6 [json]", SHOW_STR BGP_STR "BGP Segment Routing\n" "BGP Segment Routing SRv6\n" JSON_STR) diff --git a/lib/srv6.c b/lib/srv6.c index 4b201dacbacf..d11bfb015163 100644 --- a/lib/srv6.c +++ b/lib/srv6.c @@ -170,11 +170,10 @@ bool srv6_locator_chunks_exhausted(const struct srv6_locator *loc) struct listnode *node; struct srv6_locator_chunk *chunk; - for (ALL_LIST_ELEMENTS_RO(loc->chunks, node, chunk)) { + for (ALL_LIST_ELEMENTS_RO(loc->chunks, node, chunk)) if (chunk->proto == 0 && chunk->instance == 0 && chunk->session_id == 0 && chunk->keep == 0) return false; - } return true; } diff --git a/lib/srv6.h b/lib/srv6.h index 14a3b7345b85..769c63cfc98d 100644 --- a/lib/srv6.h +++ b/lib/srv6.h @@ -90,7 +90,7 @@ struct srv6_locator { uint64_t current; bool status_up; struct list *chunks; - uint8_t perchunk_bits_length; + uint8_t chunk_bits_length; QOBJ_FIELDS; }; diff --git a/tests/topotests/srv6_locator_chunks/step1/expected_bgpd_chunks.json b/tests/topotests/srv6_locator_chunks/step1/expected_bgpd_chunks.json index e17d33618b36..67229e7f229f 100644 --- a/tests/topotests/srv6_locator_chunks/step1/expected_bgpd_chunks.json +++ b/tests/topotests/srv6_locator_chunks/step1/expected_bgpd_chunks.json @@ -17,4 +17,4 @@ } } ] -} \ No newline at end of file +} diff --git a/tests/topotests/srv6_locator_chunks/step2/expected_bgpd_chunks.json b/tests/topotests/srv6_locator_chunks/step2/expected_bgpd_chunks.json index e17d33618b36..67229e7f229f 100644 --- a/tests/topotests/srv6_locator_chunks/step2/expected_bgpd_chunks.json +++ b/tests/topotests/srv6_locator_chunks/step2/expected_bgpd_chunks.json @@ -17,4 +17,4 @@ } } ] -} \ No newline at end of file +} diff --git a/tests/topotests/srv6_locator_chunks/step3/expected_bgpd_chunks.json b/tests/topotests/srv6_locator_chunks/step3/expected_bgpd_chunks.json index 246377c576d0..d9765e6a6d5e 100644 --- a/tests/topotests/srv6_locator_chunks/step3/expected_bgpd_chunks.json +++ b/tests/topotests/srv6_locator_chunks/step3/expected_bgpd_chunks.json @@ -18,4 +18,4 @@ } } ] -} \ No newline at end of file +} diff --git a/tests/topotests/srv6_locator_chunks/step4/expected_bgpd_chunks.json b/tests/topotests/srv6_locator_chunks/step4/expected_bgpd_chunks.json index 246377c576d0..d9765e6a6d5e 100644 --- a/tests/topotests/srv6_locator_chunks/step4/expected_bgpd_chunks.json +++ b/tests/topotests/srv6_locator_chunks/step4/expected_bgpd_chunks.json @@ -18,4 +18,4 @@ } } ] -} \ No newline at end of file +} diff --git a/tests/topotests/srv6_locator_chunks/step5/expected_bgpd_chunks.json b/tests/topotests/srv6_locator_chunks/step5/expected_bgpd_chunks.json index e17d33618b36..67229e7f229f 100644 --- a/tests/topotests/srv6_locator_chunks/step5/expected_bgpd_chunks.json +++ b/tests/topotests/srv6_locator_chunks/step5/expected_bgpd_chunks.json @@ -17,4 +17,4 @@ } } ] -} \ No newline at end of file +} diff --git a/tests/topotests/srv6_locator_chunks/step6/expected_bgpd_chunks.json b/tests/topotests/srv6_locator_chunks/step6/expected_bgpd_chunks.json index e17d33618b36..67229e7f229f 100644 --- a/tests/topotests/srv6_locator_chunks/step6/expected_bgpd_chunks.json +++ b/tests/topotests/srv6_locator_chunks/step6/expected_bgpd_chunks.json @@ -17,4 +17,4 @@ } } ] -} \ No newline at end of file +} diff --git a/tests/topotests/srv6_locator_chunks/test_srv6_locator_chunks.py b/tests/topotests/srv6_locator_chunks/test_srv6_locator_chunks.py index 3f6ff618bf29..71bb4a36c651 100755 --- a/tests/topotests/srv6_locator_chunks/test_srv6_locator_chunks.py +++ b/tests/topotests/srv6_locator_chunks/test_srv6_locator_chunks.py @@ -73,6 +73,7 @@ def teardown_module(mod): tgen = get_topogen() tgen.stop_topology() + def get_locator_chunk_from_bgpd(router, locator): router.vtysh_cmd( """ @@ -83,11 +84,13 @@ def get_locator_chunk_from_bgpd(router, locator): """.format(locator) ) + def get_locator_chunk_from_sharpd(router, locator): router.vtysh_cmd( "sharp srv6-manager get-locator-chunk {}".format(locator) ) + def release_locator_chunk_from_bgpd(router, locator): router.vtysh_cmd( """ @@ -98,11 +101,13 @@ def release_locator_chunk_from_bgpd(router, locator): """.format(locator) ) + def release_locator_chunk_from_sharpd(router, locator): router.vtysh_cmd( "sharp srv6-manager release-locator-chunk {}".format(locator) ) + def test_srv6(): tgen = get_topogen() if tgen.routers_have_failure(): @@ -182,6 +187,7 @@ def check_bgpd_chunk(router, expected_file): check_sharpd_chunk(router, "step6/expected_sharpd_chunks.json") check_bgpd_chunk(router, "step6/expected_bgpd_chunks.json") + if __name__ == "__main__": args = ["-s"] + sys.argv[1:] sys.exit(pytest.main(args)) diff --git a/zebra/zebra_srv6.c b/zebra/zebra_srv6.c index b1c8fbade48a..a5bf2966c3b2 100644 --- a/zebra/zebra_srv6.c +++ b/zebra/zebra_srv6.c @@ -221,7 +221,7 @@ separate_locator_prefix_into_chunk(struct srv6_locator *loc, uint16_t chunk_index) { struct prefix_ipv6 chunk_prefix = loc->prefix; - chunk_prefix.prefixlen += loc->perchunk_bits_length; + chunk_prefix.prefixlen += loc->chunk_bits_length; chunk_prefix.prefix.s6_addr32[2] = (uint32_t)htons(chunk_index); return chunk_prefix; } diff --git a/zebra/zebra_srv6_vty.c b/zebra/zebra_srv6_vty.c index 777acbc97301..1ca44cb5a4c8 100644 --- a/zebra/zebra_srv6_vty.c +++ b/zebra/zebra_srv6_vty.c @@ -302,7 +302,7 @@ DEFPY (locator_prefix, // currently srv6 manager supports the chunk_length to only 4 bits. // the feature enables us to manipulate at most 16 chunks. - locator->perchunk_bits_length = DEFAULT_SRV6_LOCATOR_PERCHUNK_LEN; + locator->chunk_bits_length = DEFAULT_SRV6_LOCATOR_PERCHUNK_LEN; if (!list_isempty(locator->chunks)) { for (ALL_LIST_ELEMENTS_RO(locator->chunks, node, chunk)) {