ospfd: Tweak previous iface RR write patch to avoid free/malloc & redundant log
* linklist.{c,h}: (listnode_move_to_tail) new unction to move a
listnode to tail of list.
* ospf_packet.c: (ospf_write) remove debug that seemed to be mostly covered
by existing debug.
Use listnode_move_to_tail to just move the list node to the end of the
tail, rather than freeing the one to hand and allocing a new one.
diff --git a/lib/linklist.c b/lib/linklist.c
index 370b2fa..4b16f07 100644
--- a/lib/linklist.c
+++ b/lib/linklist.c
@@ -159,6 +159,13 @@
list->count++;
}
+/* Move given listnode to tail of the list */
+void
+listnode_move_to_tail (struct list *l, struct listnode *n)
+{
+ LISTNODE_DETACH(l,n);
+ LISTNODE_ATTACH(l,n);
+}
/* Delete specific date pointer from the list. */
void
diff --git a/lib/linklist.h b/lib/linklist.h
index 24a9e20..c8d715e 100644
--- a/lib/linklist.h
+++ b/lib/linklist.h
@@ -68,6 +68,7 @@
extern void listnode_add (struct list *, void *);
extern void listnode_add_sort (struct list *, void *);
extern void listnode_add_after (struct list *, struct listnode *, void *);
+extern void listnode_move_to_tail (struct list *, struct listnode *);
extern void listnode_delete (struct list *, void *);
extern struct listnode *listnode_lookup (struct list *, void *);
extern void *listnode_head (struct list *);
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index d2504c7..36aa895 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -760,11 +760,6 @@
sockopt_iphdrincl_swab_htosys (&iph);
ret = sendmsg (ospf->fd, &msg, flags);
sockopt_iphdrincl_swab_systoh (&iph);
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug ("ospf_write to %s, "
- "id %d, off %d, len %d, interface %s, mtu %u:",
- inet_ntoa (iph.ip_dst), iph.ip_id, iph.ip_off, iph.ip_len,
- oi->ifp->name, oi->ifp->mtu);
if (ret < 0)
zlog_warn ("*** sendmsg in ospf_write failed to %s, "
@@ -796,14 +791,11 @@
/* Move this interface to the tail of write_q to
serve everyone in a round robin fashion */
- list_delete_node (ospf->oi_write_q, node);
+ listnode_move_to_tail (ospf->oi_write_q, node);
if (ospf_fifo_head (oi->obuf) == NULL)
{
oi->on_write_q = 0;
- }
- else
- {
- listnode_add (ospf->oi_write_q, oi);
+ list_delete_node (ospf->oi_write_q, node);
}
/* If packets still remain in queue, call write thread. */