]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra, test: mark mpls label chunks as dynamic or static
authorPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 4 Oct 2023 12:57:27 +0000 (14:57 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 18 Oct 2023 07:41:02 +0000 (09:41 +0200)
The zebra label manager stores the mpls label chunks,
but does not record if the label request was for a
dynamic or a static chunk.

For all label requests accepted, mark the label chunk
if the 'base' parameter is set to MPLS_LABEL_BASE_ANY,
unmark it otherwise.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
tests/zebra/test_lm_plugin.c
zebra/label_manager.c
zebra/label_manager.h

index 9ad0bc4e17c73d596b73d7be2051591671d30e46..9895c025f05fc21f6ce5e6495de6eca849b54bff 100644 (file)
@@ -48,7 +48,7 @@ static int lm_get_chunk_pi(struct label_manager_chunk **lmc,
                           uint32_t base, vrf_id_t vrf_id)
 {
        if (base == 0)
-               *lmc = create_label_chunk(10, 55, 0, 1, 50, 50 + size);
+               *lmc = create_label_chunk(10, 55, 0, 1, 50, 50 + size, true);
        else
                *lmc = assign_label_chunk(10, 55, 0, 1, size, base);
 
index fa7dbb0a25028fcc6260eef358980d2a15f56436..b2926da15ddf5c3b9b19c704f518ff496a3f249c 100644 (file)
@@ -184,7 +184,7 @@ void label_manager_init(void)
 /* alloc and fill a label chunk */
 struct label_manager_chunk *
 create_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
-                  uint8_t keep, uint32_t start, uint32_t end)
+                  uint8_t keep, uint32_t start, uint32_t end, bool is_dynamic)
 {
        /* alloc chunk, fill it and return it */
        struct label_manager_chunk *lmc =
@@ -196,6 +196,7 @@ create_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
        lmc->instance = instance;
        lmc->session_id = session_id;
        lmc->keep = keep;
+       lmc->is_dynamic = is_dynamic;
 
        return lmc;
 }
@@ -254,7 +255,7 @@ assign_specific_label_chunk(uint8_t proto, unsigned short instance,
        /* insert chunk between existing chunks */
        if (insert_node) {
                lmc = create_label_chunk(proto, instance, session_id, keep,
-                                        base, end);
+                                        base, end, false);
                listnode_add_before(lbl_mgr.lc_list, insert_node, lmc);
                return lmc;
        }
@@ -277,7 +278,7 @@ assign_specific_label_chunk(uint8_t proto, unsigned short instance,
                }
 
                lmc = create_label_chunk(proto, instance, session_id, keep,
-                                        base, end);
+                                        base, end, false);
                if (last_node)
                        listnode_add_before(lbl_mgr.lc_list, last_node, lmc);
                else
@@ -288,7 +289,7 @@ assign_specific_label_chunk(uint8_t proto, unsigned short instance,
                /* create a new chunk past all the existing ones and link at
                 * tail */
                lmc = create_label_chunk(proto, instance, session_id, keep,
-                                        base, end);
+                                        base, end, false);
                listnode_add(lbl_mgr.lc_list, lmc);
                return lmc;
        }
@@ -315,7 +316,10 @@ assign_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
        struct listnode *node;
        uint32_t prev_end = MPLS_LABEL_UNRESERVED_MIN;
 
-       /* handle chunks request with a specific base label */
+       /* handle chunks request with a specific base label
+        * - static label requests: BGP hardset value, Pathd
+        * - segment routing label requests
+        */
        if (base != MPLS_LABEL_BASE_ANY)
                return assign_specific_label_chunk(proto, instance, session_id,
                                                   keep, size, base);
@@ -331,6 +335,7 @@ assign_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
                        lmc->instance = instance;
                        lmc->session_id = session_id;
                        lmc->keep = keep;
+                       lmc->is_dynamic = true;
                        return lmc;
                }
                /* check if we hadve a "hole" behind us that we can squeeze into
@@ -338,7 +343,7 @@ assign_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
                if ((lmc->start > prev_end) && (lmc->start - prev_end > size)) {
                        lmc = create_label_chunk(proto, instance, session_id,
                                                 keep, prev_end + 1,
-                                                prev_end + size);
+                                                prev_end + size, true);
                        listnode_add_before(lbl_mgr.lc_list, node, lmc);
                        return lmc;
                }
@@ -364,7 +369,7 @@ assign_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
 
        /* create chunk and link at tail */
        lmc = create_label_chunk(proto, instance, session_id, keep, start_free,
-                                start_free + size - 1);
+                                start_free + size - 1, true);
        listnode_add(lbl_mgr.lc_list, lmc);
        return lmc;
 }
index 74f40fab23f2c84fdd917842c88b00ff6f22b698..df9513281f070d9127b76e938b5842909ce93312 100644 (file)
@@ -42,6 +42,7 @@ struct label_manager_chunk {
        unsigned short instance;
        uint32_t session_id;
        uint8_t keep;
+       uint8_t is_dynamic; /* Tell if chunk is dynamic or static */
        uint32_t start; /* First label of the chunk */
        uint32_t end;   /* Last label of the chunk */
 };
@@ -82,7 +83,7 @@ int lm_client_connect_response(uint8_t proto, uint16_t instance,
 /* convenience function to allocate an lmc to be consumed by the above API */
 struct label_manager_chunk *
 create_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
-                  uint8_t keep, uint32_t start, uint32_t end);
+                  uint8_t keep, uint32_t start, uint32_t end, bool is_dynamic);
 void delete_label_chunk(void *val);
 
 /* register/unregister callbacks for hooks */