diff --git a/isisd/isis_pfpacket.c b/isisd/isis_pfpacket.c index 6ec7771ec2..dd07a9c6f5 100644 --- a/isisd/isis_pfpacket.c +++ b/isisd/isis_pfpacket.c @@ -279,6 +279,10 @@ isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char * ssnpa) bytesread = recvfrom (circuit->fd, discard_buff, sizeof (discard_buff), MSG_DONTWAIT, (struct sockaddr *) &s_addr, (socklen_t *) &addr_len); + + if (bytesread < 0) + zlog_warn ("isis_recv_pdu_bcast(): recvfrom() failed"); + return ISIS_WARNING; } /* @@ -322,10 +326,10 @@ isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char * ssnpa) addr_len = sizeof (s_addr); /* we can read directly to the stream */ - bytesread = stream_recvfrom (circuit->rcv_stream, circuit->fd, - circuit->interface->mtu, 0, - (struct sockaddr *) &s_addr, - (socklen_t *) &addr_len); + stream_recvfrom (circuit->rcv_stream, circuit->fd, + circuit->interface->mtu, 0, + (struct sockaddr *) &s_addr, + (socklen_t *) &addr_len); if (s_addr.sll_pkttype == PACKET_OUTGOING) { diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index db46078f20..554fa563ad 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -68,7 +68,6 @@ remove_excess_adjs (struct list *adjs) if (candidate->sys_type < adj->sys_type) { excess = node; - candidate = adj; continue; } if (candidate->sys_type > adj->sys_type) @@ -78,7 +77,6 @@ remove_excess_adjs (struct list *adjs) if (comp > 0) { excess = node; - candidate = adj; continue; } if (comp < 0) @@ -87,7 +85,6 @@ remove_excess_adjs (struct list *adjs) if (candidate->circuit->circuit_id > adj->circuit->circuit_id) { excess = node; - candidate = adj; continue; } @@ -98,7 +95,6 @@ remove_excess_adjs (struct list *adjs) if (comp > 0) { excess = node; - candidate = adj; continue; } } diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c index 73b6aaccf6..4c1d97a489 100644 --- a/nhrpd/nhrp_peer.c +++ b/nhrpd/nhrp_peer.c @@ -425,7 +425,6 @@ static void nhrp_handle_registration_request(struct nhrp_packet_parser *p) nbma_natoa = NULL; if (natted) { nbma_natoa = nbma_addr; - nbma_addr = &p->peer->vc->remote.nbma; } holdtime = htons(cie->holding_time); diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c index e6582e2b17..ee88e7d8ea 100644 --- a/pimd/pim_igmp.c +++ b/pimd/pim_igmp.c @@ -876,10 +876,8 @@ pim_igmp_read (struct thread *t) if (errno == EINTR) continue; if (errno == EWOULDBLOCK || errno == EAGAIN) - { - cont = 0; break; - } + goto done; } } diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index 90e30ea3d6..2fb243b9bd 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -577,10 +577,8 @@ static int mroute_read(struct thread *t) if (errno == EINTR) continue; if (errno == EWOULDBLOCK || errno == EAGAIN) - { - cont = 0; - break; - } + break; + if (PIM_DEBUG_MROUTE) zlog_warn("%s: failure reading fd=%d: errno=%d: %s", __PRETTY_FUNCTION__, fd, errno, safe_strerror(errno)); diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c index c9ae673224..fe96d01a06 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -111,42 +111,6 @@ pim_nexthop_cache_find (struct pim_rpf *rpf) } -static int -pim_rp_list_cmp (void *v1, void *v2) -{ - struct rp_info *rp1 = (struct rp_info *) v1; - struct rp_info *rp2 = (struct rp_info *) v2; - - if (rp1 == rp2) - return 0; - - if (!rp1 && rp2) - return -1; - - if (rp1 && !rp2) - return 1; - - /* - * Sort by RP IP address - */ - if (rp1->rp.rpf_addr.u.prefix4.s_addr < rp2->rp.rpf_addr.u.prefix4.s_addr) - return -1; - - if (rp1->rp.rpf_addr.u.prefix4.s_addr > rp2->rp.rpf_addr.u.prefix4.s_addr) - return 1; - - /* - * Sort by group IP address - */ - if (rp1->group.u.prefix4.s_addr < rp2->group.u.prefix4.s_addr) - return -1; - - if (rp1->group.u.prefix4.s_addr > rp2->group.u.prefix4.s_addr) - return 1; - - return -1; -} - struct pim_nexthop_cache * pim_nexthop_cache_add (struct pim_rpf *rpf_addr) { @@ -462,10 +426,13 @@ pim_update_upstream_nh (struct pim_nexthop_cache *pnc) return 0; } -/* This API is used to parse Registered address nexthop update coming from Zebra */ -void -pim_parse_nexthop_update (struct zclient *zclient, int command, - vrf_id_t vrf_id) +/* + * This API is used to parse Registered address nexthop update + * coming from Zebra + */ +int +pim_parse_nexthop_update (int command, struct zclient *zclient, + zebra_size_t length, vrf_id_t vrf_id) { struct stream *s; struct prefix p; @@ -512,9 +479,16 @@ pim_parse_nexthop_update (struct zclient *zclient, int command, zlog_debug ("%s: NHT addr %s is not in local cached DB.", __PRETTY_FUNCTION__, buf); } - return; + return 0; } } + else + { + /* + * We do not currently handle ZEBRA_IMPORT_CHECK_UPDATE + */ + return 0; + } pnc->last_update = pim_time_monotonic_sec (); distance = stream_getc (s); @@ -644,4 +618,5 @@ pim_parse_nexthop_update (struct zclient *zclient, int command, if (listcount (pnc->upstream_list)) pim_update_upstream_nh (pnc); + return 0; } diff --git a/pimd/pim_nht.h b/pimd/pim_nht.h index 6e6602b3be..5348ec3704 100644 --- a/pimd/pim_nht.h +++ b/pimd/pim_nht.h @@ -48,8 +48,8 @@ struct pim_nexthop_cache struct list *upstream_list; }; -void pim_parse_nexthop_update (struct zclient *zclient, int command, - vrf_id_t vrf_id); +int pim_parse_nexthop_update (int command, struct zclient *zclient, + zebra_size_t length, vrf_id_t vrf_id); int pim_find_or_track_nexthop (struct prefix *addr, struct pim_upstream *up, struct rp_info *rp); void pim_delete_tracked_nexthop (struct prefix *addr, struct pim_upstream *up, diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c index f82687245d..b2f858b7d9 100644 --- a/pimd/pim_pim.c +++ b/pimd/pim_pim.c @@ -310,10 +310,8 @@ static int pim_sock_read(struct thread *t) if (errno == EINTR) continue; if (errno == EWOULDBLOCK || errno == EAGAIN) - { - cont = 0; - break; - } + break; + if (PIM_DEBUG_PIM_PACKETS) zlog_debug ("Received errno: %d %s", errno, safe_strerror (errno)); goto done; diff --git a/pimd/pim_register.c b/pimd/pim_register.c index effc212722..65a3e8714f 100644 --- a/pimd/pim_register.c +++ b/pimd/pim_register.c @@ -54,7 +54,7 @@ pim_register_join (struct pim_upstream *up) { if (PIM_DEBUG_PIM_EVENTS) zlog_debug ("%s register setup skipped as group is SSM", up->sg_str); - return; + return; } pim_channel_add_oif (up->channel_oil, pim_regiface, PIM_OIF_FLAG_PROTO_PIM); diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 6c83811d9a..78bbd14405 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -54,21 +54,12 @@ pim_rp_info_free (struct rp_info *rp_info) XFREE (MTYPE_PIM_RP, rp_info); } -static int +int pim_rp_list_cmp (void *v1, void *v2) { struct rp_info *rp1 = (struct rp_info *)v1; struct rp_info *rp2 = (struct rp_info *)v2; - if (rp1 == rp2) - return 0; - - if (!rp1 && rp2) - return -1; - - if (rp1 && !rp2) - return 1; - /* * Sort by RP IP address */ @@ -87,10 +78,7 @@ pim_rp_list_cmp (void *v1, void *v2) if (rp1->group.u.prefix4.s_addr > rp2->group.u.prefix4.s_addr) return 1; - if (rp1 == tail) - return 1; - - return -1; + return 0; } void diff --git a/pimd/pim_rp.h b/pimd/pim_rp.h index e5580cfa63..84ab9be482 100644 --- a/pimd/pim_rp.h +++ b/pimd/pim_rp.h @@ -61,4 +61,6 @@ struct pim_rpf *pim_rp_g (struct in_addr group); #define RP(G) pim_rp_g ((G)) void pim_rp_show_information (struct vty *vty, u_char uj); + +int pim_rp_list_cmp (void *v1, void *v2); #endif diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index cd7c3db59a..4e18c478d6 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -602,14 +602,6 @@ void sched_rpf_cache_refresh(void) 0, qpim_rpf_cache_refresh_delay_msec); } -static int -pim_zebra_nexthop_update (int command, struct zclient *zclient, - zebra_size_t length, vrf_id_t vrf_id) -{ - pim_parse_nexthop_update (zclient, command, vrf_id); - return 0; -} - static void pim_zebra_connected (struct zclient *zclient) { @@ -637,7 +629,7 @@ void pim_zebra_init(void) zclient->interface_down = pim_zebra_if_state_down; zclient->interface_address_add = pim_zebra_if_address_add; zclient->interface_address_delete = pim_zebra_if_address_del; - zclient->nexthop_update = pim_zebra_nexthop_update; + zclient->nexthop_update = pim_parse_nexthop_update; zclient_init(zclient, ZEBRA_ROUTE_PIM, 0); if (PIM_DEBUG_PIM_TRACE) { diff --git a/pimd/pimd.c b/pimd/pimd.c index 72fe0e7046..bdbd251e20 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -108,8 +108,14 @@ pim_vrf_enable (struct vrf *vrf) { pimg = pim_instance_init (VRF_DEFAULT, AFI_IP); if (pimg == NULL) - zlog_err ("%s %s: pim class init failure ", __FILE__, - __PRETTY_FUNCTION__); + { + zlog_err ("%s %s: pim class init failure ", __FILE__, + __PRETTY_FUNCTION__); + /* + * We will crash and burn otherwise + */ + exit(1); + } } return 0; } @@ -194,12 +200,18 @@ static void pim_instance_terminate (void) { /* Traverse and cleanup rpf_hash */ - if (pimg && pimg->rpf_hash) + if (pimg->rpf_hash) { hash_clean (pimg->rpf_hash, (void *) pim_rp_list_hash_clean); hash_free (pimg->rpf_hash); + pimg->rpf_hash = NULL; + } + + if (pimg->ssm_info) + { + pim_ssm_terminate (pimg->ssm_info); + pimg->ssm_info = NULL; } - pim_ssm_terminate (pimg->ssm_info); XFREE (MTYPE_PIM_PIM_INSTANCE, pimg); }