]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: Store neighbor Adjacency SID in SR database 7322/head
authorOlivier Dugeon <olivier.dugeon@orange.com>
Wed, 14 Oct 2020 12:17:58 +0000 (14:17 +0200)
committerOlivier Dugeon <olivier.dugeon@orange.com>
Wed, 14 Oct 2020 12:17:58 +0000 (14:17 +0200)
For TI-LFA, it is necessay to known the Adjacency SID advetise by the nieghbor
routers. However, the current Segment Routing code skip neighbor Adjacency SID
and thus, don't store them into the Segment Routing database.

This PR takes care of neighbor Adjacency SID by allowing to store them in the
Segment Routing database. Corresponding MPLS table entry is only configured if
the advertised Adjacency SID is global i.e. with L-Flag unset.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
ospfd/ospf_sr.c
ospfd/ospf_sr.h

index eb882c5d0e57df2ad4f32d77c092c970238824c0..64d7b39acda9e098b5ba649315de439639988a1c 100644 (file)
@@ -1046,6 +1046,7 @@ static void update_ext_link_sid(struct sr_node *srn, struct sr_link *srl,
        struct listnode *node;
        struct sr_link *lk;
        bool found = false;
+       bool config = true;
 
        /* Sanity check */
        if ((srn == NULL) || (srl == NULL))
@@ -1053,11 +1054,11 @@ static void update_ext_link_sid(struct sr_node *srn, struct sr_link *srl,
 
        osr_debug("  |-  Process Extended Link Adj/Lan-SID");
 
-       /* Skip Local Adj/Lan_Adj SID coming from neighbors */
+       /* Detect if Adj/Lan_Adj SID must be configured */
        if (!CHECK_FLAG(lsa_flags, OSPF_LSA_SELF)
            && (CHECK_FLAG(srl->flags[0], EXT_SUBTLV_LINK_ADJ_SID_LFLG)
                || CHECK_FLAG(srl->flags[1], EXT_SUBTLV_LINK_ADJ_SID_LFLG)))
-               return;
+               config = false;
 
        /* Search for existing Segment Link */
        for (ALL_LIST_ELEMENTS_RO(srn->ext_link, node, lk))
@@ -1077,28 +1078,31 @@ static void update_ext_link_sid(struct sr_node *srn, struct sr_link *srl,
                IPV4_ADDR_COPY(&srl->adv_router, &srn->adv_router);
                listnode_add(srn->ext_link, srl);
                /* Try to set MPLS table */
-               if (compute_link_nhlfe(srl)) {
+               if (config && compute_link_nhlfe(srl)) {
                        add_adj_sid(srl->nhlfe[0]);
                        add_adj_sid(srl->nhlfe[1]);
                }
        } else {
+               /* Update SR-Link if they are different */
                if (sr_link_cmp(lk, srl)) {
-                       if (compute_link_nhlfe(srl)) {
-                               update_adj_sid(lk->nhlfe[0], srl->nhlfe[0]);
-                               update_adj_sid(lk->nhlfe[1], srl->nhlfe[1]);
-                               /* Replace Segment List */
-                               listnode_delete(srn->ext_link, lk);
-                               XFREE(MTYPE_OSPF_SR_PARAMS, lk);
-                               srl->srn = srn;
-                               IPV4_ADDR_COPY(&srl->adv_router,
-                                              &srn->adv_router);
-                               listnode_add(srn->ext_link, srl);
-                       } else {
-                               /* New NHLFE was not found.
-                                * Just free the SR Link
-                                */
-                               XFREE(MTYPE_OSPF_SR_PARAMS, srl);
+                       /* Try to set MPLS table */
+                       if (config) {
+                               if (compute_link_nhlfe(srl)) {
+                                       update_adj_sid(lk->nhlfe[0],
+                                                      srl->nhlfe[0]);
+                                       update_adj_sid(lk->nhlfe[1],
+                                                      srl->nhlfe[1]);
+                               } else {
+                                       del_adj_sid(lk->nhlfe[0]);
+                                       del_adj_sid(lk->nhlfe[1]);
+                               }
                        }
+                       /* Replace SR-Link in SR-Node Adjacency List */
+                       listnode_delete(srn->ext_link, lk);
+                       XFREE(MTYPE_OSPF_SR_PARAMS, lk);
+                       srl->srn = srn;
+                       IPV4_ADDR_COPY(&srl->adv_router, &srn->adv_router);
+                       listnode_add(srn->ext_link, srl);
                } else {
                        /*
                         * This is just an LSA refresh.
index c54d2dcc3c90d1991806b071d797d340c21400b7..222675944d4dcf88907216c84b76a16d3b077399 100644 (file)
@@ -269,7 +269,7 @@ struct sr_node {
 
        /* List of Prefix & Link advertise by this node */
        struct list *ext_prefix; /* For Node SID */
-       struct list *ext_link;   /* For Adj and LAN SID */
+       struct list *ext_link;   /* For Adjacency SID */
 
        /* Pointer to FRR SR-Node or NULL if it is not a neighbor */
        struct sr_node *neighbor;