]> git.puffer.fish Git - matthieu/frr.git/commitdiff
eigrpd: When writing packet don't crash in some cases
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sun, 29 Oct 2017 12:51:57 +0000 (08:51 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sun, 29 Oct 2017 13:48:02 +0000 (09:48 -0400)
When we are writing a packet if we have gotten ourselves
into a bad situation, note it and move on.  Hopefully
dumping enough information so that we can find the offending
reason.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
eigrpd/eigrp_packet.c
eigrpd/eigrp_query.c

index 83ff194729f592ab9a46d9150362e9c0b3a3ec85..5b54f813269f0e84f389b6533729ebc2ff647600 100644 (file)
@@ -344,8 +344,18 @@ int eigrp_write(struct thread *thread)
 
        /* Get one packet from queue. */
        ep = eigrp_fifo_next(ei->obuf);
-       assert(ep);
-       assert(ep->length >= EIGRP_HEADER_LEN);
+       if (!ep) {
+               zlog_err("%s: Interface %s no packet on queue?",
+                        __PRETTY_FUNCTION__, ei->ifp->name);
+               goto out;
+       }
+       if (ep->length < EIGRP_HEADER_LEN) {
+               zlog_err("%s: Packet just has a header?",
+                        __PRETTY_FUNCTION__);
+               eigrp_header_dump((struct eigrp_header *)ep->s->data);
+               eigrp_packet_delete(ei);
+               goto out;
+       }
 
        if (ep->dst.s_addr == htonl(EIGRP_MULTICAST_ADDRESS))
                eigrp_if_ipmulticast(eigrp, ei->address, ei->ifp->ifindex);
@@ -442,6 +452,7 @@ int eigrp_write(struct thread *thread)
        /* Now delete packet from queue. */
        eigrp_packet_delete(ei);
 
+out:
        if (eigrp_fifo_next(ei->obuf) == NULL) {
                ei->on_write_q = 0;
                list_delete_node(eigrp->oi_write_q, node);
index 58f3d2b53c5bf5263c4adb087d78fb5e44bbb62c..caa37870a1edc7c961d7ee93643b5c116ea1a101 100644 (file)
@@ -165,7 +165,7 @@ void eigrp_send_query(struct eigrp_interface *ei)
        struct listnode *node, *nnode, *node2, *nnode2;
        struct eigrp_neighbor *nbr;
        struct eigrp_prefix_entry *pe;
-       char has_tlv;
+       bool has_tlv = false;
        bool ep_saved = false;
 
        ep = eigrp_packet_new(ei->ifp->mtu, NULL);
@@ -180,7 +180,6 @@ void eigrp_send_query(struct eigrp_interface *ei)
                length += eigrp_add_authTLV_MD5_to_stream(ep->s, ei);
        }
 
-       has_tlv = 0;
        for (ALL_LIST_ELEMENTS(ei->eigrp->topology_changes_internalIPV4, node,
                               nnode, pe)) {
                if (!(pe->req_action & EIGRP_FSM_NEED_QUERY))
@@ -190,7 +189,7 @@ void eigrp_send_query(struct eigrp_interface *ei)
                for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
                        if (nbr->state == EIGRP_NEIGHBOR_UP) {
                                listnode_add(pe->rij, nbr);
-                               has_tlv = 1;
+                               has_tlv = true;;
                        }
                }
        }