]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib,sharpd,zebra: Extend nexthop_add_srv6_seg6 to encode encap behavior
authorCarmine Scarpitta <cscarpit@cisco.com>
Fri, 21 Feb 2025 12:21:36 +0000 (13:21 +0100)
committerCarmine Scarpitta <cscarpit@cisco.com>
Wed, 30 Apr 2025 16:54:43 +0000 (16:54 +0000)
Previous commits introduced the `encap_behavior` field in the SRv6
nexthop data structure and updated the compare, hash, and copy
functions to handle this new field.

This commit extends the `nexthop_add_srv6_seg6` function by adding a
new parameter `encap_behavior` and modify the code in various places
to pass the encap behavior when calling this function.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
lib/nexthop.c
lib/nexthop.h
lib/zclient.c
sharpd/sharp_vty.c
zebra/rt_netlink.c
zebra/zapi_msg.c
zebra/zebra_nhg.c

index 7850827f4a33e75c113bcfdcd31856984181e8ce..7526dd86f66f8dfb7f5a7b93546898e3c449c0ee 100644 (file)
@@ -646,8 +646,8 @@ void nexthop_del_srv6_seg6local(struct nexthop *nexthop)
                XFREE(MTYPE_NH_SRV6, nexthop->nh_srv6);
 }
 
-void nexthop_add_srv6_seg6(struct nexthop *nexthop, const struct in6_addr *segs,
-                          int num_segs)
+void nexthop_add_srv6_seg6(struct nexthop *nexthop, const struct in6_addr *segs, int num_segs,
+                          enum srv6_headend_behavior encap_behavior)
 {
        int i;
 
@@ -674,6 +674,8 @@ void nexthop_add_srv6_seg6(struct nexthop *nexthop, const struct in6_addr *segs,
        for (i = 0; i < num_segs; i++)
                memcpy(&nexthop->nh_srv6->seg6_segs->seg[i], &segs[i],
                       sizeof(struct in6_addr));
+
+       nexthop->nh_srv6->seg6_segs->encap_behavior = encap_behavior;
 }
 
 void nexthop_del_srv6_seg6(struct nexthop *nexthop)
@@ -872,10 +874,9 @@ void nexthop_copy_no_recurse(struct nexthop *copy,
                if (nexthop->nh_srv6->seg6_segs &&
                    nexthop->nh_srv6->seg6_segs->num_segs &&
                    !sid_zero(nexthop->nh_srv6->seg6_segs))
-                       nexthop_add_srv6_seg6(copy,
-                                             &nexthop->nh_srv6->seg6_segs->seg[0],
-                                             nexthop->nh_srv6->seg6_segs
-                                                     ->num_segs);
+                       nexthop_add_srv6_seg6(copy, &nexthop->nh_srv6->seg6_segs->seg[0],
+                                             nexthop->nh_srv6->seg6_segs->num_segs,
+                                             nexthop->nh_srv6->seg6_segs->encap_behavior);
        }
 }
 
index cea7c77e3ea89c93061e5bad2080772d04e29002..dba51627522c06689da89f698d2c0c89e9d0ded9 100644 (file)
@@ -207,8 +207,8 @@ void nexthop_change_labels(struct nexthop *nexthop, struct mpls_label_stack *new
 void nexthop_add_srv6_seg6local(struct nexthop *nexthop, uint32_t action,
                                const struct seg6local_context *ctx);
 void nexthop_del_srv6_seg6local(struct nexthop *nexthop);
-void nexthop_add_srv6_seg6(struct nexthop *nexthop, const struct in6_addr *seg,
-                          int num_segs);
+void nexthop_add_srv6_seg6(struct nexthop *nexthop, const struct in6_addr *seg, int num_segs,
+                          enum srv6_headend_behavior encap_behavior);
 void nexthop_del_srv6_seg6(struct nexthop *nexthop);
 
 /*
index 4340863a3ff3a56ec3082d939206d0ed2cabae28..122a6ef52a5b19a71fd4668f6403fcd754075227 100644 (file)
@@ -2359,7 +2359,7 @@ struct nexthop *nexthop_from_zapi_nexthop(const struct zapi_nexthop *znh)
                                           &znh->seg6local_ctx);
 
        if (znh->seg_num && !sid_zero_ipv6(znh->seg6_segs))
-               nexthop_add_srv6_seg6(n, &znh->seg6_segs[0], znh->seg_num);
+               nexthop_add_srv6_seg6(n, &znh->seg6_segs[0], znh->seg_num, znh->srv6_encap_behavior);
 
        return n;
 }
index fd36e8898eee12d53ff8af3452877b2ce007e2d8..a6bcfff3b7ddf8a90bdc42f9360e1b817825ef9d 100644 (file)
@@ -429,7 +429,7 @@ DEFPY (install_seg6_routes,
        sg.r.nhop.gate.ipv6 = seg6_nh6;
        sg.r.nhop.vrf_id = vrf->vrf_id;
        sg.r.nhop_group.nexthop = &sg.r.nhop;
-       nexthop_add_srv6_seg6(&sg.r.nhop, &seg6_seg, 1);
+       nexthop_add_srv6_seg6(&sg.r.nhop, &seg6_seg, 1, SRV6_HEADEND_BEHAVIOR_H_ENCAPS);
 
        sg.r.vrf_id = vrf->vrf_id;
        sharp_install_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst, 0,
@@ -527,7 +527,7 @@ DEFPY(install_seg6local_segs_routes, install_seg6local_segs_routes_cmd,
        sg.r.nhop_group.nexthop = &sg.r.nhop;
        seg_list[0] = seg6_seg1;
        seg_list[1] = seg6_seg2;
-       nexthop_add_srv6_seg6(&sg.r.nhop, p_seg_list, 2);
+       nexthop_add_srv6_seg6(&sg.r.nhop, p_seg_list, 2, SRV6_HEADEND_BEHAVIOR_H_ENCAPS);
 
        sg.r.vrf_id = vrf->vrf_id;
        sharp_install_routes_helper(&sg.r.orig_prefix, sg.r.vrf_id, sg.r.inst, 0, &sg.r.nhop_group,
index 8f6a032959d92808b6c3586793e7afd304c3f41a..62fde90018ed778bf0e63ccf353633e77dc5ab6e 100644 (file)
@@ -612,7 +612,7 @@ parse_nexthop_unicast(ns_id_t ns_id, struct rtmsg *rtm, struct rtattr **tb,
                nexthop_add_srv6_seg6local(&nh, seg6l_act, &seg6l_ctx);
 
        if (num_segs)
-               nexthop_add_srv6_seg6(&nh, segs, num_segs);
+               nexthop_add_srv6_seg6(&nh, segs, num_segs, srv6_encap_behavior);
 
        return nh;
 }
@@ -729,7 +729,7 @@ static uint16_t parse_multipath_nexthops_unicast(ns_id_t ns_id, struct nexthop_g
                                                           &seg6l_ctx);
 
                        if (num_segs)
-                               nexthop_add_srv6_seg6(nh, segs, num_segs);
+                               nexthop_add_srv6_seg6(nh, segs, num_segs, srv6_encap_behavior);
 
                        if (rtnh->rtnh_flags & RTNH_F_ONLINK)
                                SET_FLAG(nh->flags, NEXTHOP_FLAG_ONLINK);
index fc78f87eb1dea462d65137fcf31d4387b25bca35..9687d71e257cd540e22b9979a17bd90a5ac1029f 100644 (file)
@@ -1888,8 +1888,8 @@ static bool zapi_read_nexthops(struct zserv *client, struct prefix *p,
                        if (IS_ZEBRA_DEBUG_RECV)
                                zlog_debug("%s: adding seg6", __func__);
 
-                       nexthop_add_srv6_seg6(nexthop, &api_nh->seg6_segs[0],
-                                             api_nh->seg_num);
+                       nexthop_add_srv6_seg6(nexthop, &api_nh->seg6_segs[0], api_nh->seg_num,
+                                             api_nh->srv6_encap_behavior);
                }
 
                if (IS_ZEBRA_DEBUG_RECV) {
index 1da2c13c15c832740dae9b63288a561a4ce0b9c7..4d73d8620e4089fc3495514b88dcd0831784fd2c 100644 (file)
@@ -1965,10 +1965,9 @@ static struct nexthop *nexthop_set_resolved(afi_t afi,
                                                   &nexthop->nh_srv6
                                                            ->seg6local_ctx);
                if (nexthop->nh_srv6->seg6_segs)
-                       nexthop_add_srv6_seg6(resolved_hop,
-                                             &nexthop->nh_srv6->seg6_segs->seg[0],
-                                             nexthop->nh_srv6->seg6_segs
-                                                     ->num_segs);
+                       nexthop_add_srv6_seg6(resolved_hop, &nexthop->nh_srv6->seg6_segs->seg[0],
+                                             nexthop->nh_srv6->seg6_segs->num_segs,
+                                             nexthop->nh_srv6->seg6_segs->encap_behavior);
        }
 
        resolved_hop->rparent = nexthop;