mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-02 20:59:42 +00:00
Modified the number of writes to service at most
20 interfaces. Signed-off-by: Ayan Banerjee <ayan@cumulusnetworks.com> Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
This commit is contained in:
parent
2f8f370e35
commit
e8f45e82d4
@ -640,6 +640,7 @@ ospf_write (struct thread *thread)
|
||||
{
|
||||
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;
|
||||
@ -669,16 +670,21 @@ ospf_write (struct thread *thread)
|
||||
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);
|
||||
@ -804,19 +810,30 @@ ospf_write (struct thread *thread)
|
||||
|
||||
/* 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))
|
||||
|
@ -2533,35 +2533,50 @@ DEFUN (no_ospf_auto_cost_reference_bandwidth,
|
||||
|
||||
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",
|
||||
@ -2793,7 +2808,7 @@ DEFUN (show_ip_ospf,
|
||||
|
||||
/* 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",
|
||||
@ -7323,9 +7338,9 @@ ospf_config_write (struct vty *vty)
|
||||
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);
|
||||
@ -7766,6 +7781,8 @@ ospf_vty_init (void)
|
||||
/* 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 ();
|
||||
|
@ -233,7 +233,7 @@ ospf_new (void)
|
||||
}
|
||||
new->t_read = thread_add_read (master, ospf_read, new, new->fd);
|
||||
new->oi_write_q = list_new ();
|
||||
new->write_multiplier = OSPF_WRITE_MULTIPLIER_DEFAULT;
|
||||
new->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
@ -219,8 +219,8 @@ struct ospf
|
||||
struct thread *t_deferred_shutdown; /* deferred/stub-router shutdown timer*/
|
||||
|
||||
struct thread *t_write;
|
||||
#define OSPF_WRITE_MULTIPLIER_DEFAULT 3
|
||||
int write_multiplier; /* Num of packets sent per thread invocation */
|
||||
#define OSPF_WRITE_INTERFACE_COUNT_DEFAULT 20
|
||||
int write_oi_count; /* Num of packets sent per thread invocation */
|
||||
struct thread *t_read;
|
||||
int fd;
|
||||
unsigned int maxsndbuflen;
|
||||
|
Loading…
Reference in New Issue
Block a user