From 857945ad1a8aff9077f84a5b8db7318852330725 Mon Sep 17 00:00:00 2001 From: Dmytro Shytyi Date: Thu, 3 Aug 2023 18:35:53 +0200 Subject: [PATCH] lib: update del_srv6_seg6_local to handle seg6_segs Adapt de_srv6_seg6local to handle seg6_segs structure. Signed-off-by: Dmytro Shytyi --- lib/nexthop.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/nexthop.c b/lib/nexthop.c index c27c0d5559..e19c1d6800 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -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); } -- 2.39.5