From 99e5d4af38875ce1919abeabe4030ea4cfc48ed1 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 9 Oct 2020 08:00:44 -0400 Subject: [PATCH] isisd: circuit->area->isis to circuit->isis The code in isisd uses `circuit->area->isis` all the time but we know that circuit now has a valid `circuit->isis` pointer so let's use that and cleanup the long dereference. Signed-off-by: Donald Sharp --- isisd/isis_circuit.c | 6 +++--- isisd/isis_dr.c | 6 +++--- isisd/isis_lsp.c | 8 ++++---- isisd/isis_nb_config.c | 18 +++++++++--------- isisd/isis_pdu.c | 31 +++++++++++++------------------ 5 files changed, 32 insertions(+), 37 deletions(-) diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 4883e012a2..695e1318ae 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -627,8 +627,8 @@ int isis_circuit_up(struct isis_circuit *circuit) } if (circuit->circ_type == CIRCUIT_T_BROADCAST) { - circuit->circuit_id = isis_circuit_id_gen(circuit->area->isis, - circuit->interface); + circuit->circuit_id = + isis_circuit_id_gen(circuit->isis, circuit->interface); if (!circuit->circuit_id) { flog_err( EC_ISIS_CONFIG, @@ -812,7 +812,7 @@ void isis_circuit_down(struct isis_circuit *circuit) circuit->lsp_regenerate_pending[0] = 0; circuit->lsp_regenerate_pending[1] = 0; - _ISIS_CLEAR_FLAG(circuit->area->isis->circuit_ids_used, + _ISIS_CLEAR_FLAG(circuit->isis->circuit_ids_used, circuit->circuit_id); circuit->circuit_id = 0; } else if (circuit->circ_type == CIRCUIT_T_P2P) { diff --git a/isisd/isis_dr.c b/isisd/isis_dr.c index 318fb9fab8..3324d74e0f 100644 --- a/isisd/isis_dr.c +++ b/isisd/isis_dr.c @@ -225,7 +225,7 @@ int isis_dr_resign(struct isis_circuit *circuit, int level) THREAD_TIMER_OFF(circuit->u.bc.t_refresh_pseudo_lsp[level - 1]); circuit->lsp_regenerate_pending[level - 1] = 0; - memcpy(id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN); + memcpy(id, circuit->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(id) = circuit->circuit_id; LSP_FRAGMENT(id) = 0; lsp_purge_pseudo(id, circuit, level); @@ -278,7 +278,7 @@ int isis_dr_commence(struct isis_circuit *circuit, int level) /* there was a dr elected, purge its LSPs from the db */ lsp_purge_pseudo(old_dr, circuit, level); } - memcpy(circuit->u.bc.l1_desig_is, circuit->area->isis->sysid, + memcpy(circuit->u.bc.l1_desig_is, circuit->isis->sysid, ISIS_SYS_ID_LEN); *(circuit->u.bc.l1_desig_is + ISIS_SYS_ID_LEN) = circuit->circuit_id; @@ -300,7 +300,7 @@ int isis_dr_commence(struct isis_circuit *circuit, int level) /* there was a dr elected, purge its LSPs from the db */ lsp_purge_pseudo(old_dr, circuit, level); } - memcpy(circuit->u.bc.l2_desig_is, circuit->area->isis->sysid, + memcpy(circuit->u.bc.l2_desig_is, circuit->isis->sysid, ISIS_SYS_ID_LEN); *(circuit->u.bc.l2_desig_is + ISIS_SYS_ID_LEN) = circuit->circuit_id; diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index 1af6f417dc..7abfbe63cc 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -1611,7 +1611,7 @@ int lsp_generate_pseudo(struct isis_circuit *circuit, int level) || (circuit->u.bc.is_dr[level - 1] == 0)) return ISIS_ERROR; - memcpy(lsp_id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN); + memcpy(lsp_id, circuit->isis->sysid, ISIS_SYS_ID_LEN); LSP_FRAGMENT(lsp_id) = 0; LSP_PSEUDO_ID(lsp_id) = circuit->circuit_id; @@ -1671,7 +1671,7 @@ static int lsp_regenerate_pseudo(struct isis_circuit *circuit, int level) || (circuit->u.bc.is_dr[level - 1] == 0)) return ISIS_ERROR; - memcpy(lsp_id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN); + memcpy(lsp_id, circuit->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(lsp_id) = circuit->circuit_id; LSP_FRAGMENT(lsp_id) = 0; @@ -1728,7 +1728,7 @@ static int lsp_l1_refresh_pseudo(struct thread *thread) if ((circuit->u.bc.is_dr[0] == 0) || (circuit->is_type & IS_LEVEL_1) == 0) { - memcpy(id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN); + memcpy(id, circuit->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(id) = circuit->circuit_id; LSP_FRAGMENT(id) = 0; lsp_purge_pseudo(id, circuit, IS_LEVEL_1); @@ -1750,7 +1750,7 @@ static int lsp_l2_refresh_pseudo(struct thread *thread) if ((circuit->u.bc.is_dr[1] == 0) || (circuit->is_type & IS_LEVEL_2) == 0) { - memcpy(id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN); + memcpy(id, circuit->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(id) = circuit->circuit_id; LSP_FRAGMENT(id) = 0; lsp_purge_pseudo(id, circuit, IS_LEVEL_2); diff --git a/isisd/isis_nb_config.c b/isisd/isis_nb_config.c index 2c7e79be56..d5f4c605c4 100644 --- a/isisd/isis_nb_config.c +++ b/isisd/isis_nb_config.c @@ -2135,11 +2135,11 @@ int lib_interface_isis_vrf_modify(struct nb_cb_modify_args *args) vrf_name = yang_dnode_get_string(args->dnode, NULL); circuit = circuit_scan_by_ifp(ifp); - if (circuit && circuit->area && circuit->area->isis - && strcmp(circuit->area->isis->name, vrf_name)) { + if (circuit && circuit->area && circuit->isis + && strcmp(circuit->isis->name, vrf_name)) { snprintf(args->errmsg, args->errmsg_len, "ISIS circuit is already defined on vrf %s", - circuit->area->isis->name); + circuit->isis->name); return NB_ERR_VALIDATION; } } @@ -2805,7 +2805,7 @@ int lib_interface_isis_mpls_ldp_sync_modify(struct nb_cb_modify_args *args) if (circuit == NULL || circuit->area == NULL) return NB_ERR_VALIDATION; - if (circuit->area->isis->vrf_id != VRF_DEFAULT) { + if (circuit->isis->vrf_id != VRF_DEFAULT) { snprintf(args->errmsg, args->errmsg_len, "LDP-Sync only runs on Default VRF"); return NB_ERR_VALIDATION; @@ -2817,7 +2817,7 @@ int lib_interface_isis_mpls_ldp_sync_modify(struct nb_cb_modify_args *args) case NB_EV_APPLY: circuit = nb_running_get_entry(args->dnode, NULL, true); ldp_sync_enable = yang_dnode_get_bool(args->dnode, NULL); - isis = circuit->area->isis; + isis = circuit->isis; if (circuit->ldp_sync_info == NULL) isis_ldp_sync_if_init(circuit, isis); @@ -2873,7 +2873,7 @@ int lib_interface_isis_mpls_holddown_modify(struct nb_cb_modify_args *args) if (circuit == NULL || circuit->area == NULL) return NB_ERR_VALIDATION; - if (circuit->area->isis->vrf_id != VRF_DEFAULT) { + if (circuit->isis->vrf_id != VRF_DEFAULT) { snprintf(args->errmsg, args->errmsg_len, "LDP-Sync only runs on Default VRF"); return NB_ERR_VALIDATION; @@ -2885,7 +2885,7 @@ int lib_interface_isis_mpls_holddown_modify(struct nb_cb_modify_args *args) case NB_EV_APPLY: circuit = nb_running_get_entry(args->dnode, NULL, true); holddown = yang_dnode_get_uint16(args->dnode, NULL); - isis = circuit->area->isis; + isis = circuit->isis; if (circuit->ldp_sync_info == NULL) isis_ldp_sync_if_init(circuit, isis); @@ -2912,7 +2912,7 @@ int lib_interface_isis_mpls_holddown_destroy(struct nb_cb_destroy_args *args) || circuit->area == NULL) return NB_ERR_VALIDATION; - if (circuit->area->isis->vrf_id != VRF_DEFAULT) { + if (circuit->isis->vrf_id != VRF_DEFAULT) { snprintf(args->errmsg, args->errmsg_len, "LDP-Sync only runs on Default VRF"); return NB_ERR_VALIDATION; @@ -2923,7 +2923,7 @@ int lib_interface_isis_mpls_holddown_destroy(struct nb_cb_destroy_args *args) break; case NB_EV_APPLY: circuit = nb_running_get_entry(args->dnode, NULL, true); - isis = circuit->area->isis; + isis = circuit->isis; ldp_sync_info = circuit->ldp_sync_info; UNSET_FLAG(ldp_sync_info->flags, LDP_SYNC_FLAG_HOLDDOWN); diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index 43b9f6685e..d6f2571178 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -76,8 +76,7 @@ static int ack_lsp(struct isis_lsp_hdr *hdr, struct isis_circuit *circuit, lenp = stream_get_endp(circuit->snd_stream); stream_putw(circuit->snd_stream, 0); /* PDU length */ - stream_put(circuit->snd_stream, circuit->area->isis->sysid, - ISIS_SYS_ID_LEN); + stream_put(circuit->snd_stream, circuit->isis->sysid, ISIS_SYS_ID_LEN); stream_putc(circuit->snd_stream, circuit->idx); stream_putc(circuit->snd_stream, 9); /* code */ stream_putc(circuit->snd_stream, 16); /* len */ @@ -143,8 +142,8 @@ static int process_p2p_hello(struct iih_info *iih) } if (tw_adj->neighbor_set - && (memcmp(tw_adj->neighbor_id, - iih->circuit->area->isis->sysid, ISIS_SYS_ID_LEN) + && (memcmp(tw_adj->neighbor_id, iih->circuit->isis->sysid, + ISIS_SYS_ID_LEN) || tw_adj->neighbor_circuit_id != (uint32_t)iih->circuit->idx)) { @@ -728,7 +727,7 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit, goto out; } - if (!memcmp(iih.sys_id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN)) { + if (!memcmp(iih.sys_id, circuit->isis->sysid, ISIS_SYS_ID_LEN)) { zlog_warn( "ISIS-Adj (%s): Received IIH with own sysid - discard", circuit->area->area_tag); @@ -1044,7 +1043,7 @@ dontcheckadj: ack_lsp(&hdr, circuit, level); goto out; /* FIXME: do we need a purge? */ } else { - if (memcmp(hdr.lsp_id, circuit->area->isis->sysid, + if (memcmp(hdr.lsp_id, circuit->isis->sysid, ISIS_SYS_ID_LEN)) { /* LSP by some other system -> do 7.3.16.4 b) */ /* 7.3.16.4 b) 1) */ @@ -1139,8 +1138,7 @@ dontcheckadj: } /* 7.3.15.1 c) - If this is our own lsp and we don't have it initiate a * purge */ - if (memcmp(hdr.lsp_id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN) - == 0) { + if (memcmp(hdr.lsp_id, circuit->isis->sysid, ISIS_SYS_ID_LEN) == 0) { if (!lsp) { /* 7.3.16.4: initiate a purge */ lsp_purge_non_exist(level, &hdr, circuit->area); @@ -1427,7 +1425,7 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit, entry = entry->next) { struct isis_lsp *lsp = lsp_search(&circuit->area->lspdb[level - 1], entry->id); - bool own_lsp = !memcmp(entry->id, circuit->area->isis->sysid, + bool own_lsp = !memcmp(entry->id, circuit->isis->sysid, ISIS_SYS_ID_LEN); if (lsp) { /* 7.3.15.2 b) 1) is this LSP newer */ @@ -1468,7 +1466,7 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit, * insert it and set SSN on it */ if (entry->rem_lifetime && entry->checksum && entry->seqno - && memcmp(entry->id, circuit->area->isis->sysid, + && memcmp(entry->id, circuit->isis->sysid, ISIS_SYS_ID_LEN)) { struct isis_lsp *lsp0 = NULL; @@ -1679,11 +1677,11 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) if (pdu_type != FS_LINK_STATE /* FS PDU doesn't contain max area addr field */ && max_area_addrs != 0 - && max_area_addrs != circuit->area->isis->max_area_addrs) { + && max_area_addrs != circuit->isis->max_area_addrs) { flog_err( EC_ISIS_PACKET, "maximumAreaAddressesMismatch: maximumAreaAdresses in a received PDU %hhu while the parameter for this IS is %u", - max_area_addrs, circuit->area->isis->max_area_addrs); + max_area_addrs, circuit->isis->max_area_addrs); circuit->max_area_addr_mismatches++; #ifndef FABRICD /* send northbound notification */ @@ -1792,8 +1790,7 @@ static void put_hello_hdr(struct isis_circuit *circuit, int level, fill_fixed_hdr(pdu_type, circuit->snd_stream); stream_putc(circuit->snd_stream, circuit->is_type); - stream_put(circuit->snd_stream, circuit->area->isis->sysid, - ISIS_SYS_ID_LEN); + stream_put(circuit->snd_stream, circuit->isis->sysid, ISIS_SYS_ID_LEN); uint32_t holdtime = circuit->hello_multiplier[level - 1] * circuit->hello_interval[level - 1]; @@ -2064,8 +2061,7 @@ int send_csnp(struct isis_circuit *circuit, int level) size_t len_pointer = stream_get_endp(circuit->snd_stream); stream_putw(circuit->snd_stream, 0); - stream_put(circuit->snd_stream, circuit->area->isis->sysid, - ISIS_SYS_ID_LEN); + stream_put(circuit->snd_stream, circuit->isis->sysid, ISIS_SYS_ID_LEN); /* with zero circuit id - ref 9.10, 9.11 */ stream_putc(circuit->snd_stream, 0); @@ -2242,8 +2238,7 @@ static int send_psnp(int level, struct isis_circuit *circuit) size_t len_pointer = stream_get_endp(circuit->snd_stream); stream_putw(circuit->snd_stream, 0); /* length is filled in later */ - stream_put(circuit->snd_stream, circuit->area->isis->sysid, - ISIS_SYS_ID_LEN); + stream_put(circuit->snd_stream, circuit->isis->sysid, ISIS_SYS_ID_LEN); stream_putc(circuit->snd_stream, circuit->idx); struct isis_passwd *passwd = (level == ISIS_LEVEL1) -- 2.39.5