+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* This is an implementation of Segment Routing
* as per RFC 8665 - OSPF Extensions for Segment Routing
* Author: Anselme Sawadogo <anselmesawadogo@gmail.com>
*
* Copyright (C) 2016 - 2020 Orange Labs http://www.orange.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
osr_debug("SR (%s): Initialize SR Data Base", __func__);
- memset(&OspfSR, 0, sizeof(struct ospf_sr_db));
+ memset(&OspfSR, 0, sizeof(OspfSR));
OspfSR.status = SR_OFF;
/* Only AREA flooding is supported in this release */
OspfSR.scope = OSPF_OPAQUE_AREA_LSA;
for (ALL_LIST_ELEMENTS_RO(top->oiflist, node, oi))
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
nbr = rn->info;
- if (nbr)
- if (IPV4_ADDR_SAME(&nbr->address.u.prefix4,
- &addr)
- || IPV4_ADDR_SAME(&nbr->router_id, &addr)) {
- route_unlock_node(rn);
- return nbr;
- }
+ if (!nbr)
+ continue;
+
+ if (IPV4_ADDR_SAME(&nbr->address.u.prefix4, &addr) ||
+ IPV4_ADDR_SAME(&nbr->router_id, &addr)) {
+ route_unlock_node(rn);
+ return nbr;
+ }
}
return NULL;
}
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)",
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);