From: Donald Sharp Date: Tue, 22 Jun 2021 16:44:24 +0000 (-0400) Subject: isisd: using argv as a string name is categorically wrong X-Git-Tag: base_8.1~400^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=1d88e63a4e3d29cec6f49602e3263f13a8de3d1e;p=matthieu%2Ffrr.git isisd: using argv as a string name is categorically wrong We are passing around the system id using the variable name of `argv`. Let's name the variable correctly and pass it around correctly named. Signed-off-by: Donald Sharp --- diff --git a/isisd/isis_vty_fabricd.c b/isisd/isis_vty_fabricd.c index a19fcc240f..2c1b6e932f 100644 --- a/isisd/isis_vty_fabricd.c +++ b/isisd/isis_vty_fabricd.c @@ -187,7 +187,7 @@ DEFUN (show_lsp_flooding, vty_out(vty, "Area %s:\n", area->area_tag ? area->area_tag : "null"); if (lspid) { - lsp = lsp_for_arg(head, lspid, isis); + lsp = lsp_for_sysid(head, lspid, isis); if (lsp) lsp_print_flooding(vty, lsp, isis); continue; diff --git a/isisd/isisd.c b/isisd/isisd.c index ed55e3ba48..bdc5edf201 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -2170,8 +2170,8 @@ DEFUN(show_isis_summary, show_isis_summary_cmd, return CMD_SUCCESS; } -struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv, - struct isis *isis) +struct isis_lsp *lsp_for_sysid(struct lspdb_head *head, const char *sysid_str, + struct isis *isis) { char sysid[255] = {0}; uint8_t number[3]; @@ -2180,11 +2180,11 @@ struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv, struct isis_dynhn *dynhn; struct isis_lsp *lsp = NULL; - if (!argv) + if (!sysid_str) return NULL; /* - * extract fragment and pseudo id from the string argv + * extract fragment and pseudo id from the string sysid_str * in the forms: * (a) .- or * (b) . or @@ -2192,10 +2192,10 @@ struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv, * Where systemid is in the form: * xxxx.xxxx.xxxx */ - strlcpy(sysid, argv, sizeof(sysid)); + strlcpy(sysid, sysid_str, sizeof(sysid)); - if (strlen(argv) > 3) { - pos = argv + strlen(argv) - 3; + if (strlen(sysid_str) > 3) { + pos = sysid_str + strlen(sysid_str) - 3; if (strncmp(pos, "-", 1) == 0) { memcpy(number, ++pos, 2); lspid[ISIS_SYS_ID_LEN + 1] = @@ -2208,14 +2208,13 @@ struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv, memcpy(number, ++pos, 2); lspid[ISIS_SYS_ID_LEN] = (uint8_t)strtol((char *)number, NULL, 16); - sysid[pos - argv - 1] = '\0'; + sysid[pos - sysid_str - 1] = '\0'; } } /* - * Try to find the lsp-id if the argv - * string is in - * the form + * Try to find the lsp-id if the sysid_str + * is in the form * hostname.- */ if (sysid2buff(lspid, sysid)) { @@ -2233,15 +2232,15 @@ struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv, void show_isis_database_lspdb(struct vty *vty, struct isis_area *area, int level, struct lspdb_head *lspdb, - const char *argv, int ui_level) + const char *sysid_str, int ui_level) { struct isis_lsp *lsp; int lsp_count; if (lspdb_count(lspdb) > 0) { - lsp = lsp_for_arg(lspdb, argv, area->isis); + lsp = lsp_for_sysid(lspdb, sysid_str, area->isis); - if (lsp != NULL || argv == NULL) { + if (lsp != NULL || sysid_str == NULL) { vty_out(vty, "IS-IS Level-%d link-state database:\n", level + 1); @@ -2257,7 +2256,7 @@ void show_isis_database_lspdb(struct vty *vty, struct isis_area *area, else lsp_print(lsp, vty, area->dynhostname, area->isis); - } else if (argv == NULL) { + } else if (sysid_str == NULL) { lsp_count = lsp_print_all(vty, lspdb, ui_level, area->dynhostname, area->isis); @@ -2267,7 +2266,7 @@ void show_isis_database_lspdb(struct vty *vty, struct isis_area *area, } } -static void show_isis_database_common(struct vty *vty, const char *argv, +static void show_isis_database_common(struct vty *vty, const char *sysid_str, int ui_level, struct isis *isis) { struct listnode *node; @@ -2283,7 +2282,7 @@ static void show_isis_database_common(struct vty *vty, const char *argv, for (level = 0; level < ISIS_LEVELS; level++) show_isis_database_lspdb(vty, area, level, - &area->lspdb[level], argv, + &area->lspdb[level], sysid_str, ui_level); } } @@ -2303,8 +2302,8 @@ static void show_isis_database_common(struct vty *vty, const char *argv, * [ show isis database detail .- ] * [ show isis database detail .- ] */ -static int show_isis_database(struct vty *vty, const char *argv, int ui_level, - const char *vrf_name, bool all_vrf) +static int show_isis_database(struct vty *vty, const char *sysid_str, + int ui_level, const char *vrf_name, bool all_vrf) { struct listnode *node; struct isis *isis; @@ -2312,14 +2311,15 @@ static int show_isis_database(struct vty *vty, const char *argv, int ui_level, if (vrf_name) { if (all_vrf) { for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) - show_isis_database_common(vty, argv, ui_level, - isis); + show_isis_database_common(vty, sysid_str, + ui_level, isis); return CMD_SUCCESS; } isis = isis_lookup_by_vrfname(vrf_name); if (isis) - show_isis_database_common(vty, argv, ui_level, isis); + show_isis_database_common(vty, sysid_str, ui_level, + isis); } return CMD_SUCCESS; diff --git a/isisd/isisd.h b/isisd/isisd.h index b2c9af55b7..60dcf066dd 100644 --- a/isisd/isisd.h +++ b/isisd/isisd.h @@ -274,8 +274,8 @@ void isis_area_destroy(struct isis_area *area); void isis_filter_update(struct access_list *access); void isis_prefix_list_update(struct prefix_list *plist); void print_debug(struct vty *, int, int); -struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv, - struct isis *isis); +struct isis_lsp *lsp_for_sysid(struct lspdb_head *head, const char *sysid_str, + struct isis *isis); void isis_area_invalidate_routes(struct isis_area *area, int levels); void isis_area_verify_routes(struct isis_area *area);