{
struct ospf_interface *oi;
- if ((oi = ospf_if_table_lookup(ifp, p)) == NULL) {
- oi = XCALLOC(MTYPE_OSPF_IF, sizeof(struct ospf_interface));
- memset(oi, 0, sizeof(struct ospf_interface));
- } else
+ oi = ospf_if_table_lookup(ifp, p);
+ if (oi)
return oi;
+ oi = XCALLOC(MTYPE_OSPF_IF, sizeof(struct ospf_interface));
+
+ oi->obuf = ospf_fifo_new();
+
/* Set zebra interface pointer. */
oi->ifp = ifp;
oi->address = p;
oi->ospf = ospf;
- ospf_if_stream_set(oi);
-
QOBJ_REG(oi, ospf_interface);
if (IS_DEBUG_OSPF_EVENT)
{
ospf_if_down(oi);
- if (oi->obuf)
- ospf_fifo_free(oi->obuf);
+ ospf_fifo_free(oi->obuf);
assert(oi->state == ISM_Down);
oi->ls_ack_in = oi->ls_ack_out = 0;
}
-void ospf_if_stream_set(struct ospf_interface *oi)
-{
- /* set output fifo queue. */
- if (oi->obuf == NULL)
- oi->obuf = ospf_fifo_new();
-}
-
void ospf_if_stream_unset(struct ospf_interface *oi)
{
struct ospf *ospf = oi->ospf;
- if (oi->obuf) {
- /* flush the interface packet queue */
- ospf_fifo_flush(oi->obuf);
- /*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))
- OSPF_TIMER_OFF(ospf->t_write);
- oi->on_write_q = 0;
- }
+ /* flush the interface packet queue */
+ ospf_fifo_flush(oi->obuf);
+ /*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))
+ OSPF_TIMER_OFF(ospf->t_write);
+ oi->on_write_q = 0;
}
}
ospf_area_add_if(voi->area, voi);
- ospf_if_stream_set(voi);
-
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_vl_new(): Stop");
return voi;
static void ospf_packet_add(struct ospf_interface *oi, struct ospf_packet *op)
{
- if (!oi->obuf) {
- flog_err(
- EC_OSPF_PKT_PROCESS,
- "ospf_packet_add(interface %s in state %d [%s], packet type %s, "
- "destination %s) called with NULL obuf, ignoring "
- "(please report this bug)!\n",
- IF_NAME(oi), oi->state,
- lookup_msg(ospf_ism_state_msg, oi->state, NULL),
- lookup_msg(ospf_packet_type_str,
- stream_getc_from(op->s, 1), NULL),
- inet_ntoa(op->dst));
- return;
- }
-
/* Add packet to end of queue. */
ospf_fifo_push(oi->obuf, op);
static void ospf_packet_add_top(struct ospf_interface *oi,
struct ospf_packet *op)
{
- if (!oi->obuf) {
- flog_err(
- EC_OSPF_PKT_PROCESS,
- "ospf_packet_add(interface %s in state %d [%s], packet type %s, "
- "destination %s) called with NULL obuf, ignoring "
- "(please report this bug)!\n",
- IF_NAME(oi), oi->state,
- lookup_msg(ospf_ism_state_msg, oi->state, NULL),
- lookup_msg(ospf_packet_type_str,
- stream_getc_from(op->s, 1), NULL),
- inet_ntoa(op->dst));
- return;
- }
-
/* Add packet to head of queue. */
ospf_fifo_push_head(oi->obuf, op);