eigrpd: Fix memory leak in eigrp_update

When we send packets to a nbr, make a duplicate copy
as that each packet sent is assumed to be a complete
to itself.

Also clean up indentation in loop over figuring out
what to send.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2017-08-19 13:42:48 -04:00
parent de4ddd13aa
commit a75c1cc191

View File

@ -651,15 +651,16 @@ void eigrp_update_send(struct eigrp_interface *ei)
has_tlv = 0;
for (ALL_LIST_ELEMENTS(ei->eigrp->topology_changes_internalIPV4, node,
nnode, pe)) {
if (pe->req_action & EIGRP_FSM_NEED_UPDATE) {
if (!(pe->req_action & EIGRP_FSM_NEED_UPDATE))
continue;
/* Get destination address from prefix */
dest_addr = pe->destination_ipv4;
/*
* Filtering
*/
// TODO: Work in progress
/* get list from eigrp process */
e = eigrp_lookup();
/* Get access-lists and prefix-lists from process and
* interface */
@ -692,13 +693,6 @@ void eigrp_update_send(struct eigrp_interface *ei)
pe);
has_tlv = 1;
}
/*
* End of filtering
*/
/* NULL the pointer */
dest_addr = NULL;
}
}
if (!has_tlv) {
@ -725,16 +719,24 @@ void eigrp_update_send(struct eigrp_interface *ei)
ep->sequence_number);
for (ALL_LIST_ELEMENTS(ei->nbrs, node, nnode, nbr)) {
if (nbr->state == EIGRP_NEIGHBOR_UP) {
struct eigrp_packet *ep_dup;
if (nbr->state != EIGRP_NEIGHBOR_UP)
continue;
if (packet_sent)
ep_dup = eigrp_packet_duplicate(ep);
else
ep_dup = ep;
packet_sent = true;
/*Put packet to retransmission queue*/
eigrp_fifo_push(nbr->retrans_queue, ep);
eigrp_fifo_push(nbr->retrans_queue, ep_dup);
if (nbr->retrans_queue->count == 1) {
eigrp_send_packet_reliably(nbr);
}
}
}
if (!packet_sent)
eigrp_packet_free(ep);