]> git.puffer.fish Git - matthieu/frr.git/commitdiff
isisd: Update router cap TLV size computation
authorCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Sat, 10 Jun 2023 13:51:30 +0000 (15:51 +0200)
committerCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Mon, 11 Sep 2023 15:34:50 +0000 (17:34 +0200)
Update the `isis_router_cap_tlv_size` function to take into account the
SRv6 Capabilities Sub-TLV and SRv6-related MSDs when calculating the
size needed to pack the Router Capabilities TLV.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
isisd/isis_tlvs.c
isisd/isis_tlvs.h

index dd4a72d2c4d8664ef712f81fc8c529d61e50956a..69c73ef081266e14fef0b7a6ab576544199ba77d 100644 (file)
@@ -4193,7 +4193,7 @@ static size_t isis_router_cap_tlv_size(const struct isis_router_cap *router_cap)
 #ifndef FABRICD
        size_t fad_sz;
 #endif /* ifndef FABRICD */
-       int nb_algo;
+       int nb_algo, nb_msd;
 
        if ((router_cap->srgb.range_size != 0) &&
            (router_cap->srgb.lower_bound != 0)) {
@@ -4227,6 +4227,28 @@ static size_t isis_router_cap_tlv_size(const struct isis_router_cap *router_cap)
        }
 #endif /* ifndef FABRICD */
 
+       if (router_cap->srv6_cap.is_srv6_capable) {
+               sz += ISIS_SUBTLV_TYPE_FIELD_SIZE +
+                     ISIS_SUBTLV_LENGTH_FIELD_SIZE +
+                     ISIS_SUBTLV_SRV6_CAPABILITIES_SIZE;
+
+               nb_algo = isis_tlvs_sr_algo_count(router_cap);
+               if (nb_algo != 0)
+                       sz += ISIS_SUBTLV_TYPE_FIELD_SIZE +
+                             ISIS_SUBTLV_LENGTH_FIELD_SIZE + nb_algo;
+
+               nb_msd = router_cap->srv6_msd.max_seg_left_msd +
+                        router_cap->srv6_msd.max_end_pop_msd +
+                        router_cap->srv6_msd.max_h_encaps_msd +
+                        router_cap->srv6_msd.max_end_d_msd;
+               if (nb_msd != 0)
+                       sz += ISIS_SUBTLV_TYPE_FIELD_SIZE +
+                             ISIS_SUBTLV_LENGTH_FIELD_SIZE +
+                             (ISIS_SUBTLV_NODE_MSD_TYPE_SIZE +
+                              ISIS_SUBTLV_NODE_MSD_VALUE_SIZE) *
+                                     nb_msd;
+       }
+
        return sz;
 }
 
index 6ded0c3411aab636d8fe1ee7fac21a75622ad79a..f24c88b165b64ec256debcd9ccd73e19ded81070 100644 (file)
@@ -461,6 +461,10 @@ enum isis_tlv_type {
 
 /* subTLVs size for TE and SR */
 enum ext_subtlv_size {
+       /* Sub-TLV Type and Length fields */
+       ISIS_SUBTLV_TYPE_FIELD_SIZE = 1,
+       ISIS_SUBTLV_LENGTH_FIELD_SIZE = 1,
+
        /* RFC 5307 */
        ISIS_SUBTLV_LLRI_SIZE = 8,
 
@@ -471,6 +475,8 @@ enum ext_subtlv_size {
 
        /* RFC 8491 */
        ISIS_SUBTLV_NODE_MSD_SIZE = 2,
+       ISIS_SUBTLV_NODE_MSD_TYPE_SIZE = 1,
+       ISIS_SUBTLV_NODE_MSD_VALUE_SIZE = 1,
 
        /* RFC 8667 sections #2 & #3 */
        ISIS_SUBTLV_SID_LABEL_SIZE = 3,