Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ospfd: no router ospf crash fix #4685

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ospfd: no router ospf crash fix
no router ospf triggers to cancel all threads
including read/write (receive/send packets) threads,
cleans up resources fd, message queue and data.

Last job of write (packet) thread invoked where the
ospf instance is referenced is not running nor
the socket fd valid.

Write thread callback should check if fd is valid and
ospf instance is running before proceeding to send a
message over socket.

Ticket:CM-20095
Testing Done:

Performed the multiple 'no router ospf' with the fix
in topology where the crash was seen.
Post fix the crash is not observed.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
  • Loading branch information
chiragshah6 committed Jul 15, 2019
commit c32eba04f311d2bd4d249b2d84a3b496b0f4d302
8 changes: 8 additions & 0 deletions ospfd/ospf_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,14 @@ static int ospf_write(struct thread *thread)
struct in_pktinfo *pi;
#endif

if (ospf->fd < 0 || ospf->oi_running == 0) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"ospf_write failed to send, fd %d, instance %u"
,ospf->fd, ospf->oi_running);
return -1;
}

ospf->t_write = NULL;

node = listhead(ospf->oi_write_q);
Expand Down
17 changes: 9 additions & 8 deletions ospfd/ospfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ static void ospf_finish_final(struct ospf *ospf)
for (ALL_LIST_ELEMENTS(ospf->oiflist, node, nnode, oi))
ospf_if_free(oi);
list_delete(&ospf->oiflist);
ospf->oi_running = 0;

/* De-Register VRF */
ospf_zebra_vrf_deregister(ospf);
Expand Down Expand Up @@ -699,6 +700,8 @@ static void ospf_finish_final(struct ospf *ospf)
}

/* Cancel all timers. */
OSPF_TIMER_OFF(ospf->t_read);
OSPF_TIMER_OFF(ospf->t_write);
OSPF_TIMER_OFF(ospf->t_external_lsa);
OSPF_TIMER_OFF(ospf->t_spf_calc);
OSPF_TIMER_OFF(ospf->t_ase_calc);
Expand All @@ -708,14 +711,9 @@ static void ospf_finish_final(struct ospf *ospf)
OSPF_TIMER_OFF(ospf->t_asbr_check);
OSPF_TIMER_OFF(ospf->t_distribute_update);
OSPF_TIMER_OFF(ospf->t_lsa_refresher);
OSPF_TIMER_OFF(ospf->t_read);
OSPF_TIMER_OFF(ospf->t_write);
OSPF_TIMER_OFF(ospf->t_opaque_lsa_self);
OSPF_TIMER_OFF(ospf->t_sr_update);

close(ospf->fd);
stream_free(ospf->ibuf);

LSDB_LOOP (OPAQUE_AS_LSDB(ospf), rn, lsa)
ospf_discard_from_db(ospf, ospf->lsdb, lsa);
LSDB_LOOP (EXTERNAL_LSDB(ospf), rn, lsa)
Expand Down Expand Up @@ -755,9 +753,6 @@ static void ospf_finish_final(struct ospf *ospf)
ospf_ase_external_lsas_finish(ospf->external_lsas);
}

list_delete(&ospf->areas);
list_delete(&ospf->oi_write_q);

for (i = ZEBRA_ROUTE_SYSTEM; i <= ZEBRA_ROUTE_MAX; i++) {
struct list *ext_list;
struct ospf_external *ext;
Expand Down Expand Up @@ -789,6 +784,12 @@ static void ospf_finish_final(struct ospf *ospf)
if (!CHECK_FLAG(om->options, OSPF_MASTER_SHUTDOWN))
instance = ospf->instance;

list_delete(&ospf->areas);
list_delete(&ospf->oi_write_q);

close(ospf->fd);
stream_free(ospf->ibuf);
ospf->fd = -1;
ospf_delete(ospf);

if (ospf->name) {
Expand Down