]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospf6d: add write-multiplier configuration
authorPat Ruddy <pat@voltanet.io>
Thu, 6 May 2021 10:39:58 +0000 (11:39 +0100)
committerPat Ruddy <pat@voltanet.io>
Fri, 18 Jun 2021 08:40:42 +0000 (09:40 +0100)
allow amount of work done by read and write threads in a single
invocation to be tuned to between 1 and 100 packets (default 20)

Signed-off-by: Pat Ruddy <pat@voltanet.io>
ospf6d/ospf6_interface.c
ospf6d/ospf6_message.c
ospf6d/ospf6_top.c
ospf6d/ospf6_top.h

index 57b7348bccb9c432f8b00df361449645ee40a06b..0651b3188c0d95f79b36449b2dc120f46e96c5b7 100644 (file)
@@ -1985,6 +1985,38 @@ DEFUN (no_auto_cost_reference_bandwidth,
 }
 
 
+DEFUN (ospf6_write_multiplier,
+       ospf6_write_multiplier_cmd,
+       "write-multiplier (1-100)",
+       "Write multiplier\n"
+       "Maximum number of interface serviced per write\n")
+{
+       VTY_DECLVAR_CONTEXT(ospf6, o);
+       uint32_t write_oi_count;
+
+       write_oi_count = strtol(argv[1]->arg, NULL, 10);
+       if (write_oi_count < 1 || write_oi_count > 100) {
+               vty_out(vty, "write-multiplier value is invalid\n");
+               return CMD_WARNING_CONFIG_FAILED;
+       }
+
+       o->write_oi_count = write_oi_count;
+       return CMD_SUCCESS;
+}
+
+DEFUN (no_ospf6_write_multiplier,
+       no_ospf6_write_multiplier_cmd,
+       "no write-multiplier (1-100)",
+       NO_STR
+       "Write multiplier\n"
+       "Maximum number of interface serviced per write\n")
+{
+       VTY_DECLVAR_CONTEXT(ospf6, o);
+
+       o->write_oi_count = OSPF6_WRITE_INTERFACE_COUNT_DEFAULT;
+       return CMD_SUCCESS;
+}
+
 DEFUN (ipv6_ospf6_hellointerval,
        ipv6_ospf6_hellointerval_cmd,
        "ipv6 ospf6 hello-interval (1-65535)",
@@ -2657,6 +2689,9 @@ void ospf6_interface_init(void)
        /* reference bandwidth commands */
        install_element(OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
        install_element(OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
+       /* write-multiplier commands */
+       install_element(OSPF6_NODE, &ospf6_write_multiplier_cmd);
+       install_element(OSPF6_NODE, &no_ospf6_write_multiplier_cmd);
 }
 
 /* Clear the specified interface structure */
index 95ea4b5c14b2e1fa7ae2c5abac64dee628793341..a5470917e50bbcc0819954c5095ae480b5647046 100644 (file)
@@ -1848,7 +1848,7 @@ int ospf6_receive(struct thread *thread)
        thread_add_read(master, ospf6_receive, ospf6, ospf6->fd,
                        &ospf6->t_ospf6_receive);
 
-       while (count < OSPF6_WRITE_INTERFACE_COUNT_DEFAULT) {
+       while (count < ospf6->write_oi_count) {
                count++;
                switch (ospf6_read_helper(sockfd, ospf6)) {
                case OSPF6_READ_ERROR:
@@ -1966,7 +1966,7 @@ static int ospf6_write(struct thread *thread)
        assert(node);
        oi = listgetdata(node);
 
-       while ((pkt_count < OSPF6_WRITE_INTERFACE_COUNT_DEFAULT) && oi
+       while ((pkt_count < ospf6->write_oi_count) && oi
               && (last_serviced_oi != oi)) {
 
                op = ospf6_fifo_head(oi->obuf);
index adfedcc49c04255a8ccfbdb5908afd6e78ea141c..193ee4800dce4fdd70acc103d18843123c573354 100644 (file)
@@ -406,6 +406,7 @@ static struct ospf6 *ospf6_create(const char *name)
 
        o->external_id_table = route_table_init();
 
+       o->write_oi_count = OSPF6_WRITE_INTERFACE_COUNT_DEFAULT;
        o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
 
        o->distance_table = route_table_init();
@@ -1668,6 +1669,11 @@ static int config_write_ospf6(struct vty *vty)
                        vty_out(vty, " auto-cost reference-bandwidth %d\n",
                                ospf6->ref_bandwidth);
 
+               if (ospf6->write_oi_count
+                   != OSPF6_WRITE_INTERFACE_COUNT_DEFAULT)
+                       vty_out(vty, " write-multiplier %d\n",
+                               ospf6->write_oi_count);
+
                /* LSA timers print. */
                if (ospf6->lsa_minarrival != OSPF_MIN_LS_ARRIVAL)
                        vty_out(vty, " timers lsa min-arrival %d\n",
index dfd68939831ad275fe7b454e1f027650da80998a..5b739ac76b098bd0b8b9668a9eed2751775daaeb 100644 (file)
@@ -131,6 +131,7 @@ struct ospf6 {
 #define OSPF6_WRITE_INTERFACE_COUNT_DEFAULT 20
        struct thread *t_write;
 
+       int write_oi_count; /* Num of packets sent per thread invocation */
        uint32_t ref_bandwidth;
 
        /* Distance parameters */