summaryrefslogtreecommitdiff
path: root/ospfd/ospf_interface.c
diff options
context:
space:
mode:
authorChirag Shah <chirag@cumulusnetworks.com>2018-05-01 07:36:53 -0700
committerChirag Shah <chirag@cumulusnetworks.com>2018-05-10 17:45:43 -0700
commit4fc8a85288f48f607b13f7bb36c5055fda92a639 (patch)
tree9562405e6e925aec0d55c4410c6937c403f8c533 /ospfd/ospf_interface.c
parent3dc755e492093c42d0983620da810893c413c533 (diff)
ospfd: packet fifo init in interface create
Currently, interface packet transmit queue is created/deleted as part of Interface UP/Down event. This results in a rare condition where port came up but queue was not created. The creation of queue occupies only few bytes. Moving fifo queue creation to interface create would add few bytes of fifo creation but at least it guaranteed to be available during Up/down -->Up event. Initialize ospf packet fifo queue during ospf interface creation. Drain queue during interface down event. Drained and free the queue as part of the interface delete/cleanup. Ticket:CM-20744 Testing Done: Bring up ospfv2 topology with multiple neighbors. 1) Trigger multiple shut/no shut events and validate all queues are freed. 2) configure/deconfigure router ospf and validate all ospf instance and interface underneath are freed. Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
Diffstat (limited to 'ospfd/ospf_interface.c')
-rw-r--r--ospfd/ospf_interface.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 52b954d6a1..ea31d8c2ca 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -263,6 +263,9 @@ struct ospf_interface *ospf_if_new(struct ospf *ospf, struct interface *ifp,
ospf_opaque_type9_lsa_init(oi);
oi->ospf = ospf;
+
+ ospf_if_stream_set(oi);
+
QOBJ_REG(oi, ospf_interface);
if (IS_DEBUG_OSPF_EVENT)
@@ -322,6 +325,9 @@ void ospf_if_free(struct ospf_interface *oi)
{
ospf_if_down(oi);
+ if (oi->obuf)
+ ospf_fifo_free(oi->obuf);
+
assert(oi->state == ISM_Down);
ospf_opaque_type9_lsa_term(oi);
@@ -496,9 +502,8 @@ void ospf_if_stream_unset(struct ospf_interface *oi)
struct ospf *ospf = oi->ospf;
if (oi->obuf) {
- ospf_fifo_free(oi->obuf);
- oi->obuf = NULL;
-
+ /* flush the interface packet queue */
+ ospf_fifo_flush(oi->obuf);
/*reset protocol stats */
ospf_if_reset_stats(oi);
@@ -781,7 +786,6 @@ int ospf_if_up(struct ospf_interface *oi)
if (oi->type == OSPF_IFTYPE_LOOPBACK)
OSPF_ISM_EVENT_SCHEDULE(oi, ISM_LoopInd);
else {
- ospf_if_stream_set(oi);
OSPF_ISM_EVENT_SCHEDULE(oi, ISM_InterfaceUp);
}