summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2022-11-03 14:30:23 +0100
committerLouis Scalbert <louis.scalbert@6wind.com>2023-02-09 15:48:21 +0100
commit05a12619dd6eca2feabebb987239c5a133754fef (patch)
tree826c0a9155d94f36b21c8f71919da18d4a3d22ad
parentMerge pull request #12730 from louis-6wind/fix-ext-te-metrics (diff)
downloadfrr-05a12619dd6eca2feabebb987239c5a133754fef.tar.xz
frr-05a12619dd6eca2feabebb987239c5a133754fef.zip
lib,yang,zebra: add affinity-map support
Add the affinity-map global command to zebra. The syntax is: > affinity-map NAME bit-position (0-1023) Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
-rw-r--r--lib/affinitymap.c122
-rw-r--r--lib/affinitymap.h74
-rw-r--r--lib/affinitymap_cli.c107
-rw-r--r--lib/affinitymap_northbound.c123
-rw-r--r--lib/command.h3
-rw-r--r--lib/subdir.am6
-rw-r--r--lib/yang.c1
-rw-r--r--vtysh/vtysh.c26
-rw-r--r--vtysh/vtysh.h1
-rw-r--r--vtysh/vtysh_config.c20
-rw-r--r--yang/frr-affinity-map.yang81
-rw-r--r--yang/frr-zebra.yang4
-rw-r--r--yang/subdir.am1
-rw-r--r--zebra/main.c4
-rw-r--r--zebra/zebra_vty.c3
15 files changed, 568 insertions, 8 deletions
diff --git a/lib/affinitymap.c b/lib/affinitymap.c
new file mode 100644
index 000000000..62c9c0df8
--- /dev/null
+++ b/lib/affinitymap.c
@@ -0,0 +1,122 @@
+/*
+ * Affinity map function.
+ *
+ * Copyright 2022 Hiroki Shirokura, LINE Corporation
+ * Copyright 2022 Masakazu Asama
+ * Copyright 2022 6WIND S.A.
+ *
+ * This file is part of Free Range Routing (FRR).
+ *
+ * FRR 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, or (at your option) any
+ * later version.
+ *
+ * FRR 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
+ */
+
+#include <zebra.h>
+
+#include "linklist.h"
+#include "memory.h"
+#include "command.h"
+#include "vector.h"
+#include "prefix.h"
+#include "vty.h"
+#include "affinitymap.h"
+#include "command.h"
+#include "log.h"
+#include "hash.h"
+#include "libfrr.h"
+#include "lib_errors.h"
+#include "table.h"
+#include "json.h"
+#include "jhash.h"
+
+DEFINE_MTYPE_STATIC(LIB, AFFINITY_MAP, "Affinity map");
+DEFINE_MTYPE(LIB, AFFINITY_MAP_NAME, "Affinity map name");
+DEFINE_MTYPE_STATIC(LIB, AFFINITY_MAP_INDEX, "Affinity map index");
+
+DEFINE_QOBJ_TYPE(affinity_maps);
+DEFINE_QOBJ_TYPE(affinity_map);
+
+struct affinity_maps affinity_map_master = {NULL};
+
+static void affinity_map_free(struct affinity_map *map)
+{
+ XFREE(MTYPE_AFFINITY_MAP, map);
+}
+
+void affinity_map_set(const char *name, int pos)
+{
+ struct listnode *node;
+ struct affinity_map *map;
+
+ if (!affinity_map_master.maps)
+ affinity_map_master.maps = list_new();
+
+ for (ALL_LIST_ELEMENTS_RO(affinity_map_master.maps, node, map)) {
+ if (strncmp(name, map->name, AFFINITY_NAME_SIZE) != 0)
+ continue;
+ map->bit_position = pos;
+ return;
+ }
+
+ map = XCALLOC(MTYPE_AFFINITY_MAP, sizeof(*map));
+ map->bit_position = pos;
+ snprintf(map->name, sizeof(map->name), "%s", name);
+ listnode_add(affinity_map_master.maps, map);
+}
+
+void affinity_map_unset(const char *name)
+{
+ struct listnode *node, *nnode;
+ struct affinity_map *map;
+
+ if (!affinity_map_master.maps)
+ return;
+
+ for (ALL_LIST_ELEMENTS(affinity_map_master.maps, node, nnode, map)) {
+ if (strncmp(name, map->name, AFFINITY_NAME_SIZE) != 0)
+ continue;
+ listnode_delete(affinity_map_master.maps, map);
+ affinity_map_free(map);
+ return;
+ }
+}
+
+struct affinity_map *affinity_map_get(const char *name)
+{
+ struct listnode *node;
+ struct affinity_map *map;
+
+ if (!affinity_map_master.maps)
+ return NULL;
+
+ for (ALL_LIST_ELEMENTS_RO(affinity_map_master.maps, node, map))
+ if (strncmp(name, map->name, AFFINITY_NAME_SIZE) == 0)
+ return map;
+ return NULL;
+}
+
+
+char *affinity_map_name_get(int pos)
+{
+ struct listnode *node;
+ struct affinity_map *map;
+
+ if (!affinity_map_master.maps)
+ return NULL;
+
+ for (ALL_LIST_ELEMENTS_RO(affinity_map_master.maps, node, map))
+ if (map->bit_position == pos)
+ return map->name;
+ return NULL;
+}
diff --git a/lib/affinitymap.h b/lib/affinitymap.h
new file mode 100644
index 000000000..323439c74
--- /dev/null
+++ b/lib/affinitymap.h
@@ -0,0 +1,74 @@
+/*
+ * Affinity-map function.
+ *
+ * Copyright 2022 Hiroki Shirokura, LINE Corporation
+ * Copyright 2022 Masakazu Asama
+ * Copyright 2022 6WIND S.A.
+ *
+ * This file is part of Free Range Routing (FRR).
+ *
+ * FRR 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, or (at your option) any
+ * later version.
+ *
+ * FRR 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
+ */
+
+#ifndef _ZEBRA_AFFINITYMAP_H
+#define _ZEBRA_AFFINITYMAP_H
+
+#include "typesafe.h"
+#include "prefix.h"
+#include "memory.h"
+#include "qobj.h"
+#include "vty.h"
+#include "lib/plist.h"
+#include "lib/plist_int.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define AFFINITY_NAME_SIZE 32
+
+struct affinity_map {
+ char name[AFFINITY_NAME_SIZE];
+ uint16_t bit_position;
+
+ QOBJ_FIELDS;
+};
+DECLARE_QOBJ_TYPE(affinity_map);
+
+struct affinity_maps {
+ struct list *maps;
+
+ QOBJ_FIELDS;
+};
+DECLARE_QOBJ_TYPE(affinity_maps);
+
+extern const struct frr_yang_module_info frr_affinity_map_info;
+
+void affinity_map_set(const char *name, int pos);
+void affinity_map_unset(const char *name);
+struct affinity_map *affinity_map_get(const char *name);
+char *affinity_map_name_get(const int pos);
+
+void cli_show_affinity_map(struct vty *vty, const struct lyd_node *dnode,
+ bool show_defaults);
+
+void affinity_map_init(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ZEBRA_AFFINITYMAP_H */
diff --git a/lib/affinitymap_cli.c b/lib/affinitymap_cli.c
new file mode 100644
index 000000000..a2d5e8ecc
--- /dev/null
+++ b/lib/affinitymap_cli.c
@@ -0,0 +1,107 @@
+/*
+ * Affinity map northbound CLI implementation.
+ *
+ * Copyright 2022 Hiroki Shirokura, LINE Corporation
+ * Copyright 2022 Masakazu Asama
+ * Copyright 2022 6WIND S.A.
+ *
+ *
+ * This file is part of Free Range Routing (FRR).
+ *
+ * FRR 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, or (at your option) any
+ * later version.
+ *
+ * FRR 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
+ */
+
+#include <zebra.h>
+
+#include "lib/command.h"
+#include "lib/northbound_cli.h"
+#include "lib/affinitymap.h"
+#include "lib/affinitymap_cli_clippy.c"
+
+/* Route map node structure. */
+static int affinity_map_config_write(struct vty *vty);
+static struct cmd_node affinitymap_node = {
+ .name = "affinity-map",
+ .node = AFFMAP_NODE,
+ .prompt = "",
+ .config_write = affinity_map_config_write,
+};
+
+/* max value is EXT_ADMIN_GROUP_MAX_POSITIONS - 1 */
+DEFPY_YANG_NOSH(affinity_map, affinity_map_cmd,
+ "affinity-map NAME$name bit-position (0-1023)$position",
+ "Affinity map configuration\n"
+ "Affinity attribute name\n"
+ "Bit position for affinity attribute value\n"
+ "Bit position\n")
+{
+ char xpathr[XPATH_MAXLEN];
+
+ snprintf(
+ xpathr, sizeof(xpathr),
+ "/frr-affinity-map:lib/affinity-maps/affinity-map[name='%s']/value",
+ name);
+ nb_cli_enqueue_change(vty, xpathr, NB_OP_MODIFY, position_str);
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+/* max value is EXT_ADMIN_GROUP_MAX_POSITIONS - 1 */
+DEFPY_YANG_NOSH(no_affinity_map, no_affinity_map_cmd,
+ "no affinity-map NAME$name [bit-position (0-1023)$position]",
+ NO_STR
+ "Affinity map configuration\n"
+ "Affinity attribute name\n"
+ "Bit position for affinity attribute value\n"
+ "Bit position\n")
+{
+ char xpathr[XPATH_MAXLEN];
+
+ snprintf(xpathr, sizeof(xpathr),
+ "/frr-affinity-map:lib/affinity-maps/affinity-map[name='%s']",
+ name);
+ nb_cli_enqueue_change(vty, xpathr, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+static int affinity_map_config_write(struct vty *vty)
+{
+ const struct lyd_node *dnode;
+ int written = 0;
+
+ dnode = yang_dnode_get(running_config->dnode, "/frr-affinity-map:lib");
+ if (dnode) {
+ nb_cli_show_dnode_cmds(vty, dnode, false);
+ written = 1;
+ }
+
+ return written;
+}
+
+void cli_show_affinity_map(struct vty *vty, const struct lyd_node *dnode,
+ bool show_defaults __attribute__((__unused__)))
+{
+ vty_out(vty, "affinity-map %s bit-position %u\n",
+ yang_dnode_get_string(dnode, "./name"),
+ yang_dnode_get_uint16(dnode, "./value"));
+}
+
+/* Initialization of affinity map vector. */
+void affinity_map_init(void)
+{
+ /* CLI commands. */
+ install_node(&affinitymap_node);
+ install_element(CONFIG_NODE, &affinity_map_cmd);
+ install_element(CONFIG_NODE, &no_affinity_map_cmd);
+}
diff --git a/lib/affinitymap_northbound.c b/lib/affinitymap_northbound.c
new file mode 100644
index 000000000..5082a8b82
--- /dev/null
+++ b/lib/affinitymap_northbound.c
@@ -0,0 +1,123 @@
+/*
+ * affinity map northbound implementation.
+ *
+ * Copyright 2022 Hiroki Shirokura, LINE Corporation
+ * Copyright 2022 Masakazu Asama
+ * Copyright 2022 6WIND S.A.
+ *
+ * This file is part of Free Range Routing (FRR).
+ *
+ * FRR 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, or (at your option) any
+ * later version.
+ *
+ * FRR 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
+ */
+
+#include <zebra.h>
+
+#include "lib/command.h"
+#include "lib/log.h"
+#include "lib/northbound.h"
+#include "lib/affinitymap.h"
+
+/*
+ * XPath: /frr-affinity-map:lib/affinity-maps/affinity-map
+ */
+
+static int lib_affinity_map_create(struct nb_cb_create_args *args)
+{
+ return NB_OK;
+}
+
+static int lib_affinity_map_destroy(struct nb_cb_destroy_args *args)
+{
+ const char *name;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ name = yang_dnode_get_string(
+ (const struct lyd_node *)args->dnode, "./name");
+ affinity_map_unset(name);
+ break;
+ }
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-affinity-map:lib/affinity-maps/affinity-map/value
+ */
+static int lib_affinity_map_value_modify(struct nb_cb_modify_args *args)
+{
+ const char *name;
+ char *map_name;
+ uint16_t pos;
+
+ name = yang_dnode_get_string(
+ (const struct lyd_node *)args->dnode->parent, "./name");
+
+ pos = yang_dnode_get_uint16(
+ (const struct lyd_node *)args->dnode->parent, "./value");
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ map_name = affinity_map_name_get(pos);
+ if (!map_name)
+ return NB_OK;
+ if (strncmp(map_name, name, AFFINITY_NAME_SIZE) == 0)
+ return NB_ERR_NO_CHANGES;
+ snprintf(args->errmsg, args->errmsg_len,
+ "bit-position is used by %s.", map_name);
+ return NB_ERR_VALIDATION;
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ affinity_map_set(name, pos);
+ break;
+ }
+
+ return NB_OK;
+}
+
+static int lib_affinity_map_value_destroy(struct nb_cb_destroy_args *args)
+{
+ return NB_OK;
+}
+
+/* clang-format off */
+const struct frr_yang_module_info frr_affinity_map_info = {
+ .name = "frr-affinity-map",
+ .nodes = {
+ {
+ .xpath = "/frr-affinity-map:lib/affinity-maps/affinity-map",
+ .cbs = {
+ .create = lib_affinity_map_create,
+ .destroy = lib_affinity_map_destroy,
+ .cli_show = cli_show_affinity_map,
+ }
+ },
+ {
+ .xpath = "/frr-affinity-map:lib/affinity-maps/affinity-map/value",
+ .cbs = {
+ .modify = lib_affinity_map_value_modify,
+ .destroy = lib_affinity_map_value_destroy,
+ }
+ },
+ {
+ .xpath = NULL,
+ },
+ }
+};
diff --git a/lib/command.h b/lib/command.h
index 8f5d96053..5aaa6d6cd 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -90,6 +90,7 @@ struct host {
};
/* List of CLI nodes. Please remember to update the name array in command.c. */
+/* clang-format off */
enum node_type {
AUTH_NODE, /* Authentication mode of vty interface. */
VIEW_NODE, /* View node. Default mode of vty interface. */
@@ -106,6 +107,7 @@ enum node_type {
EXTLOG_NODE, /* RFC5424 & co. extended syslog */
KEYCHAIN_NODE, /* Key-chain node. */
KEYCHAIN_KEY_NODE, /* Key-chain key node. */
+ AFFMAP_NODE, /* Affinity map node. */
IP_NODE, /* Static ip route node. */
VRF_NODE, /* VRF mode node. */
INTERFACE_NODE, /* Interface mode node. */
@@ -186,6 +188,7 @@ enum node_type {
BMP_NODE, /* BMP config under router bgp */
NODE_TYPE_MAX, /* maximum */
};
+/* clang-format on */
extern vector cmdvec;
extern const struct message tokennames[];
diff --git a/lib/subdir.am b/lib/subdir.am
index 18e9825a7..faf77abad 100644
--- a/lib/subdir.am
+++ b/lib/subdir.am
@@ -7,6 +7,9 @@ lib_libfrr_la_LDFLAGS = $(LIB_LDFLAGS) -version-info 0:0:0 -Xlinker -e_libfrr_ve
lib_libfrr_la_LIBADD = $(LIBCAP) $(UNWIND_LIBS) $(LIBYANG_LIBS) $(LUA_LIB) $(UST_LIBS) $(LIBCRYPT) $(LIBDL) $(LIBM)
lib_libfrr_la_SOURCES = \
+ lib/affinitymap.c \
+ lib/affinitymap_cli.c \
+ lib/affinitymap_northbound.c \
lib/agg_table.c \
lib/atomlist.c \
lib/base64.c \
@@ -127,6 +130,7 @@ lib_libfrr_la_SOURCES = \
# end
nodist_lib_libfrr_la_SOURCES = \
+ yang/frr-affinity-map.yang.c \
yang/frr-filter.yang.c \
yang/frr-interface.yang.c \
yang/frr-route-map.yang.c \
@@ -146,6 +150,7 @@ lib_libfrr_la_SOURCES += lib/db.c
endif
clippy_scan += \
+ lib/affinitymap_cli.c \
lib/if.c \
lib/filter_cli.c \
lib/log_vty.c \
@@ -159,6 +164,7 @@ clippy_scan += \
# end
pkginclude_HEADERS += \
+ lib/affinitymap.h \
lib/agg_table.h \
lib/atomlist.h \
lib/base64.h \
diff --git a/lib/yang.c b/lib/yang.c
index ef1cf898a..ec8de85e9 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -88,6 +88,7 @@ static const char *const frr_native_modules[] = {
"frr-interface",
"frr-vrf",
"frr-routing",
+ "frr-affinity-map",
"frr-route-map",
"frr-nexthop",
"frr-ripd",
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index acc984ced..2538d2073 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -2216,6 +2216,29 @@ DEFUNSH(VTYSH_PATHD, pcep_cli_pcep_pce_config, pcep_cli_pcep_pce_config_cmd,
#endif /* HAVE_PATHD */
+/* max value is EXT_ADMIN_GROUP_MAX_POSITIONS - 1 */
+DEFUNSH(VTYSH_AFFMAP, affinity_map, vtysh_affinity_map_cmd,
+ "affinity-map NAME bit-position (0-1023)",
+ "Affinity map configuration\n"
+ "Affinity attribute name\n"
+ "Bit position for affinity attribute value\n"
+ "Bit position\n")
+{
+ return CMD_SUCCESS;
+}
+
+/* max value is EXT_ADMIN_GROUP_MAX_POSITIONS - 1 */
+DEFUNSH(VTYSH_AFFMAP, no_affinity_map, vtysh_no_affinity_map_cmd,
+ "no affinity-map NAME$name [bit-position (0-1023)$position]",
+ NO_STR
+ "Affinity map configuration\n"
+ "Affinity attribute name\n"
+ "Bit position for affinity attribute value\n"
+ "Bit position\n")
+{
+ return CMD_SUCCESS;
+}
+
DEFUNSH(VTYSH_RMAP, vtysh_route_map, vtysh_route_map_cmd,
"route-map RMAP_NAME <deny|permit> (1-65535)",
"Create route-map or enter route-map command mode\n"
@@ -4850,6 +4873,9 @@ void vtysh_init_vty(void)
install_element(VRF_NODE, &vtysh_exit_vrf_cmd);
install_element(VRF_NODE, &vtysh_quit_vrf_cmd);
+ install_element(CONFIG_NODE, &vtysh_affinity_map_cmd);
+ install_element(CONFIG_NODE, &vtysh_no_affinity_map_cmd);
+
install_node(&rmap_node);
install_element(CONFIG_NODE, &vtysh_route_map_cmd);
install_element(RMAP_NODE, &vtysh_exit_rmap_cmd);
diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h
index 1de4ab017..e551f4e9f 100644
--- a/vtysh/vtysh.h
+++ b/vtysh/vtysh.h
@@ -59,6 +59,7 @@ extern struct thread_master *master;
* things like prefix lists are not even initialised) */
#define VTYSH_ALL VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_PIM6D|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_SHARPD|VTYSH_PBRD|VTYSH_STATICD|VTYSH_BFDD|VTYSH_FABRICD|VTYSH_VRRPD|VTYSH_PATHD
#define VTYSH_ACL VTYSH_BFDD|VTYSH_BABELD|VTYSH_BGPD|VTYSH_EIGRPD|VTYSH_ISISD|VTYSH_FABRICD|VTYSH_LDPD|VTYSH_NHRPD|VTYSH_OSPF6D|VTYSH_OSPFD|VTYSH_PBRD|VTYSH_PIMD|VTYSH_PIM6D|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_VRRPD|VTYSH_ZEBRA
+#define VTYSH_AFFMAP VTYSH_ZEBRA
#define VTYSH_RMAP VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_FABRICD
#define VTYSH_INTERFACE_SUBSET \
VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | \
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index ac32f0a77..6dce99a57 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -395,6 +395,9 @@ void vtysh_config_parse_line(void *arg, const char *line)
else if (strncmp(line, "router openfabric", strlen("router openfabric"))
== 0)
config = config_get(OPENFABRIC_NODE, line);
+ else if (strncmp(line, "affinity-map",
+ strlen("affinity-map")) == 0)
+ config = config_get(AFFMAP_NODE, line);
else if (strncmp(line, "route-map", strlen("route-map")) == 0)
config = config_get(RMAP_NODE, line);
else if (strncmp(line, "no route-map", strlen("no route-map"))
@@ -526,14 +529,15 @@ void vtysh_config_parse_line(void *arg, const char *line)
/* Macro to check delimiter is needed between each configuration line
* or not. */
#define NO_DELIMITER(I) \
- ((I) == ACCESS_NODE || (I) == PREFIX_NODE || (I) == IP_NODE \
- || (I) == AS_LIST_NODE || (I) == COMMUNITY_LIST_NODE \
- || (I) == COMMUNITY_ALIAS_NODE || (I) == ACCESS_IPV6_NODE \
- || (I) == ACCESS_MAC_NODE || (I) == PREFIX_IPV6_NODE \
- || (I) == FORWARDING_NODE || (I) == DEBUG_NODE || (I) == AAA_NODE \
- || (I) == VRF_DEBUG_NODE || (I) == NORTHBOUND_DEBUG_NODE \
- || (I) == RMAP_DEBUG_NODE || (I) == RESOLVER_DEBUG_NODE \
- || (I) == MPLS_NODE || (I) == KEYCHAIN_KEY_NODE)
+ ((I) == AFFMAP_NODE || (I) == ACCESS_NODE || (I) == PREFIX_NODE || \
+ (I) == IP_NODE || (I) == AS_LIST_NODE || \
+ (I) == COMMUNITY_LIST_NODE || (I) == COMMUNITY_ALIAS_NODE || \
+ (I) == ACCESS_IPV6_NODE || (I) == ACCESS_MAC_NODE || \
+ (I) == PREFIX_IPV6_NODE || (I) == FORWARDING_NODE || \
+ (I) == DEBUG_NODE || (I) == AAA_NODE || (I) == VRF_DEBUG_NODE || \
+ (I) == NORTHBOUND_DEBUG_NODE || (I) == RMAP_DEBUG_NODE || \
+ (I) == RESOLVER_DEBUG_NODE || (I) == MPLS_NODE || \
+ (I) == KEYCHAIN_KEY_NODE)
static void configvec_dump(vector vec, bool nested)
{
diff --git a/yang/frr-affinity-map.yang b/yang/frr-affinity-map.yang
new file mode 100644
index 000000000..c4377e624
--- /dev/null
+++ b/yang/frr-affinity-map.yang
@@ -0,0 +1,81 @@
+module frr-affinity-map {
+ yang-version 1.1;
+ namespace "http://frrouting.org/yang/affinity-map";
+ prefix frr-affinity-map;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ import frr-filter {
+ prefix filter;
+ }
+
+ import frr-interface {
+ prefix frr-interface;
+ }
+
+ organization
+ "FRRouting";
+ contact
+ "FRR Users List: <mailto:frog@lists.frrouting.org>
+ FRR Development List: <mailto:dev@lists.frrouting.org>";
+ description
+ "This module defines route map settings
+
+ Copyright 2022 FRRouting
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.";
+
+ revision 2022-11-03 {
+ description
+ "Initial revision";
+ }
+
+ container lib {
+ container affinity-maps {
+ description
+ "Affinity Mapping Table";
+ list affinity-map {
+ key "name";
+ description
+ "Affinity Mapping configuration";
+ leaf name {
+ type string {
+ length "1..32";
+ }
+ description
+ "Affinity Name";
+ }
+ leaf value {
+ type uint16 {
+ range "0..1023";
+ }
+ description
+ "Bit position";
+ }
+ }
+ }
+ }
+}
diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang
index a2c6bb4c2..3bf5203fb 100644
--- a/yang/frr-zebra.yang
+++ b/yang/frr-zebra.yang
@@ -11,6 +11,10 @@ module frr-zebra {
prefix inet;
}
+ import frr-affinity-map {
+ prefix frr-affinity-map;
+ }
+
import frr-route-map {
prefix frr-route-map;
}
diff --git a/yang/subdir.am b/yang/subdir.am
index 80028fcb1..82a6a0147 100644
--- a/yang/subdir.am
+++ b/yang/subdir.am
@@ -19,6 +19,7 @@ EXTRA_DIST += yang/embedmodel.py
# global symbols :(. Just put it in the daemon. Dynamic libraries.so work
# without problems, as seen in libfrr.
+dist_yangmodels_DATA += yang/frr-affinity-map.yang
dist_yangmodels_DATA += yang/frr-filter.yang
dist_yangmodels_DATA += yang/frr-module-translator.yang
dist_yangmodels_DATA += yang/frr-nexthop.yang
diff --git a/zebra/main.c b/zebra/main.c
index e38f9a85e..e38f20371 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -33,6 +33,7 @@
#include "sigevent.h"
#include "vrf.h"
#include "libfrr.h"
+#include "affinitymap.h"
#include "routemap.h"
#include "routing_nb.h"
@@ -259,6 +260,7 @@ struct frr_signal_t zebra_signals[] = {
},
};
+/* clang-format off */
static const struct frr_yang_module_info *const zebra_yang_modules[] = {
&frr_filter_info,
&frr_interface_info,
@@ -266,8 +268,10 @@ static const struct frr_yang_module_info *const zebra_yang_modules[] = {
&frr_zebra_info,
&frr_vrf_info,
&frr_routing_info,
+ &frr_affinity_map_info,
&frr_zebra_route_map_info,
};
+/* clang-format on */
FRR_DAEMON_INFO(
zebra, ZEBRA, .vty_port = ZEBRA_VTY_PORT, .flags = FRR_NO_ZCLIENT,
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index d96ee4890..15ae47dfe 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -34,6 +34,7 @@
#include "srcdest_table.h"
#include "vxlan.h"
#include "termtable.h"
+#include "affinitymap.h"
#include "zebra/zebra_router.h"
#include "zebra/zserv.h"
@@ -4496,6 +4497,8 @@ void zebra_vty_init(void)
/* Route-map */
zebra_route_map_init();
+ affinity_map_init();
+
install_node(&ip_node);
install_node(&protocol_node);