From f2b0f1f610ae7a646565e684b78157370d3b01e2 Mon Sep 17 00:00:00 2001 From: Carmine Scarpitta Date: Fri, 21 Feb 2025 13:26:26 +0100 Subject: [PATCH] lib: Extend ZAPI to handle SRv6 encap behavior 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 --- lib/zclient.c | 10 ++++++++++ lib/zclient.h | 1 + 2 files changed, 11 insertions(+) diff --git a/lib/zclient.c b/lib/zclient.c index 7af86cf4d9..4340863a3f 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -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; } } diff --git a/lib/zclient.h b/lib/zclient.h index c90e5dfe40..49aa531c1b 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -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; }; /* -- 2.39.5