summaryrefslogtreecommitdiffstats
path: root/isisd
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2022-11-10 16:36:08 +0100
committerLouis Scalbert <louis.scalbert@6wind.com>2023-04-18 11:33:15 +0200
commit9a65cf35da1d5653202a5355d60663a408ebdfa3 (patch)
tree8b1eaea84d4284bd972bd6aa50435ae16a0e0656 /isisd
parentisisd: add support of (ti-)lfa to flex-algo (diff)
downloadfrr-9a65cf35da1d5653202a5355d60663a408ebdfa3.tar.xz
frr-9a65cf35da1d5653202a5355d60663a408ebdfa3.zip
isisd: add affinity-map configuration hooks
Add affinity-map hooks to check the utilization of affinity-map in flex-algo contexts before its deletion and to update local TLVs when the affinity-map bit-position is updated. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'isisd')
-rw-r--r--isisd/isis_affinitymap.c91
-rw-r--r--isisd/isis_affinitymap.h25
-rw-r--r--isisd/isis_main.c5
-rw-r--r--isisd/subdir.am2
4 files changed, 122 insertions, 1 deletions
diff --git a/isisd/isis_affinitymap.c b/isisd/isis_affinitymap.c
new file mode 100644
index 000000000..e681e820b
--- /dev/null
+++ b/isisd/isis_affinitymap.c
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* IS-IS affinity-map
+ * Copyright 2023 6WIND S.A.
+ */
+
+#include <zebra.h>
+#include "lib/if.h"
+#include "lib/vrf.h"
+#include "isisd/isisd.h"
+#include "isisd/isis_affinitymap.h"
+
+#ifndef FABRICD
+
+static bool isis_affinity_map_check_use(const char *affmap_name)
+{
+ struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT);
+ struct isis_area *area;
+ struct listnode *area_node, *fa_node;
+ struct flex_algo *fa;
+ struct affinity_map *map;
+ uint16_t pos;
+
+ map = affinity_map_get(affmap_name);
+ pos = map->bit_position;
+
+ for (ALL_LIST_ELEMENTS_RO(isis->area_list, area_node, area)) {
+ for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, fa_node,
+ fa)) {
+ if (admin_group_get(&fa->admin_group_exclude_any,
+ pos) ||
+ admin_group_get(&fa->admin_group_include_any,
+ pos) ||
+ admin_group_get(&fa->admin_group_include_all, pos))
+ return true;
+ }
+ }
+ return false;
+}
+
+static void isis_affinity_map_update(const char *affmap_name, uint16_t old_pos,
+ uint16_t new_pos)
+{
+ struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT);
+ struct listnode *area_node, *fa_node;
+ struct isis_area *area;
+ struct flex_algo *fa;
+ bool changed;
+
+ for (ALL_LIST_ELEMENTS_RO(isis->area_list, area_node, area)) {
+ changed = false;
+ for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, fa_node,
+ fa)) {
+ if (admin_group_get(&fa->admin_group_exclude_any,
+ old_pos)) {
+ admin_group_unset(&fa->admin_group_exclude_any,
+ old_pos);
+ admin_group_set(&fa->admin_group_exclude_any,
+ new_pos);
+ changed = true;
+ }
+ if (admin_group_get(&fa->admin_group_include_any,
+ old_pos)) {
+ admin_group_unset(&fa->admin_group_include_any,
+ old_pos);
+ admin_group_set(&fa->admin_group_include_any,
+ new_pos);
+ changed = true;
+ }
+ if (admin_group_get(&fa->admin_group_include_all,
+ old_pos)) {
+ admin_group_unset(&fa->admin_group_include_all,
+ old_pos);
+ admin_group_set(&fa->admin_group_include_all,
+ new_pos);
+ changed = true;
+ }
+ }
+ if (changed)
+ lsp_regenerate_schedule(area, area->is_type, 0);
+ }
+}
+
+void isis_affinity_map_init(void)
+{
+ affinity_map_init();
+
+ affinity_map_set_check_use_hook(isis_affinity_map_check_use);
+ affinity_map_set_update_hook(isis_affinity_map_update);
+}
+
+#endif /* ifndef FABRICD */
diff --git a/isisd/isis_affinitymap.h b/isisd/isis_affinitymap.h
new file mode 100644
index 000000000..c432e99f5
--- /dev/null
+++ b/isisd/isis_affinitymap.h
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* IS-IS affinity-map header
+ * Copyright 2023 6WIND S.A.
+ */
+
+#ifndef __ISIS_AFFINITYMAP_H__
+#define __ISIS_AFFINITYMAP_H__
+
+#include "lib/affinitymap.h"
+
+#ifndef FABRICD
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void isis_affinity_map_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ifndef FABRICD */
+
+#endif /* __ISIS_AFFINITYMAP_H__ */
diff --git a/isisd/isis_main.c b/isisd/isis_main.c
index 2f4e4e0bd..8e40882e5 100644
--- a/isisd/isis_main.c
+++ b/isisd/isis_main.c
@@ -29,6 +29,7 @@
#include "routemap.h"
#include "affinitymap.h"
+#include "isisd/isis_affinitymap.h"
#include "isisd/isis_constants.h"
#include "isisd/isis_common.h"
#include "isisd/isis_flags.h"
@@ -290,7 +291,9 @@ int main(int argc, char **argv, char **envp)
lsp_init();
mt_init();
- affinity_map_init();
+#ifndef FABRICD
+ isis_affinity_map_init();
+#endif /* ifndef FABRICD */
isis_zebra_init(master, instance);
isis_bfd_init(master);
diff --git a/isisd/subdir.am b/isisd/subdir.am
index 49e252c85..6bd2477b1 100644
--- a/isisd/subdir.am
+++ b/isisd/subdir.am
@@ -19,6 +19,7 @@ vtysh_daemons += fabricd
endif
noinst_HEADERS += \
+ isisd/isis_affinitymap.h \
isisd/isis_adjacency.h \
isisd/isis_bfd.h \
isisd/isis_circuit.h \
@@ -56,6 +57,7 @@ noinst_HEADERS += \
# end
LIBISIS_SOURCES = \
+ isisd/isis_affinitymap.c \
isisd/isis_adjacency.c \
isisd/isis_bfd.c \
isisd/isis_circuit.c \