]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: make affinity-map value unique in the yang model
authorIgor Ryzhov <iryzhov@nfware.com>
Thu, 18 Jan 2024 21:39:32 +0000 (23:39 +0200)
committerIgor Ryzhov <iryzhov@nfware.com>
Fri, 19 Jan 2024 01:47:02 +0000 (03:47 +0200)
It allows us to remove the code that does the same thing manually.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
lib/affinitymap.c
lib/affinitymap.h
lib/affinitymap_northbound.c
yang/frr-affinity-map.yang

index b748e74884869b7713332caa82e204fbcae0c3d3..00f23c1ca3683c9051f423fa6fccbd37298ce76b 100644 (file)
@@ -106,21 +106,6 @@ struct affinity_map *affinity_map_get(const char *name)
        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;
-}
-
 bool affinity_map_check_update_hook(const char *affmap_name, uint16_t new_pos)
 {
        if (affinity_map_master.check_update_hook)
index 5ce233404fc0cf16fb874642545d3980c2df512d..8e0a798040edff5110099466d8de325d957e36f4 100644 (file)
@@ -63,7 +63,6 @@ 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);
 
 bool affinity_map_check_update_hook(const char *affmap_name, uint16_t new_pos);
 void affinity_map_update_hook(const char *affmap_name, uint16_t new_pos);
index bee2ebe8616a524902987347ebf5abcb7baa1721..1a1ff5f465f3c9814eec29ce7d1e14beb341b101 100644 (file)
@@ -63,7 +63,6 @@ static int lib_affinity_map_destroy(struct nb_cb_destroy_args *args)
 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(
@@ -74,13 +73,6 @@ static int lib_affinity_map_value_modify(struct nb_cb_modify_args *args)
 
        switch (args->event) {
        case NB_EV_VALIDATE:
-               map_name = affinity_map_name_get(pos);
-               if (map_name &&
-                   strncmp(map_name, name, AFFINITY_NAME_SIZE) != 0) {
-                       snprintf(args->errmsg, args->errmsg_len,
-                                "bit-position is used by %s.", map_name);
-                       return NB_ERR_VALIDATION;
-               }
                if (!affinity_map_check_update_hook(name, pos)) {
                        snprintf(
                                args->errmsg, args->errmsg_len,
index 992f5c75354d2add3b03f1732af98f6548b302c9..91b70ff22a8e39ad0886b840899fda7f9f12c83d 100644 (file)
@@ -68,6 +68,7 @@ module frr-affinity-map {
         "Affinity Mapping Table";
       list affinity-map {
         key "name";
+        unique "value";
         description
           "Affinity Mapping configuration";
         leaf name {