Skip to content

Commit

Permalink
Merge pull request FRRouting#13897 from donaldsharp/ospf_crashing_pos…
Browse files Browse the repository at this point in the history
…sibility

ospf6d: Stop crash in ospf6_write
  • Loading branch information
ton31337 authored Jul 2, 2023
2 parents 913f02f + 3fa39a3 commit b893852
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions ospf6d/ospf6_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -2576,9 +2576,7 @@ static void ospf6_send_lsupdate(struct ospf6_neighbor *on,
struct ospf6_interface *oi,
struct ospf6_packet *op)
{

if (on) {

if ((on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT)
|| (on->ospf6_if->state == OSPF6_INTERFACE_DR)
|| (on->ospf6_if->state == OSPF6_INTERFACE_BDR))
Expand All @@ -2595,19 +2593,36 @@ static void ospf6_send_lsupdate(struct ospf6_neighbor *on,
op->dst = alldrouters6;
}
if (oi) {
struct ospf6 *ospf6;

ospf6_fill_hdr_checksum(oi, op);
ospf6_packet_add(oi, op);
/* If ospf instance is being deleted, send the packet
* immediately
*/
if ((oi->area == NULL) || (oi->area->ospf6 == NULL))
return;
if (oi->area->ospf6->inst_shutdown) {

ospf6 = oi->area->ospf6;
if (ospf6->inst_shutdown) {
if (oi->on_write_q == 0) {
listnode_add(oi->area->ospf6->oi_write_q, oi);
listnode_add(ospf6->oi_write_q, oi);
oi->on_write_q = 1;
}
event_execute(master, ospf6_write, oi->area->ospf6, 0);
/*
* When ospf6d immediately calls event_execute
* for items in the oi_write_q. The event_execute
* will call ospf6_write and cause the oi_write_q
* to be emptied. *IF* there is already an event
* scheduled for the oi_write_q by something else
* then when it wakes up in the future and attempts
* to cycle through items in the queue it will
* assert. Let's stop the t_write event and
* if ospf6_write doesn't finish up the work
* it will schedule itself again.
*/
event_cancel(&ospf6->t_write);
event_execute(master, ospf6_write, ospf6, 0);
} else
OSPF6_MESSAGE_WRITE_ON(oi);
}
Expand Down

0 comments on commit b893852

Please sign in to comment.