{
struct ospf *ospf = THREAD_ARG (thread);
struct ospf_interface *oi;
+ struct ospf_interface *last_serviced_oi = NULL;
struct ospf_packet *op;
struct sockaddr_in sa_dst;
struct ip iph;
ipid = (time(NULL) & 0xffff);
#endif /* WANT_OSPF_WRITE_FRAGMENT */
- /* convenience - max OSPF data per packet,
- * and reliability - not more data, than our
- * socket can accept
- */
- maxdatasize = MIN (oi->ifp->mtu, ospf->maxsndbuflen) -
- sizeof (struct ip);
-
- while ((pkt_count < ospf->write_multiplier) && ospf_fifo_count(oi->obuf))
+ while ((pkt_count < ospf->write_oi_count) && oi && (last_serviced_oi != oi))
{
+ /* If there is only packet in the queue, the oi is removed from
+ write-q, so fix up the last interface that was serviced */
+ if (last_serviced_oi == NULL) {
+ last_serviced_oi = oi;
+ }
pkt_count++;
+ /* convenience - max OSPF data per packet,
+ * and reliability - not more data, than our
+ * socket can accept
+ */
+ maxdatasize = MIN (oi->ifp->mtu, ospf->maxsndbuflen) -
+ sizeof (struct ip);
+
/* Get one packet from queue. */
op = ospf_fifo_head (oi->obuf);
assert (op);
/* Now delete packet from queue. */
ospf_packet_delete (oi);
- }
- /* 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);
- if (ospf_fifo_head (oi->obuf) == NULL)
- {
- oi->on_write_q = 0;
- }
- else
- {
- listnode_add (ospf->oi_write_q, oi);
- }
+ /* 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);
+ if (ospf_fifo_head (oi->obuf) == NULL)
+ {
+ oi->on_write_q = 0;
+ last_serviced_oi = NULL;
+ oi = NULL;
+ }
+ else
+ {
+ listnode_add (ospf->oi_write_q, oi);
+ }
+
+ /* Setup to service from the head of the queue again */
+ if (!list_isempty (ospf->oi_write_q))
+ {
+ node = listhead (ospf->oi_write_q);
+ assert (node);
+ oi = listgetdata (node);
+ assert (oi);
+ }
+ }
/* If packets still remain in queue, call write thread. */
if (!list_isempty (ospf->oi_write_q))
DEFUN (ospf_write_multiplier,
ospf_write_multiplier_cmd,
- "write-multiplier <1-50>",
- "Number of writes per thread callback\n")
+ "ospf write-multiplier <1-100>",
+ "OSPF specific commands\n"
+ "Write multiplier\n"
+ "Maximum number of interface serviced per write\n")
{
struct ospf *ospf = vty->index;
- u_int32_t write_multiplier;
+ u_int32_t write_oi_count;
- write_multiplier = strtol (argv[0], NULL, 10);
- if (write_multiplier < 1 || write_multiplier > 50)
+ write_oi_count = strtol (argv[0], NULL, 10);
+ if (write_oi_count < 1 || write_oi_count > 100)
{
vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
- ospf->write_multiplier = write_multiplier;
+ ospf->write_oi_count = write_oi_count;
return CMD_SUCCESS;
}
+ALIAS (ospf_write_multiplier,
+ write_multiplier_cmd,
+ "write-multiplier <1-100>",
+ "Write multiplier\n"
+ "Maximum number of interface serviced per write\n")
+
DEFUN (no_ospf_write_multiplier,
no_ospf_write_multiplier_cmd,
- "no write-multiplier",
+ "no ospf write-multiplier",
NO_STR
- "Number of writes per thread callback\n")
+ "OSPF specific commands\n"
+ "Write multiplier\n")
{
struct ospf *ospf = vty->index;
- ospf->write_multiplier = OSPF_WRITE_MULTIPLIER_DEFAULT;
+ ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
return CMD_SUCCESS;
}
+ALIAS (no_ospf_write_multiplier,
+ no_write_multiplier_cmd,
+ "no write-multiplier",
+ NO_STR
+ "Write multiplier\n")
+
const char *ospf_abr_type_descr_str[] =
{
"Unknown",
/* Show write multiplier values */
vty_out (vty, " Write Multiplier set to %d %s",
- ospf->write_multiplier, VTY_NEWLINE);
+ ospf->write_oi_count, VTY_NEWLINE);
/* Show refresh parameters. */
vty_out (vty, " Refresh timer %d secs%s",
ospf->spf_max_holdtime, VTY_NEWLINE);
/* Write multiplier print. */
- if (ospf->write_multiplier != OSPF_WRITE_MULTIPLIER_DEFAULT)
+ if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT)
vty_out (vty, " ospf write-multiplier %d%s",
- ospf->write_multiplier, VTY_NEWLINE);
+ ospf->write_oi_count, VTY_NEWLINE);
/* Max-metric router-lsa print */
config_write_stub_router (vty, ospf);
/* write multiplier commands */
install_element (OSPF_NODE, &ospf_write_multiplier_cmd);
install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd);
+ install_element (OSPF_NODE, &write_multiplier_cmd);
+ install_element (OSPF_NODE, &no_write_multiplier_cmd);
/* Init interface related vty commands. */
ospf_vty_if_init ();