]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: update del_srv6_seg6_local to handle seg6_segs
authorDmytro Shytyi <dmytro.shytyi@6wind.com>
Thu, 3 Aug 2023 16:35:53 +0000 (18:35 +0200)
committerDmytro Shytyi <dmytro.shytyi@6wind.com>
Wed, 20 Sep 2023 13:07:15 +0000 (15:07 +0200)
Adapt de_srv6_seg6local to handle seg6_segs structure.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
lib/nexthop.c

index c27c0d55599296b920f6e699fb351e49a9591c79..e19c1d6800357cc978a00481709160c32deb5e98 100644 (file)
@@ -362,7 +362,7 @@ struct nexthop *nexthop_new(void)
         * The linux kernel does some weird stuff with adding +1 to
         * all nexthop weights it gets over netlink.
         * To handle this, just default everything to 1 right from
-        * from the beginning so we don't have to special case
+        * the beginning so we don't have to special case
         * default weights in the linux netlink code.
         *
         * 1 should be a valid on all platforms anyway.
@@ -568,8 +568,16 @@ void nexthop_del_srv6_seg6local(struct nexthop *nexthop)
        if (!nexthop->nh_srv6)
                return;
 
+       if (nexthop->nh_srv6->seg6local_action == ZEBRA_SEG6_LOCAL_ACTION_UNSPEC)
+               return;
+
        nexthop->nh_srv6->seg6local_action = ZEBRA_SEG6_LOCAL_ACTION_UNSPEC;
 
+       if (nexthop->nh_srv6->seg6_segs &&
+           (nexthop->nh_srv6->seg6_segs->num_segs == 0 ||
+            sid_zero(nexthop->nh_srv6->seg6_segs)))
+               XFREE(MTYPE_NH_SRV6, nexthop->nh_srv6->seg6_segs);
+
        if (nexthop->nh_srv6->seg6_segs == NULL)
                XFREE(MTYPE_NH_SRV6, nexthop->nh_srv6);
 }