]> git.puffer.fish Git - mirror/frr.git/commitdiff
Modified the number of writes to service at most
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 20 May 2015 00:24:43 +0000 (17:24 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 20 May 2015 00:24:43 +0000 (17:24 -0700)
20 interfaces.

Signed-off-by: Ayan Banerjee <ayan@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
ospfd/ospf_packet.c
ospfd/ospf_vty.c
ospfd/ospfd.c
ospfd/ospfd.h

index 43a237cf558b4ad558c7e406452c7af47dfc1316..ff1bdae59fa7068a4291f2dc0e4a8228db6a3522 100644 (file)
@@ -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))
index b9c99b1dbdf3095b9c82cf9b4609165e1a1a8d10..839a2b699703952b33e7e7237315b2002bdb0309 100644 (file)
@@ -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 ();
index 09f3a142471c11379ed3fbdec4e1f6938295571a..4cddca67d21cffb3d456f176e83e13827714a820 100644 (file)
@@ -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;
 }
index 3e8b52e9e323b224dc58bf9b5ce0f0c77b67e296..9920a6e2ef47218a949f85fd85967de7421e6976 100644 (file)
@@ -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;