forked from Mirror/frr
isisd: Even after configuring "no hostname dynamic", the topology still displays the hostname.
The command "show isis topology" calls print_sys_hostname() to display the system ID or hostname, but it does not check the area->dynhostname flag. Signed-off-by: zhou-run <zhou.run@h3c.com>
This commit is contained in:
parent
045029e244
commit
0db469958c
|
@ -370,18 +370,20 @@ const char *print_sys_hostname(const uint8_t *sysid)
|
||||||
struct isis_dynhn *dyn;
|
struct isis_dynhn *dyn;
|
||||||
struct isis *isis = NULL;
|
struct isis *isis = NULL;
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
|
struct isis_area *area = NULL;
|
||||||
|
|
||||||
if (!sysid)
|
if (!sysid)
|
||||||
return "nullsysid";
|
return "nullsysid";
|
||||||
|
|
||||||
/* For our system ID return our host name */
|
/* For our system ID return our host name */
|
||||||
isis = isis_lookup_by_sysid(sysid);
|
area = isis_area_lookup_by_sysid(sysid);
|
||||||
if (isis && !CHECK_FLAG(im->options, F_ISIS_UNIT_TEST))
|
if (area && area->dynhostname && !CHECK_FLAG(im->options, F_ISIS_UNIT_TEST))
|
||||||
return cmd_hostname_get();
|
return cmd_hostname_get();
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
|
for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
|
||||||
|
area = isis_area_lookup_by_sysid(isis->sysid);
|
||||||
dyn = dynhn_find_by_id(isis, sysid);
|
dyn = dynhn_find_by_id(isis, sysid);
|
||||||
if (dyn)
|
if (area && area->dynhostname && dyn)
|
||||||
return dyn->hostname;
|
return dyn->hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ void isis_area_del_circuit(struct isis_area *area, struct isis_circuit *circuit)
|
||||||
isis_csm_state_change(ISIS_DISABLE, circuit, area);
|
isis_csm_state_change(ISIS_DISABLE, circuit, area);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_area_addr(void *arg)
|
void isis_area_address_delete(void *arg)
|
||||||
{
|
{
|
||||||
struct iso_address *addr = (struct iso_address *)arg;
|
struct iso_address *addr = (struct iso_address *)arg;
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ struct isis_area *isis_area_create(const char *area_tag, const char *vrf_name)
|
||||||
area->circuit_list = list_new();
|
area->circuit_list = list_new();
|
||||||
area->adjacency_list = list_new();
|
area->adjacency_list = list_new();
|
||||||
area->area_addrs = list_new();
|
area->area_addrs = list_new();
|
||||||
area->area_addrs->del = delete_area_addr;
|
area->area_addrs->del = isis_area_address_delete;
|
||||||
|
|
||||||
if (!CHECK_FLAG(im->options, F_ISIS_UNIT_TEST))
|
if (!CHECK_FLAG(im->options, F_ISIS_UNIT_TEST))
|
||||||
event_add_timer(master, lsp_tick, area, 1, &area->t_tick);
|
event_add_timer(master, lsp_tick, area, 1, &area->t_tick);
|
||||||
|
@ -471,6 +471,29 @@ struct isis_area *isis_area_lookup(const char *area_tag, vrf_id_t vrf_id)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct isis_area *isis_area_lookup_by_sysid(const uint8_t *sysid)
|
||||||
|
{
|
||||||
|
struct isis_area *area;
|
||||||
|
struct listnode *node;
|
||||||
|
struct isis *isis;
|
||||||
|
struct iso_address *addr = NULL;
|
||||||
|
|
||||||
|
isis = isis_lookup_by_sysid(sysid);
|
||||||
|
if (isis == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
|
||||||
|
if (listcount(area->area_addrs) > 0) {
|
||||||
|
addr = listgetdata(listhead(area->area_addrs));
|
||||||
|
if (!memcmp(addr->area_addr + addr->addr_len, sysid,
|
||||||
|
ISIS_SYS_ID_LEN))
|
||||||
|
return area;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int isis_area_get(struct vty *vty, const char *area_tag)
|
int isis_area_get(struct vty *vty, const char *area_tag)
|
||||||
{
|
{
|
||||||
struct isis_area *area;
|
struct isis_area *area;
|
||||||
|
|
|
@ -285,10 +285,12 @@ void isis_area_add_circuit(struct isis_area *area,
|
||||||
void isis_area_del_circuit(struct isis_area *area,
|
void isis_area_del_circuit(struct isis_area *area,
|
||||||
struct isis_circuit *circuit);
|
struct isis_circuit *circuit);
|
||||||
|
|
||||||
|
void isis_area_address_delete(void *arg);
|
||||||
struct isis_area *isis_area_create(const char *, const char *);
|
struct isis_area *isis_area_create(const char *, const char *);
|
||||||
struct isis_area *isis_area_lookup(const char *, vrf_id_t vrf_id);
|
struct isis_area *isis_area_lookup(const char *, vrf_id_t vrf_id);
|
||||||
struct isis_area *isis_area_lookup_by_vrf(const char *area_tag,
|
struct isis_area *isis_area_lookup_by_vrf(const char *area_tag,
|
||||||
const char *vrf_name);
|
const char *vrf_name);
|
||||||
|
struct isis_area *isis_area_lookup_by_sysid(const uint8_t *sysid);
|
||||||
int isis_area_get(struct vty *vty, const char *area_tag);
|
int isis_area_get(struct vty *vty, const char *area_tag);
|
||||||
void isis_area_destroy(struct isis_area *area);
|
void isis_area_destroy(struct isis_area *area);
|
||||||
void isis_filter_update(struct access_list *access);
|
void isis_filter_update(struct access_list *access);
|
||||||
|
|
|
@ -245,12 +245,25 @@ static int test_run(struct vty *vty, const struct isis_topology *topology,
|
||||||
struct isis_area *area;
|
struct isis_area *area;
|
||||||
struct lfa_protected_resource protected_resource = {};
|
struct lfa_protected_resource protected_resource = {};
|
||||||
uint8_t fail_id[ISIS_SYS_ID_LEN] = {};
|
uint8_t fail_id[ISIS_SYS_ID_LEN] = {};
|
||||||
|
static char sysidstr[ISO_SYSID_STRLEN];
|
||||||
|
char net_title[255];
|
||||||
|
uint8_t buff[255];
|
||||||
|
struct iso_address *addr = NULL;
|
||||||
|
|
||||||
/* Init topology. */
|
/* Init topology. */
|
||||||
area = isis_area_create("1", NULL);
|
area = isis_area_create("1", NULL);
|
||||||
memcpy(area->isis->sysid, root->sysid, sizeof(area->isis->sysid));
|
memcpy(area->isis->sysid, root->sysid, sizeof(area->isis->sysid));
|
||||||
area->is_type = IS_LEVEL_1_AND_2;
|
area->is_type = IS_LEVEL_1_AND_2;
|
||||||
area->srdb.enabled = true;
|
area->srdb.enabled = true;
|
||||||
|
area->area_addrs = list_new();
|
||||||
|
area->area_addrs->del = isis_area_address_delete;
|
||||||
|
addr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct iso_address));
|
||||||
|
snprintfrr(sysidstr, sizeof(sysidstr), "%pSY", area->isis->sysid);
|
||||||
|
snprintf(net_title, sizeof(net_title), "49.%s.00", sysidstr);
|
||||||
|
addr->addr_len = dotformat2buff(buff, net_title);
|
||||||
|
memcpy(addr->area_addr, buff, addr->addr_len);
|
||||||
|
addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
|
||||||
|
listnode_add(area->area_addrs, addr);
|
||||||
if (test_topology_load(topology, area, area->lspdb) != 0) {
|
if (test_topology_load(topology, area, area->lspdb) != 0) {
|
||||||
vty_out(vty, "%% Failed to load topology\n");
|
vty_out(vty, "%% Failed to load topology\n");
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
|
|
Loading…
Reference in a new issue