]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Revert "ospfd: Remove local-block deprecated command" revert-11334-fix/deprecation_warning
authorOlivier Dugeon <olivier.dugeon@orange.com>
Tue, 7 Jun 2022 15:39:52 +0000 (17:39 +0200)
committerGitHub <noreply@github.com>
Tue, 7 Jun 2022 15:39:52 +0000 (17:39 +0200)
doc/developer/ospf-sr.rst
doc/user/ospfd.rst
ospfd/ospf_sr.c
tests/topotests/ospf_sr_te_topo1/rt1/ospfd.conf
tests/topotests/ospf_sr_te_topo1/rt2/ospfd.conf
tests/topotests/ospf_sr_te_topo1/rt3/ospfd.conf
tests/topotests/ospf_sr_te_topo1/rt4/ospfd.conf
tests/topotests/ospf_sr_te_topo1/rt5/ospfd.conf
tests/topotests/ospf_sr_te_topo1/rt6/ospfd.conf
tests/topotests/ospf_te_topo1/r4/ospfd.conf
tests/topotests/ospf_te_topo1/test_ospf_te_topo1.py

index 1c164433dcb5b2d2c3594d43fa3061c1954e981f..263db9dfb91923b32a8e4cde4a6ad02765440dc3 100644 (file)
@@ -310,7 +310,8 @@ Routing.
     ospf router-id 192.168.1.11
     capability opaque
     segment-routing on
-    segment-routing global-block 10000 19999 local-block 5000 5999
+    segment-routing global-block 10000 19999
+    segment-routing local-block 5000 5999
     segment-routing node-msd 8
     segment-routing prefix 192.168.1.11/32 index 1100
 
index e438d04e932add40058922f0835a20ea39d2caed..068bb8ba31cb7fb5629cf5b64f47fc3d9618e69c 100644 (file)
@@ -991,6 +991,12 @@ dataplane.
    Block, i.e. the label range used for Adjacency SID. The negative version
    of the command always unsets both ranges.
 
+.. clicmd:: segment-routing local-block (16-1048575) (16-1048575)
+
+   Set the Segment Routing Local Block i.e. the label range used by MPLS to
+   store label in the MPLS FIB for Adjacency SID. This command is deprecated
+   in favor of the combined command above.
+
 .. clicmd:: segment-routing node-msd (1-16)
 
    Fix the Maximum Stack Depth supported by the router. The value depend of the
index 2c7c80686cfd6bacf1b21627616f3a7490544648..8fa5ce77bb19ee4f42723b37bb62e016a1220f12 100644 (file)
@@ -2302,6 +2302,84 @@ DEFUN(no_sr_global_label_range, no_sr_global_label_range_cmd,
                return CMD_SUCCESS;
 }
 
+#if CONFDATE > 20220528
+CPP_NOTICE(
+       "Use of the segment-routing local-block command is deprecated, use the combined global-block command instead")
+#endif
+
+DEFUN_HIDDEN(sr_local_label_range, sr_local_label_range_cmd,
+            "segment-routing local-block (16-1048575) (16-1048575)",
+            SR_STR
+            "Segment Routing Local Block label range\n"
+            "Lower-bound range in decimal (16-1048575)\n"
+            "Upper-bound range in decimal (16-1048575)\n")
+{
+       uint32_t upper;
+       uint32_t lower;
+       uint32_t srgb_upper;
+       int idx_low = 2;
+       int idx_up = 3;
+
+       /* Get lower and upper bound */
+       lower = strtoul(argv[idx_low]->arg, NULL, 10);
+       upper = strtoul(argv[idx_up]->arg, NULL, 10);
+
+       /* check correctness of SRLB */
+       if (!sr_range_is_valid(lower, upper, MIN_SRLB_SIZE)) {
+               vty_out(vty, "Invalid SRLB range\n");
+               return CMD_WARNING_CONFIG_FAILED;
+       }
+
+       /* Check if values have changed */
+       if ((OspfSR.srlb.start == lower)
+           && (OspfSR.srlb.end == upper))
+               return CMD_SUCCESS;
+
+       /* Validate SRLB against SRGB */
+       srgb_upper = OspfSR.srgb.start + OspfSR.srgb.size - 1;
+
+       if (ranges_overlap(OspfSR.srgb.start, srgb_upper, lower, upper)) {
+               vty_out(vty,
+                       "New SR Local Block (%u/%u) conflicts with Global Block (%u/%u)\n",
+                       lower, upper, OspfSR.srgb.start, srgb_upper);
+               return CMD_WARNING_CONFIG_FAILED;
+       }
+
+       if (update_sr_blocks(OspfSR.srgb.start, srgb_upper, lower, upper) < 0)
+               return CMD_WARNING_CONFIG_FAILED;
+       else
+               return CMD_SUCCESS;
+}
+
+DEFUN_HIDDEN(no_sr_local_label_range, no_sr_local_label_range_cmd,
+            "no segment-routing local-block [(16-1048575) (16-1048575)]",
+            NO_STR SR_STR
+            "Segment Routing Local Block label range\n"
+            "Lower-bound range in decimal (16-1048575)\n"
+            "Upper-bound range in decimal (16-1048575)\n")
+{
+
+       uint32_t srgb_end;
+
+       /* Validate SRLB against SRGB */
+       srgb_end = OspfSR.srgb.start + OspfSR.srgb.size - 1;
+       if (ranges_overlap(OspfSR.srgb.start, srgb_end, DEFAULT_SRLB_LABEL,
+                          DEFAULT_SRLB_END)) {
+               vty_out(vty,
+                       "New SR Local Block (%u/%u) conflicts with Global Block (%u/%u)\n",
+                       DEFAULT_SRLB_LABEL, DEFAULT_SRLB_END, OspfSR.srgb.start,
+                       srgb_end);
+               return CMD_WARNING_CONFIG_FAILED;
+       }
+
+       if (update_sr_blocks(OspfSR.srgb.start, srgb_end, DEFAULT_SRLB_LABEL,
+                            DEFAULT_SRLB_END)
+           < 0)
+               return CMD_WARNING_CONFIG_FAILED;
+       else
+               return CMD_SUCCESS;
+}
+
 DEFUN (sr_node_msd,
        sr_node_msd_cmd,
        "segment-routing node-msd (1-16)",
@@ -2969,6 +3047,8 @@ void ospf_sr_register_vty(void)
        install_element(OSPF_NODE, &no_ospf_sr_enable_cmd);
        install_element(OSPF_NODE, &sr_global_label_range_cmd);
        install_element(OSPF_NODE, &no_sr_global_label_range_cmd);
+       install_element(OSPF_NODE, &sr_local_label_range_cmd);
+       install_element(OSPF_NODE, &no_sr_local_label_range_cmd);
        install_element(OSPF_NODE, &sr_node_msd_cmd);
        install_element(OSPF_NODE, &no_sr_node_msd_cmd);
        install_element(OSPF_NODE, &sr_prefix_sid_cmd);
index 064a4bf2863b387843bb43cb0f2f531150d2ed9b..a440fa6fdf7c3dc6777fa65f967486b6e9bb69f5 100644 (file)
@@ -30,6 +30,7 @@ router ospf
  passive-interface lo
  segment-routing on
  segment-routing global-block 16000 23999
+ !segment-routing local-block 15000 15999
  segment-routing node-msd 8
  segment-routing prefix 1.1.1.1/32 index 10
 !
index 65b20f0e63f2280c6dca6dd9475cdd29f46ea92f..7bec98cd765f56379810b87bf632ce08441a3c2d 100644 (file)
@@ -41,6 +41,7 @@ router ospf
  passive-interface lo
  segment-routing on
  segment-routing global-block 16000 23999
+ !segment-routing local-block 15000 15999
  segment-routing node-msd 8
  segment-routing prefix 2.2.2.2/32 index 20
 !
index 5be0c49a85771dab06b73d1be15c776e3d313778..40b85c4601f9e471e26439cacdb9692a30359b3d 100644 (file)
@@ -40,6 +40,7 @@ router ospf
  router-info area 0.0.0.0
  segment-routing on
  segment-routing global-block 16000 23999
+ !segment-routing local-block 15000 15999
  segment-routing node-msd 8
  segment-routing prefix 3.3.3.3/32 index 30
 !
index 7cdf032eaa6a2fcbdbe0a29db201f4fe50d3dac2..4d3380d107f4f1b0b68e15f1eff4c88d2507aa78 100644 (file)
@@ -47,6 +47,7 @@ router ospf
  passive-interface lo
  segment-routing on
  segment-routing global-block 16000 23999
+ !segment-routing local-block 15000 15999
  segment-routing node-msd 8
  segment-routing prefix 4.4.4.4/32 index 40
 !
index 8f71cda443da99abd299205c598e6b20fc9753db..b111ce588adcf9a17e040611538ae0ead1fa1642 100644 (file)
@@ -47,6 +47,7 @@ router ospf
  passive-interface lo
  segment-routing on
  segment-routing global-block 16000 23999
+! segment-routing local-block 15000 15999
  segment-routing node-msd 8
  segment-routing prefix 5.5.5.5/32 index 50
 !
index 20c89757a839d1eafd4c7a357ccb09a7ded8ad4b..f0c5a9c0ba80db800ce71739927491313b86d4cf 100644 (file)
@@ -35,6 +35,7 @@ router ospf
  passive-interface lo
  segment-routing on
  segment-routing global-block 16000 23999
+! segment-routing local-block 15000 15999
  segment-routing node-msd 8
  segment-routing prefix 6.6.6.6/32 index 60
 !
index cd508017d3b42015a62dc1070439bcc6066814e7..e454673153e9c14ab31fab2d7aa8c5e2de67d118 100644 (file)
@@ -15,7 +15,8 @@ router ospf
   mpls-te on
   mpls-te router-address 10.0.255.4
   segment-routing on
-  segment-routing global-block 10000 19999 local-block 5000 5999
+  segment-routing local-block 5000 5999
+  segment-routing global-block 10000 19999
   segment-routing node-msd 12
   segment-routing prefix 10.0.255.4/32 index 400 no-php-flag
 !
index 699cdc90546bcc8de6464b0ca78133bc6782a768..7de23dc34e7397714594ab215af001898cd9c4e8 100644 (file)
@@ -224,7 +224,7 @@ def test_step4():
         'vtysh -c "conf t" -c "router ospf" -c "segment-routing node-msd 16"'
     )
     tgen.net["r2"].cmd(
-        'vtysh -c "conf t" -c "router ospf" -c "segment-routing global-block 16000 23999 local-block 5000 6999"'
+        'vtysh -c "conf t" -c "router ospf" -c "segment-routing local-block 5000 6999"'
     )
     tgen.net["r2"].cmd(
         'vtysh -c "conf t" -c "router ospf" -c "segment-routing prefix 10.0.255.2/32 index 20 explicit-null"'