]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Extend ZAPI to handle SRv6 encap behavior
authorCarmine Scarpitta <cscarpit@cisco.com>
Fri, 21 Feb 2025 12:26:26 +0000 (13:26 +0100)
committerCarmine Scarpitta <cscarpit@cisco.com>
Wed, 30 Apr 2025 15:51:25 +0000 (15:51 +0000)
Previous commits introduced the encap_behavior field to the SRv6
nexthop, enabling the association of one of the encapsulation behaviors
defined in RFC 8986 with an SRv6 nexthop.

This commit updates the ZAPI encode/decode functions to support the new
field, allowing zclients to include the encapsulation behavior in the
ZAPI message sent to Zebra for nexthop installation.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
lib/zclient.c
lib/zclient.h

index 7af86cf4d99a14cc7aff7b87001957383687c547..4340863a3ff3a56ec3082d939206d0ed2cabae28 100644 (file)
@@ -961,6 +961,12 @@ static int zapi_nexthop_srv6_cmp(const struct zapi_nexthop *next1,
        if (ret != 0)
                return ret;
 
+       if (next1->srv6_encap_behavior > next2->srv6_encap_behavior)
+               return 1;
+
+       if (next1->srv6_encap_behavior < next2->srv6_encap_behavior)
+               return -1;
+
        if (next1->seg6local_action > next2->seg6local_action)
                return 1;
 
@@ -1182,6 +1188,7 @@ int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
                stream_putc(s, api_nh->seg_num);
                stream_put(s, &api_nh->seg6_segs[0],
                           api_nh->seg_num * sizeof(struct in6_addr));
+               stream_putl(s, api_nh->srv6_encap_behavior);
        }
 done:
        return ret;
@@ -1576,6 +1583,8 @@ int zapi_nexthop_decode(struct stream *s, struct zapi_nexthop *api_nh,
 
                STREAM_GET(&api_nh->seg6_segs[0], s,
                           api_nh->seg_num * sizeof(struct in6_addr));
+
+               STREAM_GETL(s, api_nh->srv6_encap_behavior);
        }
 
        /* Success */
@@ -2419,6 +2428,7 @@ int zapi_nexthop_from_nexthop(struct zapi_nexthop *znh,
                                memcpy(&znh->seg6_segs[i],
                                       &nh->nh_srv6->seg6_segs->seg[i],
                                       sizeof(struct in6_addr));
+                       znh->srv6_encap_behavior = nh->nh_srv6->seg6_segs->encap_behavior;
                }
        }
 
index c90e5dfe4071777b16c35999a5bd7bc931046395..49aa531c1b080ae4b368649fb209f2dfac0ecfcc 100644 (file)
@@ -470,6 +470,7 @@ struct zapi_nexthop {
        /* SRv6 Headend-behaviour */
        int seg_num;
        struct in6_addr seg6_segs[SRV6_MAX_SEGS];
+       enum srv6_headend_behavior srv6_encap_behavior;
 };
 
 /*