diff options
Diffstat (limited to 'ospfd')
| -rw-r--r-- | ospfd/ospf_abr.c | 6 | ||||
| -rw-r--r-- | ospfd/ospf_dump.c | 8 | ||||
| -rw-r--r-- | ospfd/ospf_ext.c | 4 | ||||
| -rw-r--r-- | ospfd/ospf_lsa.c | 13 | ||||
| -rw-r--r-- | ospfd/ospf_main.c | 1 | ||||
| -rw-r--r-- | ospfd/ospf_nsm.c | 3 | ||||
| -rw-r--r-- | ospfd/ospf_opaque.c | 2 | ||||
| -rw-r--r-- | ospfd/ospf_packet.c | 44 | ||||
| -rw-r--r-- | ospfd/ospf_ri.c | 2 | ||||
| -rw-r--r-- | ospfd/ospf_snmp.c | 2 | ||||
| -rw-r--r-- | ospfd/ospf_sr.c | 8 | ||||
| -rw-r--r-- | ospfd/ospf_te.c | 2 | ||||
| -rw-r--r-- | ospfd/ospf_vty.c | 26 | ||||
| -rw-r--r-- | ospfd/ospf_zebra.c | 4 | ||||
| -rw-r--r-- | ospfd/ospfd.c | 2 |
15 files changed, 76 insertions, 51 deletions
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c index a8dfcbb36b..eb3323997f 100644 --- a/ospfd/ospf_abr.c +++ b/ospfd/ospf_abr.c @@ -708,8 +708,7 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost, else full_cost = cost; - old = ospf_lsa_lookup_by_prefix(area->lsdb, OSPF_SUMMARY_LSA, - (struct prefix_ipv4 *)p, + old = ospf_lsa_lookup_by_prefix(area->lsdb, OSPF_SUMMARY_LSA, p, area->ospf->router_id); if (old) { if (IS_DEBUG_OSPF_EVENT) @@ -761,8 +760,7 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost, zlog_debug( "ospf_abr_announce_network_to_area(): " "creating new summary"); - lsa = ospf_summary_lsa_originate((struct prefix_ipv4 *)p, - full_cost, area); + lsa = ospf_summary_lsa_originate(p, full_cost, area); /* This will flood through area. */ if (!lsa) { diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index a712ecde95..f0740349a0 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -1640,9 +1640,13 @@ DEFUN_NOSH (show_debugging_ospf_instance, return show_debugging_ospf_common(vty, ospf); } +static int config_write_debug(struct vty *vty); /* Debug node. */ static struct cmd_node debug_node = { - DEBUG_NODE, "", 1 /* VTYSH */ + .name = "debug", + .node = DEBUG_NODE, + .prompt = "", + .config_write = config_write_debug, }; static int config_write_debug(struct vty *vty) @@ -1783,7 +1787,7 @@ static int config_write_debug(struct vty *vty) /* Initialize debug commands. */ void ospf_debug_init(void) { - install_node(&debug_node, config_write_debug); + install_node(&debug_node); install_element(ENABLE_NODE, &show_debugging_ospf_cmd); install_element(ENABLE_NODE, &debug_ospf_ism_cmd); diff --git a/ospfd/ospf_ext.c b/ospfd/ospf_ext.c index df64fca883..47883d5f39 100644 --- a/ospfd/ospf_ext.c +++ b/ospfd/ospf_ext.c @@ -1684,7 +1684,7 @@ static uint16_t show_vty_link_info(struct vty *vty, struct tlv_header *ext) /* Extended Link TLVs */ static void ospf_ext_link_show_info(struct vty *vty, struct ospf_lsa *lsa) { - struct lsa_header *lsah = (struct lsa_header *)lsa->data; + struct lsa_header *lsah = lsa->data; struct tlv_header *tlvh; uint16_t length = 0, sum = 0; @@ -1758,7 +1758,7 @@ static uint16_t show_vty_pref_info(struct vty *vty, struct tlv_header *ext) /* Extended Prefix TLVs */ static void ospf_ext_pref_show_info(struct vty *vty, struct ospf_lsa *lsa) { - struct lsa_header *lsah = (struct lsa_header *)lsa->data; + struct lsa_header *lsah = lsa->data; struct tlv_header *tlvh; uint16_t length = 0, sum = 0; diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index d50f390e30..8cf2fad92e 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -33,6 +33,7 @@ #include "hash.h" #include "sockunion.h" /* for inet_aton() */ #include "checksum.h" +#include "network.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_interface.h" @@ -123,7 +124,7 @@ int get_age(struct ospf_lsa *lsa) one-based. */ uint16_t ospf_lsa_checksum(struct lsa_header *lsa) { - uint8_t *buffer = (uint8_t *)&lsa->options; + uint8_t *buffer = &lsa->options; int options_offset = buffer - (uint8_t *)&lsa->ls_age; /* should be 2 */ /* Skip the AGE field */ @@ -138,7 +139,7 @@ uint16_t ospf_lsa_checksum(struct lsa_header *lsa) int ospf_lsa_checksum_valid(struct lsa_header *lsa) { - uint8_t *buffer = (uint8_t *)&lsa->options; + uint8_t *buffer = &lsa->options; int options_offset = buffer - (uint8_t *)&lsa->ls_age; /* should be 2 */ /* Skip the AGE field */ @@ -2845,8 +2846,7 @@ void ospf_lsa_maxage_delete(struct ospf *ospf, struct ospf_lsa *lsa) lsa_prefix.prefixlen = sizeof(lsa_prefix.u.ptr) * CHAR_BIT; lsa_prefix.u.ptr = (uintptr_t)lsa; - if ((rn = route_node_lookup(ospf->maxage_lsa, - (struct prefix *)&lsa_prefix))) { + if ((rn = route_node_lookup(ospf->maxage_lsa, &lsa_prefix))) { if (rn->info == lsa) { UNSET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE); ospf_lsa_unlock(&lsa); /* maxage_lsa */ @@ -2888,7 +2888,7 @@ void ospf_lsa_maxage(struct ospf *ospf, struct ospf_lsa *lsa) lsa_prefix.prefixlen = sizeof(lsa_prefix.u.ptr) * CHAR_BIT; lsa_prefix.u.ptr = (uintptr_t)lsa; - rn = route_node_get(ospf->maxage_lsa, (struct prefix *)&lsa_prefix); + rn = route_node_get(ospf->maxage_lsa, &lsa_prefix); if (rn->info != NULL) { if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) zlog_debug( @@ -3524,7 +3524,8 @@ void ospf_refresher_register_lsa(struct ospf *ospf, struct ospf_lsa *lsa) * 1680s * and 1740s. */ - delay = (random() % (max_delay - min_delay)) + min_delay; + delay = (frr_weak_random() % (max_delay - min_delay)) + + min_delay; current_index = ospf->lsa_refresh_queue.index + (monotime(NULL) - ospf->lsa_refresher_started) diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 4d6ebb40eb..6a3ba9902d 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -128,6 +128,7 @@ struct quagga_signal_t ospf_signals[] = { static const struct frr_yang_module_info *const ospfd_yang_modules[] = { &frr_interface_info, &frr_route_map_info, + &frr_vrf_info, }; FRR_DAEMON_INFO(ospfd, OSPF, .vty_port = OSPF_VTY_PORT, diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index 9cd83c245c..47688babbf 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -33,6 +33,7 @@ #include "table.h" #include "log.h" #include "command.h" +#include "network.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_interface.h" @@ -723,7 +724,7 @@ static void nsm_change_state(struct ospf_neighbor *nbr, int state) /* Start DD exchange protocol */ if (state == NSM_ExStart) { if (nbr->dd_seqnum == 0) - nbr->dd_seqnum = (uint32_t)random(); + nbr->dd_seqnum = (uint32_t)frr_weak_random(); else nbr->dd_seqnum++; diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index b042a06372..35fa5da74b 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -1161,7 +1161,7 @@ void ospf_opaque_config_write_debug(struct vty *vty) void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa) { - struct lsa_header *lsah = (struct lsa_header *)lsa->data; + struct lsa_header *lsah = lsa->data; uint32_t lsid = ntohl(lsah->id.s_addr); uint8_t opaque_type = GET_OPAQUE_TYPE(lsid); uint32_t opaque_id = GET_OPAQUE_ID(lsid); diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index aa50aeacbc..a39d19cc5a 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -2038,10 +2038,10 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph, SET_FLAG(lsa->flags, OSPF_LSA_SELF); - ospf_opaque_self_originated_lsa_received(nbr, - lsa); ospf_ls_ack_send(nbr, lsa); + ospf_opaque_self_originated_lsa_received(nbr, + lsa); continue; } } @@ -2604,7 +2604,7 @@ static unsigned ospf_router_lsa_links_examin(struct router_lsa_link *link, { unsigned counted_links = 0, thislinklen; - while (linkbytes) { + while (linkbytes >= OSPF_ROUTER_LSA_LINK_SIZE) { thislinklen = OSPF_ROUTER_LSA_LINK_SIZE + 4 * link->m[0].tos_count; if (thislinklen > linkbytes) { @@ -2642,26 +2642,32 @@ static unsigned ospf_lsa_examin(struct lsa_header *lsah, const uint16_t lsalen, return MSG_NG; } switch (lsah->type) { - case OSPF_ROUTER_LSA: - /* RFC2328 A.4.2, LSA header + 4 bytes followed by N>=1 - * (12+)-byte link blocks */ - if (headeronly) { - ret = (lsalen - OSPF_LSA_HEADER_SIZE - - OSPF_ROUTER_LSA_MIN_SIZE) - % 4 - ? MSG_NG - : MSG_OK; - break; - } + case OSPF_ROUTER_LSA: { + /* + * RFC2328 A.4.2, LSA header + 4 bytes followed by N>=0 + * (12+)-byte link blocks + */ + size_t linkbytes_len = lsalen - OSPF_LSA_HEADER_SIZE + - OSPF_ROUTER_LSA_MIN_SIZE; + + /* + * LSA link blocks are variable length but always multiples of + * 4; basic sanity check + */ + if (linkbytes_len % 4 != 0) + return MSG_NG; + + if (headeronly) + return MSG_OK; + rlsa = (struct router_lsa *)lsah; + ret = ospf_router_lsa_links_examin( (struct router_lsa_link *)rlsa->link, - lsalen - OSPF_LSA_HEADER_SIZE - 4, /* skip: basic - header, "flags", - 0, "# links" */ - ntohs(rlsa->links) /* 16 bits */ - ); + linkbytes_len, + ntohs(rlsa->links)); break; + } case OSPF_AS_EXTERNAL_LSA: /* RFC2328 A.4.5, LSA header + 4 bytes followed by N>=1 12-bytes long * blocks */ diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index fbe513cea0..c3d53ad5ed 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -1438,7 +1438,7 @@ static uint16_t show_vty_sr_msd(struct vty *vty, struct tlv_header *tlvh) static void ospf_router_info_show_info(struct vty *vty, struct ospf_lsa *lsa) { - struct lsa_header *lsah = (struct lsa_header *)lsa->data; + struct lsa_header *lsah = lsa->data; struct tlv_header *tlvh; uint16_t length = 0, sum = 0; diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 550e5ee9ee..63191d5cb5 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -784,7 +784,7 @@ static struct ospf_area *ospfStubAreaLookup(struct variable *v, oid name[], area = ospf_area_lookup_by_area_id(ospf, *addr); - if (area->external_routing == OSPF_AREA_STUB) + if (area && area->external_routing == OSPF_AREA_STUB) return area; else return NULL; diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c index b5a54a0bc4..7a786ba7ab 100644 --- a/ospfd/ospf_sr.c +++ b/ospfd/ospf_sr.c @@ -1035,7 +1035,7 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa) { struct sr_node *srn; struct tlv_header *tlvh; - struct lsa_header *lsah = (struct lsa_header *)lsa->data; + struct lsa_header *lsah = lsa->data; struct ri_sr_tlv_sid_label_range *ri_srgb; struct ri_sr_tlv_sr_algorithm *algo; struct sr_srgb srgb; @@ -1156,7 +1156,7 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa) void ospf_sr_ri_lsa_delete(struct ospf_lsa *lsa) { struct sr_node *srn; - struct lsa_header *lsah = (struct lsa_header *)lsa->data; + struct lsa_header *lsah = lsa->data; if (IS_DEBUG_OSPF_SR) zlog_debug("SR (%s): Remove SR node %s from lsa_id 4.0.0.%u", @@ -1198,7 +1198,7 @@ void ospf_sr_ext_link_lsa_update(struct ospf_lsa *lsa) { struct sr_node *srn; struct tlv_header *tlvh; - struct lsa_header *lsah = (struct lsa_header *)lsa->data; + struct lsa_header *lsah = lsa->data; struct sr_link *srl; uint16_t length, sum; @@ -1308,7 +1308,7 @@ void ospf_sr_ext_prefix_lsa_update(struct ospf_lsa *lsa) { struct sr_node *srn; struct tlv_header *tlvh; - struct lsa_header *lsah = (struct lsa_header *)lsa->data; + struct lsa_header *lsah = lsa->data; struct sr_prefix *srp; uint16_t length, sum; diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index a2084e3214..1009c7577e 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -2119,7 +2119,7 @@ static uint16_t ospf_mpls_te_show_link_subtlv(struct vty *vty, static void ospf_mpls_te_show_info(struct vty *vty, struct ospf_lsa *lsa) { - struct lsa_header *lsah = (struct lsa_header *)lsa->data; + struct lsa_header *lsah = lsa->data; struct tlv_header *tlvh, *next; uint16_t sum, total; uint16_t (*subfunc)(struct vty * vty, struct tlv_header * tlvh, diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 75f556e39f..a3a02a0f95 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -54,8 +54,8 @@ #include "ospfd/ospf_bfd.h" FRR_CFG_DEFAULT_BOOL(OSPF_LOG_ADJACENCY_CHANGES, - { .val_long = true, .match_profile = "datacenter", }, - { .val_long = false }, + { .val_bool = true, .match_profile = "datacenter", }, + { .val_bool = false }, ) static const char *const ospf_network_type_str[] = { @@ -10555,14 +10555,21 @@ void ospf_vty_show_init(void) } +static int config_write_interface(struct vty *vty); /* ospfd's interface node. */ -static struct cmd_node interface_node = {INTERFACE_NODE, "%s(config-if)# ", 1}; +static struct cmd_node interface_node = { + .name = "interface", + .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, + .prompt = "%s(config-if)# ", + .config_write = config_write_interface, +}; /* Initialization of OSPF interface. */ static void ospf_vty_if_init(void) { /* Install interface node. */ - install_node(&interface_node, config_write_interface); + install_node(&interface_node); if_cmd_init(); /* "ip ospf authentication" commands. */ @@ -10668,7 +10675,14 @@ static void ospf_vty_zebra_init(void) #endif /* 0 */ } -static struct cmd_node ospf_node = {OSPF_NODE, "%s(config-router)# ", 1}; +static int ospf_config_write(struct vty *vty); +static struct cmd_node ospf_node = { + .name = "ospf", + .node = OSPF_NODE, + .parent_node = CONFIG_NODE, + .prompt = "%s(config-router)# ", + .config_write = ospf_config_write, +}; static void ospf_interface_clear(struct interface *ifp) { @@ -10741,7 +10755,7 @@ void ospf_vty_clear_init(void) void ospf_vty_init(void) { /* Install ospf top node. */ - install_node(&ospf_node, ospf_config_write); + install_node(&ospf_node); /* "router ospf" commands. */ install_element(CONFIG_NODE, &router_ospf_cmd); diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 385a7ece7b..c7e6bd9cbf 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -1023,8 +1023,8 @@ void ospf_distribute_list_update(struct ospf *ospf, int type, /* Set timer. */ ospf->t_distribute_update = NULL; - thread_add_timer_msec(master, ospf_distribute_list_update_timer, - (void **)args, ospf->min_ls_interval, + thread_add_timer_msec(master, ospf_distribute_list_update_timer, args, + ospf->min_ls_interval, &ospf->t_distribute_update); } diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index f3fe9e17b2..e9f622d217 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -1787,7 +1787,7 @@ static void ospf_nbr_nbma_add(struct ospf_nbr_nbma *nbr_nbma, p.prefixlen = IPV4_MAX_BITLEN; p.u.prefix4 = nbr_nbma->addr; - rn = route_node_get(oi->nbrs, (struct prefix *)&p); + rn = route_node_get(oi->nbrs, &p); if (rn->info) { nbr = rn->info; nbr->nbr_nbma = nbr_nbma; |
