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,53 +651,47 @@ void eigrp_update_send(struct eigrp_interface *ei)
has_tlv = 0; has_tlv = 0;
for (ALL_LIST_ELEMENTS(ei->eigrp->topology_changes_internalIPV4, node, for (ALL_LIST_ELEMENTS(ei->eigrp->topology_changes_internalIPV4, node,
nnode, pe)) { nnode, pe)) {
if (pe->req_action & EIGRP_FSM_NEED_UPDATE) {
/* Get destination address from prefix */
dest_addr = pe->destination_ipv4;
/* if (!(pe->req_action & EIGRP_FSM_NEED_UPDATE))
* Filtering continue;
*/
// TODO: Work in progress
/* get list from eigrp process */
e = eigrp_lookup();
/* Get access-lists and prefix-lists from process and
* interface */
alist = e->list[EIGRP_FILTER_OUT];
plist = e->prefix[EIGRP_FILTER_OUT];
alist_i = ei->list[EIGRP_FILTER_OUT];
plist_i = ei->prefix[EIGRP_FILTER_OUT];
/* Check if any list fits */ /* Get destination address from prefix */
if ((alist dest_addr = pe->destination_ipv4;
&& 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)) {
// pe->reported_metric.delay = EIGRP_MAX_METRIC;
continue;
} else {
length += eigrp_add_internalTLV_to_stream(ep->s,
pe);
has_tlv = 1;
}
/*
* End of filtering
*/
/* NULL the pointer */ /*
dest_addr = NULL; * Filtering
*/
e = eigrp_lookup();
/* Get access-lists and prefix-lists from process and
* interface */
alist = e->list[EIGRP_FILTER_OUT];
plist = e->prefix[EIGRP_FILTER_OUT];
alist_i = ei->list[EIGRP_FILTER_OUT];
plist_i = ei->prefix[EIGRP_FILTER_OUT];
/* 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)) {
// pe->reported_metric.delay = EIGRP_MAX_METRIC;
continue;
} else {
length += eigrp_add_internalTLV_to_stream(ep->s,
pe);
has_tlv = 1;
} }
} }
@ -725,14 +719,22 @@ void eigrp_update_send(struct eigrp_interface *ei)
ep->sequence_number); ep->sequence_number);
for (ALL_LIST_ELEMENTS(ei->nbrs, node, nnode, nbr)) { for (ALL_LIST_ELEMENTS(ei->nbrs, node, nnode, nbr)) {
if (nbr->state == EIGRP_NEIGHBOR_UP) { struct eigrp_packet *ep_dup;
packet_sent = true;
/*Put packet to retransmission queue*/
eigrp_fifo_push(nbr->retrans_queue, ep);
if (nbr->retrans_queue->count == 1) { if (nbr->state != EIGRP_NEIGHBOR_UP)
eigrp_send_packet_reliably(nbr); 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_dup);
if (nbr->retrans_queue->count == 1) {
eigrp_send_packet_reliably(nbr);
} }
} }