mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-04 06:55:18 +00:00
ospfd: Cleanup oi->obuf to always be created
This looks like a finish up of the partial cleanup that ocurred at some point in time in the past. When we alloc oi also always alloc the oi->obuf. When we delete oi always delete the oi->obuf right before. This cleans up a bunch of code to be simpler and hopefully easier to follow. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
7cec50a533
commit
36a106e0e4
@ -225,12 +225,14 @@ struct ospf_interface *ospf_if_new(struct ospf *ospf, struct interface *ifp,
|
||||
{
|
||||
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;
|
||||
@ -264,8 +266,6 @@ struct ospf_interface *ospf_if_new(struct ospf *ospf, struct interface *ifp,
|
||||
|
||||
oi->ospf = ospf;
|
||||
|
||||
ospf_if_stream_set(oi);
|
||||
|
||||
QOBJ_REG(oi, ospf_interface);
|
||||
|
||||
if (IS_DEBUG_OSPF_EVENT)
|
||||
@ -325,8 +325,7 @@ void ospf_if_free(struct ospf_interface *oi)
|
||||
{
|
||||
ospf_if_down(oi);
|
||||
|
||||
if (oi->obuf)
|
||||
ospf_fifo_free(oi->obuf);
|
||||
ospf_fifo_free(oi->obuf);
|
||||
|
||||
assert(oi->state == ISM_Down);
|
||||
|
||||
@ -490,29 +489,20 @@ static void ospf_if_reset_stats(struct ospf_interface *oi)
|
||||
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);
|
||||
/* 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -903,8 +893,6 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
|
||||
|
||||
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;
|
||||
|
@ -285,7 +285,6 @@ extern void ospf_if_update_params(struct interface *, struct in_addr);
|
||||
|
||||
extern int ospf_if_new_hook(struct interface *);
|
||||
extern void ospf_if_init(void);
|
||||
extern void ospf_if_stream_set(struct ospf_interface *);
|
||||
extern void ospf_if_stream_unset(struct ospf_interface *);
|
||||
extern void ospf_if_reset_variables(struct ospf_interface *);
|
||||
extern int ospf_if_is_enable(struct ospf_interface *);
|
||||
|
@ -233,20 +233,6 @@ void ospf_fifo_free(struct ospf_fifo *fifo)
|
||||
|
||||
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);
|
||||
|
||||
@ -257,20 +243,6 @@ static void ospf_packet_add(struct ospf_interface *oi, struct ospf_packet *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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user