From: Donald Sharp Date: Mon, 15 May 2017 22:48:54 +0000 (-0400) Subject: eigrpd: Cleanup a bunch SA warnings. X-Git-Tag: reindent-master-before~149^2~8 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=057fad8dfb65167925c01237af31e1a4ecadabb3;p=matthieu%2Ffrr.git eigrpd: Cleanup a bunch SA warnings. 1) Cleanup SA warnings, more to come 2) Cleanup some non debug guarded zlog_info code Signed-off-by: Donald Sharp --- diff --git a/eigrpd/eigrp_dump.c b/eigrpd/eigrp_dump.c index 21bef48ecb..3de7a53c10 100644 --- a/eigrpd/eigrp_dump.c +++ b/eigrpd/eigrp_dump.c @@ -310,10 +310,15 @@ show_ip_eigrp_topology_header (struct vty *vty, struct eigrp *eigrp) void show_ip_eigrp_prefix_entry (struct vty *vty, struct eigrp_prefix_entry *tn) { + struct list *successors = eigrp_topology_get_successor(tn); + vty_out (vty, "%-3c",(tn->state > 0) ? 'A' : 'P'); - vty_out (vty, "%s/%u, ",inet_ntoa (tn->destination_ipv4->prefix),tn->destination_ipv4->prefixlen); - vty_out (vty, "%u successors, ",eigrp_topology_get_successor(tn)->count); - vty_out (vty, "FD is %u, serno: %lu %s",tn->fdistance, tn->serno, VTY_NEWLINE); + vty_out (vty, "%s/%u, ", + inet_ntoa (tn->destination_ipv4->prefix), tn->destination_ipv4->prefixlen); + vty_out (vty, "%u successors, ", successors->count); + vty_out (vty, "FD is %u, serno: %lu %s", tn->fdistance, tn->serno, VTY_NEWLINE); + + list_delete(successors); } void diff --git a/eigrpd/eigrp_filter.c b/eigrpd/eigrp_filter.c index bfe51ae88d..7d628c8208 100644 --- a/eigrpd/eigrp_filter.c +++ b/eigrpd/eigrp_filter.c @@ -83,7 +83,6 @@ eigrp_distribute_update (struct distribute *dist) if (dist->list[DISTRIBUTE_V4_IN]) { alist = access_list_lookup (AFI_IP, dist->list[DISTRIBUTE_V4_IN]); - zlog_info("name); if (alist) e->list[EIGRP_FILTER_IN] = alist; else @@ -97,7 +96,6 @@ eigrp_distribute_update (struct distribute *dist) /* access list OUT for whole process */ if (dist->list[DISTRIBUTE_V4_OUT]) { - zlog_info("list[DISTRIBUTE_V4_OUT]); alist = access_list_lookup (AFI_IP, dist->list[DISTRIBUTE_V4_OUT]); if (alist) e->list[EIGRP_FILTER_OUT] = alist; @@ -112,7 +110,6 @@ eigrp_distribute_update (struct distribute *dist) /* PREFIX_LIST IN for process */ if (dist->prefix[DISTRIBUTE_V4_IN]) { - zlog_info("prefix[DISTRIBUTE_V4_IN]); plist = prefix_list_lookup (AFI_IP, dist->prefix[DISTRIBUTE_V4_IN]); if (plist) { @@ -126,7 +123,6 @@ eigrp_distribute_update (struct distribute *dist) /* PREFIX_LIST OUT for process */ if (dist->prefix[DISTRIBUTE_V4_OUT]) { - zlog_info("prefix[DISTRIBUTE_V4_OUT]); plist = prefix_list_lookup (AFI_IP, dist->prefix[DISTRIBUTE_V4_OUT]); if (plist) { @@ -192,8 +188,6 @@ eigrp_distribute_update (struct distribute *dist) if (ifp == NULL) return; - zlog_info("info; ei = info->eigrp_interface;*/ struct listnode *node, *nnode; @@ -207,15 +201,9 @@ eigrp_distribute_update (struct distribute *dist) } } - if(ei == NULL) - { - zlog_info("Not Found eigrp interface %s",ifp->name); - } - /* Access-list for interface in */ if (dist->list[DISTRIBUTE_V4_IN]) { - zlog_info("list[DISTRIBUTE_V4_IN]); if (alist){ ei->list[EIGRP_FILTER_IN] = alist; @@ -239,10 +227,7 @@ eigrp_distribute_update (struct distribute *dist) } else - { - ei->list[EIGRP_FILTER_OUT] = NULL; - zlog_info("list[EIGRP_FILTER_OUT] = NULL; /* Prefix-list for interface in */ if (dist->prefix[DISTRIBUTE_V4_IN]) diff --git a/eigrpd/eigrp_hello.c b/eigrpd/eigrp_hello.c index 051836d7e8..624c355eb4 100644 --- a/eigrpd/eigrp_hello.c +++ b/eigrpd/eigrp_hello.c @@ -252,7 +252,8 @@ eigrp_peer_termination_decode (struct eigrp_neighbor *nbr, if(my_ip == received_ip) { zlog_info ("Neighbor %s (%s) is down: Peer Termination received", - inet_ntoa (nbr->src),ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT)); + inet_ntoa (nbr->src), + ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT)); /* set neighbor to DOWN */ nbr->state = EIGRP_NEIGHBOR_DOWN; /* delete neighbor */ @@ -364,14 +365,15 @@ eigrp_hello_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e case EIGRP_TLV_SW_VERSION: eigrp_sw_version_decode(nbr, tlv_header); break; - case EIGRP_TLV_NEXT_MCAST_SEQ: - break; + case EIGRP_TLV_NEXT_MCAST_SEQ: + break; case EIGRP_TLV_PEER_TERMINATION: eigrp_peer_termination_decode(nbr, tlv_header); + return; break; case EIGRP_TLV_PEER_MTRLIST: - case EIGRP_TLV_PEER_TIDLIST: - break; + case EIGRP_TLV_PEER_TIDLIST: + break; default: break; } @@ -388,7 +390,8 @@ eigrp_hello_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e { /* increment statistics. */ ei->hello_in++; - eigrp_nbr_state_update(nbr); + if (nbr) + eigrp_nbr_state_update(nbr); } diff --git a/eigrpd/eigrp_interface.c b/eigrpd/eigrp_interface.c index 1ad5e88c22..5f3de8a921 100644 --- a/eigrpd/eigrp_interface.c +++ b/eigrpd/eigrp_interface.c @@ -304,7 +304,9 @@ eigrp_if_up (struct eigrp_interface *ei) { pe = eigrp_prefix_entry_new (); pe->serno = eigrp->serno; - pe->destination_ipv4 = dest_addr; + pe->destination_ipv4 = prefix_ipv4_new (); + prefix_copy ((struct prefix *)pe->destination_ipv4, + (struct prefix *)&dest_addr); pe->af = AF_INET; pe->nt = EIGRP_TOPOLOGY_TYPE_CONNECTED; diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c index 635c1cf66b..6b529302d5 100644 --- a/eigrpd/eigrp_packet.c +++ b/eigrpd/eigrp_packet.c @@ -114,7 +114,10 @@ eigrp_make_md5_digest (struct eigrp_interface *ei, struct stream *s, u_char flag if(keychain) key = key_lookup_for_send(keychain); else - return EIGRP_AUTH_TYPE_NONE; + { + eigrp_authTLV_MD5_free(auth_TLV); + return EIGRP_AUTH_TYPE_NONE; + } memset(&ctx, 0, sizeof(ctx)); MD5Init(&ctx); @@ -235,8 +238,7 @@ eigrp_check_md5_digest (struct stream *s, } /* save neighbor's crypt_seqnum */ - if (nbr) - nbr->crypt_seqnum = authTLV->key_sequence; + nbr->crypt_seqnum = authTLV->key_sequence; return 1; } @@ -628,7 +630,7 @@ eigrp_read (struct thread *thread) struct eigrp_packet *ep; ep = eigrp_fifo_tail(nbr->retrans_queue); - if (ep != NULL) + if (ep) { if (ntohl(eigrph->ack) == ep->sequence_number) { @@ -642,7 +644,7 @@ eigrp_read (struct thread *thread) eigrp_update_send_EOT(nbr); } ep = eigrp_fifo_pop_tail(nbr->retrans_queue); - /*eigrp_packet_free(ep);*/ + eigrp_packet_free(ep); if (nbr->retrans_queue->count > 0) { eigrp_send_packet_reliably(nbr); @@ -650,7 +652,7 @@ eigrp_read (struct thread *thread) } } ep = eigrp_fifo_tail(nbr->multicast_queue); - if (ep != NULL) + if (ep) { if (ntohl(eigrph->ack) == ep->sequence_number) { diff --git a/eigrpd/eigrp_query.c b/eigrpd/eigrp_query.c index 4488054e06..e52d4fa663 100644 --- a/eigrpd/eigrp_query.c +++ b/eigrpd/eigrp_query.c @@ -114,16 +114,17 @@ eigrp_query_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e type = stream_getw(s); if (type == EIGRP_TLV_IPv4_INT) { + struct prefix_ipv4 dest_addr; + stream_set_getp(s, s->getp - sizeof(u_int16_t)); tlv = eigrp_read_ipv4_tlv(s); - struct prefix_ipv4 *dest_addr; - dest_addr = prefix_ipv4_new(); - dest_addr->prefix = tlv->destination; - dest_addr->prefixlen = tlv->prefix_length; + dest_addr.family = AFI_IP; + dest_addr.prefix = tlv->destination; + dest_addr.prefixlen = tlv->prefix_length; struct eigrp_prefix_entry *dest = - eigrp_topology_table_lookup_ipv4(eigrp->topology_table, dest_addr); + eigrp_topology_table_lookup_ipv4(eigrp->topology_table, &dest_addr); /* If the destination exists (it should, but one never know)*/ if (dest != NULL) diff --git a/eigrpd/eigrp_reply.c b/eigrpd/eigrp_reply.c index 0c5d9dd92e..e5470a48f0 100644 --- a/eigrpd/eigrp_reply.c +++ b/eigrpd/eigrp_reply.c @@ -146,6 +146,8 @@ eigrp_send_reply (struct eigrp_neighbor *nbr, struct eigrp_prefix_entry *pe) { eigrp_send_packet_reliably(nbr); } + + XFREE(MTYPE_EIGRP_PREFIX_ENTRY, pe2); } /*EIGRP REPLY read function*/ @@ -180,16 +182,17 @@ eigrp_reply_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e type = stream_getw(s); if (type == EIGRP_TLV_IPv4_INT) { + struct prefix_ipv4 dest_addr; + stream_set_getp(s, s->getp - sizeof(u_int16_t)); tlv = eigrp_read_ipv4_tlv(s); - struct prefix_ipv4 *dest_addr; - dest_addr = prefix_ipv4_new(); - dest_addr->prefix = tlv->destination; - dest_addr->prefixlen = tlv->prefix_length; + dest_addr.family = AFI_IP; + dest_addr.prefix = tlv->destination; + dest_addr.prefixlen = tlv->prefix_length; struct eigrp_prefix_entry *dest = - eigrp_topology_table_lookup_ipv4 (eigrp->topology_table, dest_addr); + eigrp_topology_table_lookup_ipv4 (eigrp->topology_table, &dest_addr); /* * Destination must exists */ @@ -212,24 +215,18 @@ eigrp_reply_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e plist = e->prefix[EIGRP_FILTER_IN]; alist_i = ei->list[EIGRP_FILTER_IN]; plist_i = ei->prefix[EIGRP_FILTER_IN]; - zlog_info("REPLY Receive: Filtering"); - zlog_info("REPLY RECEIVE Prefix: %s", inet_ntoa(dest_addr->prefix)); /* Check if any list fits */ - if ((alist && access_list_apply (alist, - (struct prefix *) dest_addr) == FILTER_DENY)|| - (plist && prefix_list_apply (plist, - (struct prefix *) dest_addr) == PREFIX_DENY)|| - (alist_i && access_list_apply (alist_i, - (struct prefix *) dest_addr) == FILTER_DENY)|| - (plist_i && prefix_list_apply (plist_i, - (struct prefix *) dest_addr) == PREFIX_DENY)) + if ((alist && + access_list_apply (alist, (struct prefix *)&dest_addr) == FILTER_DENY) || + (plist && + prefix_list_apply (plist, (struct prefix *)&dest_addr) == PREFIX_DENY) || + (alist_i && + access_list_apply (alist_i, (struct prefix *)&dest_addr) == FILTER_DENY) || + (plist_i && + prefix_list_apply (plist_i, (struct prefix *)&dest_addr) == PREFIX_DENY)) { - zlog_info("REPLY RECEIVE: Setting metric to max"); tlv->metric.delay = EIGRP_MAX_METRIC; - zlog_info("REPLY RECEIVE Prefix: %s", inet_ntoa(dest_addr->prefix)); - } else { - zlog_info("REPLY RECEIVE: Not setting metric"); - } + } /* * End of filtering */ diff --git a/eigrpd/eigrp_siaquery.c b/eigrpd/eigrp_siaquery.c index b041300764..38033a4fa2 100644 --- a/eigrpd/eigrp_siaquery.c +++ b/eigrpd/eigrp_siaquery.c @@ -81,16 +81,17 @@ eigrp_siaquery_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header type = stream_getw(s); if (type == EIGRP_TLV_IPv4_INT) { + struct prefix_ipv4 dest_addr; + stream_set_getp(s, s->getp - sizeof(u_int16_t)); tlv = eigrp_read_ipv4_tlv(s); - struct prefix_ipv4 *dest_addr; - dest_addr = prefix_ipv4_new(); - dest_addr->prefix = tlv->destination; - dest_addr->prefixlen = tlv->prefix_length; + dest_addr.family = AFI_IP; + dest_addr.prefix = tlv->destination; + dest_addr.prefixlen = tlv->prefix_length; struct eigrp_prefix_entry *dest = - eigrp_topology_table_lookup_ipv4(eigrp->topology_table, dest_addr); + eigrp_topology_table_lookup_ipv4(eigrp->topology_table, &dest_addr); /* If the destination exists (it should, but one never know)*/ if (dest != NULL) @@ -162,4 +163,6 @@ eigrp_send_siaquery (struct eigrp_neighbor *nbr, struct eigrp_prefix_entry *pe) eigrp_send_packet_reliably(nbr); } } + else + eigrp_packet_free(ep); } diff --git a/eigrpd/eigrp_siareply.c b/eigrpd/eigrp_siareply.c index 4c4793f864..e99f4ed957 100644 --- a/eigrpd/eigrp_siareply.c +++ b/eigrpd/eigrp_siareply.c @@ -80,16 +80,17 @@ eigrp_siareply_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header type = stream_getw(s); if (type == EIGRP_TLV_IPv4_INT) { + struct prefix_ipv4 dest_addr; + stream_set_getp(s, s->getp - sizeof(u_int16_t)); tlv = eigrp_read_ipv4_tlv(s); - struct prefix_ipv4 *dest_addr; - dest_addr = prefix_ipv4_new(); - dest_addr->prefix = tlv->destination; - dest_addr->prefixlen = tlv->prefix_length; + dest_addr.family = AFI_IP; + dest_addr.prefix = tlv->destination; + dest_addr.prefixlen = tlv->prefix_length; struct eigrp_prefix_entry *dest = - eigrp_topology_table_lookup_ipv4(eigrp->topology_table, dest_addr); + eigrp_topology_table_lookup_ipv4(eigrp->topology_table, &dest_addr); /* If the destination exists (it should, but one never know)*/ if (dest != NULL) @@ -161,6 +162,8 @@ eigrp_send_siareply (struct eigrp_neighbor *nbr, struct eigrp_prefix_entry *pe) eigrp_send_packet_reliably(nbr); } } + else + eigrp_packet_free(ep); } diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c index 5c942bd4d5..9bb772decf 100644 --- a/eigrpd/eigrp_update.c +++ b/eigrpd/eigrp_update.c @@ -291,17 +291,18 @@ eigrp_update_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header * type = stream_getw(s); if (type == EIGRP_TLV_IPv4_INT) { + struct prefix_ipv4 dest_addr; + stream_set_getp(s, s->getp - sizeof(u_int16_t)); tlv = eigrp_read_ipv4_tlv(s); /*searching if destination exists */ - struct prefix_ipv4 *dest_addr; - dest_addr = prefix_ipv4_new(); - dest_addr->prefix = tlv->destination; - dest_addr->prefixlen = tlv->prefix_length; + dest_addr.family = AFI_IP; + dest_addr.prefix = tlv->destination; + dest_addr.prefixlen = tlv->prefix_length; struct eigrp_prefix_entry *dest = - eigrp_topology_table_lookup_ipv4(eigrp->topology_table, dest_addr); + eigrp_topology_table_lookup_ipv4(eigrp->topology_table, &dest_addr); /*if exists it comes to DUAL*/ if (dest != NULL) @@ -331,7 +332,9 @@ eigrp_update_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header * /*Here comes topology information save*/ pe = eigrp_prefix_entry_new(); pe->serno = eigrp->serno; - pe->destination_ipv4 = dest_addr; + pe->destination_ipv4 = prefix_ipv4_new(); + prefix_copy((struct prefix *)pe->destination_ipv4, + (struct prefix *)&dest_addr); pe->af = AF_INET; pe->state = EIGRP_FSM_STATE_PASSIVE; pe->nt = EIGRP_TOPOLOGY_TYPE_REMOTE; @@ -353,93 +356,52 @@ eigrp_update_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header * */ alist = ei->list[EIGRP_FILTER_IN]; - if (alist) { - zlog_info ("ALIST PROC IN: %s", alist->name); - } else { - zlog_info("ALIST je prazdny"); - } - /* Check if access-list fits */ - if (alist && access_list_apply (alist, - (struct prefix *) dest_addr) == FILTER_DENY) + if (alist && + access_list_apply (alist, (struct prefix *)&dest_addr) == FILTER_DENY) { /* If yes, set reported metric to Max */ - zlog_info("PROC IN: Nastavujem metriku na MAX"); ne->reported_metric.delay = EIGRP_MAX_METRIC; - zlog_info("PROC IN Prefix: %s", inet_ntoa(dest_addr->prefix)); } else { - zlog_info("PROC IN: NENastavujem metriku "); ne->distance = eigrp_calculate_total_metrics(eigrp, ne); } plist = e->prefix[EIGRP_FILTER_IN]; - if (plist) { - zlog_info ("PLIST PROC IN: %s", plist->name); - } else { - zlog_info("PLIST PROC IN je prazdny"); - } - /* Check if prefix-list fits */ - if (plist && prefix_list_apply (plist, - (struct prefix *) dest_addr) == PREFIX_DENY) + if (plist && + prefix_list_apply (plist, (struct prefix *)&dest_addr) == PREFIX_DENY) { /* If yes, set reported metric to Max */ - zlog_info("PLIST PROC IN: Nastavujem metriku na MAX"); ne->reported_metric.delay = EIGRP_MAX_METRIC; - zlog_info("PLIST PROC IN Prefix: %s", inet_ntoa(dest_addr->prefix)); - } else { - zlog_info("PLIST PROC IN: NENastavujem metriku "); - } + } /*Get access-list from current interface */ - zlog_info("Checking access_list on interface: %s",ei->ifp->name); alist = ei->list[EIGRP_FILTER_IN]; - if (alist) { - zlog_info ("ALIST INT IN: %s", alist->name); - } else { - zlog_info("ALIST INT IN je prazdny"); - } /* Check if access-list fits */ - if (alist && access_list_apply (alist, (struct prefix *) dest_addr) == FILTER_DENY) + if (alist && + access_list_apply (alist, (struct prefix *)&dest_addr) == FILTER_DENY) { /* If yes, set reported metric to Max */ - zlog_info("INT IN: Nastavujem metriku na MAX"); ne->reported_metric.delay = EIGRP_MAX_METRIC; - zlog_info("INT IN Prefix: %s", inet_ntoa(dest_addr->prefix)); - } else { - zlog_info("INT IN: NENastavujem metriku "); - } + } plist = ei->prefix[EIGRP_FILTER_IN]; - if (plist) { - zlog_info ("PLIST INT IN: %s", plist->name); - } else { - zlog_info("PLIST INT IN je prazdny"); - } - /* Check if prefix-list fits */ - if (plist && prefix_list_apply (plist, - (struct prefix *) dest_addr) == PREFIX_DENY) + if (plist && + prefix_list_apply (plist, (struct prefix *)&dest_addr) == PREFIX_DENY) { /* If yes, set reported metric to Max */ - zlog_info("PLIST INT IN: Nastavujem metriku na MAX"); ne->reported_metric.delay = EIGRP_MAX_METRIC; - zlog_info("PLIST INT IN Prefix: %s", inet_ntoa(dest_addr->prefix)); - } else { - zlog_info("PLIST INT IN: NENastavujem metriku "); - } + } /* * End of filtering */ ne->distance = eigrp_calculate_total_metrics(eigrp, ne); - zlog_info("distance); - zlog_info("total_metric.delay); - pe->fdistance = pe->distance = pe->rdistance = ne->distance; ne->prefix = pe; @@ -669,6 +631,7 @@ eigrp_update_send (struct eigrp_interface *ei) struct prefix_list *plist_i; struct eigrp *e; struct prefix_ipv4 *dest_addr; + bool packet_sent = false; u_int16_t length = EIGRP_HEADER_LEN; @@ -740,7 +703,8 @@ eigrp_update_send (struct eigrp_interface *ei) return; } - if((IF_DEF_PARAMS (ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) && (IF_DEF_PARAMS (ei->ifp)->auth_keychain != NULL)) + if((IF_DEF_PARAMS (ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) + && (IF_DEF_PARAMS (ei->ifp)->auth_keychain != NULL)) { eigrp_make_md5_digest(ei,ep->s, EIGRP_AUTH_UPDATE_FLAG); } @@ -762,6 +726,7 @@ eigrp_update_send (struct eigrp_interface *ei) { if (nbr->state == EIGRP_NEIGHBOR_UP) { + packet_sent = true; /*Put packet to retransmission queue*/ eigrp_fifo_push_head(nbr->retrans_queue, ep); @@ -771,6 +736,9 @@ eigrp_update_send (struct eigrp_interface *ei) } } } + + if (!packet_sent) + eigrp_packet_free(ep); } void