ospfd: Refactor fifo_flush for the interface

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-08-10 21:56:40 -04:00
parent 14fad76ce2
commit fb617d1874
3 changed files with 18 additions and 18 deletions

View File

@ -494,6 +494,20 @@ struct ospf_interface *ospf_if_lookup_recv_if(struct ospf *ospf,
return match;
}
void ospf_interface_fifo_flush(struct ospf_interface *oi)
{
struct ospf *ospf = oi->ospf;
ospf_fifo_flush(oi->obuf);
if (oi->on_write_q) {
listnode_delete(ospf->oi_write_q, oi);
if (list_isempty(ospf->oi_write_q))
THREAD_OFF(ospf->t_write);
oi->on_write_q = 0;
}
}
static void ospf_if_reset_stats(struct ospf_interface *oi)
{
oi->hello_in = oi->hello_out = 0;
@ -505,19 +519,10 @@ static void ospf_if_reset_stats(struct ospf_interface *oi)
void ospf_if_stream_unset(struct ospf_interface *oi)
{
struct ospf *ospf = oi->ospf;
/* flush the interface packet queue */
ospf_fifo_flush(oi->obuf);
ospf_interface_fifo_flush(oi);
/*reset protocol stats */
ospf_if_reset_stats(oi);
if (oi->on_write_q) {
listnode_delete(ospf->oi_write_q, oi);
if (list_isempty(ospf->oi_write_q))
THREAD_OFF(ospf->t_write);
oi->on_write_q = 0;
}
}

View File

@ -351,6 +351,8 @@ extern void ospf_if_interface(struct interface *ifp);
extern uint32_t ospf_if_count_area_params(struct interface *ifp);
extern void ospf_reset_hello_timer(struct interface *ifp, struct in_addr addr,
bool is_addr);
extern void ospf_interface_fifo_flush(struct ospf_interface *oi);
DECLARE_HOOK(ospf_vl_add, (struct ospf_vl_data * vd), (vd));
DECLARE_HOOK(ospf_vl_delete, (struct ospf_vl_data * vd), (vd));

View File

@ -439,14 +439,7 @@ static int nsm_kill_nbr(struct ospf_neighbor *nbr)
* be sending packets. Let's flush anything
* we got.
*/
ospf_fifo_flush(oi->obuf);
if (oi->on_write_q) {
listnode_delete(oi->ospf->oi_write_q, oi);
if (list_isempty(oi->ospf->oi_write_q))
THREAD_OFF(oi->ospf->t_write);
oi->on_write_q = 0;
}
ospf_interface_fifo_flush(oi);
return 0;
}