]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospf6d: add "auto-cost reference-bandwidth" command
authorVincent Bernat <bernat@luffy.cx>
Wed, 24 Oct 2012 14:45:54 +0000 (14:45 +0000)
committerDavid Lamparter <equinox@opensourcerouting.org>
Fri, 21 Mar 2014 05:28:48 +0000 (06:28 +0100)
This command allows the user to change to default reference bandwidth
for cost calculations. The default value is 100 Mbps. With a default
bandwidth of 10 MBps, the default cost becomes 10. Those values are
consistent with OSPFv2.

[DL: resolved conflicts in vty command additions & docs]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
doc/ospf6d.texi
ospf6d/README
ospf6d/ospf6_interface.c
ospf6d/ospf6_snmp.c
ospf6d/ospf6_top.c
ospf6d/ospf6_top.h

index d9bf06dddc321857130d45c71ee4da19b3e1bebd..31f4db0ccccb3cc485fe2b4321a4622a68a95e02 100644 (file)
@@ -66,6 +66,18 @@ within the hold-time of the previous SPF calculation.
 
 @end deffn
 
+@deffn {OSPF6 Command} {auto-cost reference-bandwidth @var{cost}} {}
+@deffnx {OSPF6 Command} {no auto-cost reference-bandwidth} {}
+This sets the reference bandwidth for cost calculations, where this
+bandwidth is considered equivalent to an OSPF cost of 1, specified in
+Mbits/s. The default is 100Mbit/s (i.e. a link of bandwidth 100Mbit/s
+or higher will have a cost of 1. Cost of lower bandwidth links will be
+scaled with reference to this cost).
+
+This configuration setting MUST be consistent across all routers
+within the OSPF domain.
+@end deffn
+
 @node OSPF6 area
 @section OSPF6 area
 
@@ -75,7 +87,8 @@ Area support for OSPFv3 is not yet implemented.
 @section OSPF6 interface
 
 @deffn {Interface Command} {ipv6 ospf6 cost COST} {}
-Sets interface's output cost.  Default value depends on the interface bandwidth.
+Sets interface's output cost.  Default value depends on the interface
+bandwidth and on the auto-cost reference bandwidth.
 @end deffn
 
 @deffn {Interface Command} {ipv6 ospf6 hello-interval HELLOINTERVAL} {}
index 6db347f9bfb41b41c61c7ad8ff632aa2d1ee563c..f5a004646a8e60392be99e45fea3b5d0e7050dd2 100644 (file)
@@ -85,6 +85,15 @@ OSPF6 NODE:
     Binds interface to specified Area, and start
     sending OSPFv3 packets.
 
+  auto-cost reference-bandwidth COST
+    Sets the reference bandwidth for cost calculations, where this
+    bandwidth is considered equivalent to an OSPF cost of 1, specified
+    in Mbits/s. The default is 100Mbit/s (i.e. a link of bandwidth
+    100Mbit/s or higher will have a cost of 1. Cost of lower bandwidth
+    links will be scaled with reference to this cost).  This
+    configuration setting MUST be consistent across all routers within
+    the OSPF domain.
+
 Sample configuration is in ospf6d.conf.sample.
 
 --
index e698893076d8efd97b37f7bba19c790e08976e8b..4bc61551853ec787fa37db6d8021a257f41a451e 100644 (file)
@@ -125,7 +125,7 @@ ospf6_interface_get_cost (struct ospf6_interface *oi)
   u_int32_t bw, refbw;
 
   bw = oi->interface->bandwidth ? oi->interface->bandwidth : OSPF6_INTERFACE_BANDWIDTH;
-  refbw = OSPF6_REFERENCE_BANDWIDTH;
+  refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH;
 
   /* A specifed ip ospf cost overrides a calculated one. */
   if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
@@ -1300,6 +1300,61 @@ DEFUN (no_ipv6_ospf6_cost,
   return CMD_SUCCESS;
 }
 
+DEFUN (auto_cost_reference_bandwidth,
+       auto_cost_reference_bandwidth_cmd,
+       "auto-cost reference-bandwidth <1-4294967>",
+       "Calculate OSPF interface cost according to bandwidth\n"
+       "Use reference bandwidth method to assign OSPF cost\n"
+       "The reference bandwidth in terms of Mbits per second\n")
+{
+  struct ospf6 *o = vty->index;
+  struct ospf6_area *oa;
+  struct ospf6_interface *oi;
+  struct listnode *i, *j;
+  u_int32_t refbw;
+
+  refbw = strtol (argv[0], NULL, 10);
+  if (refbw < 1 || refbw > 4294967)
+    {
+      vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  /* If reference bandwidth is changed. */
+  if ((refbw * 1000) == o->ref_bandwidth)
+    return CMD_SUCCESS;
+
+  o->ref_bandwidth = refbw * 1000;
+  for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
+      for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
+          ospf6_interface_recalculate_cost (oi);
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_auto_cost_reference_bandwidth,
+       no_auto_cost_reference_bandwidth_cmd,
+       "no auto-cost reference-bandwidth",
+       NO_STR
+       "Calculate OSPF interface cost according to bandwidth\n"
+       "Use reference bandwidth method to assign OSPF cost\n")
+{
+  struct ospf6 *o = vty->index;
+  struct ospf6_area *oa;
+  struct ospf6_interface *oi;
+  struct listnode *i, *j;
+
+  if (o->ref_bandwidth == OSPF6_REFERENCE_BANDWIDTH)
+    return CMD_SUCCESS;
+
+  o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
+  for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
+      for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
+          ospf6_interface_recalculate_cost (oi);
+
+  return CMD_SUCCESS;
+}
+
 DEFUN (ipv6_ospf6_hellointerval,
        ipv6_ospf6_hellointerval_cmd,
        "ipv6 ospf6 hello-interval <1-65535>",
@@ -1854,6 +1909,10 @@ ospf6_interface_init (void)
 
   install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
   install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
+
+  /* reference bandwidth commands */
+  install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
+  install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
 }
 
 DEFUN (debug_ospf6_interface,
index 466039277c3141f97e7bf5dfdf3cf7d1eea75dd5..4be8be04b1a88942f499345a24bf6787f2b5b6ae 100644 (file)
@@ -488,7 +488,9 @@ ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length,
     case OSPFv3DEMANDEXTENSIONS:
       return SNMP_INTEGER (0); /* Not supported */
     case OSPFv3REFERENCEBANDWIDTH:
-      return SNMP_INTEGER (100000);
+      if (ospf6)
+        return SNMP_INTEGER (ospf6->ref_bandwidth);
+      /* Otherwise, like for "not implemented". */
     case OSPFv3RESTARTSUPPORT:
     case OSPFv3RESTARTINTERVAL:
     case OSPFv3RESTARTSTRICTLSACHECKING:
index 7c0922a6ff788b35cd62fe07dcc1bfe195116c06..7191270143e05c4043d26a846b70848547e569be 100644 (file)
@@ -148,6 +148,8 @@ ospf6_create (void)
 
   o->external_id_table = route_table_init ();
 
+  o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
+
   return o;
 }
 
@@ -890,6 +892,10 @@ config_write_ospf6 (struct vty *vty)
       vty_out(vty, "%s", VTY_NEWLINE);
     }
 
+  if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH)
+    vty_out (vty, " auto-cost reference-bandwidth %d%s", ospf6->ref_bandwidth / 1000,
+             VNL);
+
   ospf6_stub_router_config_write (vty);
   ospf6_redistribute_config_write (vty);
   ospf6_area_config_write (vty);
index 866f92f9883877b2b1b840b8162fea92da95421d..d6f4bf0f3d07a680b07c3ac6f756923b06193ddd 100644 (file)
@@ -80,6 +80,8 @@ struct ospf6
   struct thread *t_spf_calc;           /* SPF calculation timer. */
   struct thread *t_ase_calc;           /* ASE calculation timer. */
   struct thread *maxage_remover;
+
+  u_int32_t ref_bandwidth;
 };
 
 #define OSPF6_DISABLED    0x01