From a3536fae2f1d865e11c624e19e8319d33f02908d Mon Sep 17 00:00:00 2001 From: Dmytro Shytyi Date: Wed, 20 Dec 2023 16:18:32 +0100 Subject: [PATCH] zebra: fix static srv6 segment-list sid order When configuring a SID list by vtysh, the segment list obtained in iproute2 is the exact opposite: > >vtysh: >ipv6 route 2005::/64 eth0 segments 2001:db8:aaaa::7/2002::2/2003::3/2004::4 > >root@r1:/# ip -6 route >2005::/64 nhid 6 encap seg6 mode encap segs 4 [ 2004::4 2003::3 2002::2 2001:db8:aaaa::7 ] dev dummy0 proto 196 metric 20 pref medium > Fix this by keeping the same vtysh config and swap the segment's order of the list in the rt_netlink.c > >root@r1:/# ip -6 route >2005::/64 nhid 6 encap seg6 mode encap segs 4 [ 2001:db8:aaaa::7 2002::2 2003::3 2004::4 ] dev dummy0 proto 196 metric 20 pref medium > Fixes: f20cf14 ("bgpd,lib,sharpd,zebra: srv6 introduce multiple segs/SIDs in nexthop") Signed-off-by: Dmytro Shytyi --- zebra/rt_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index f092fc5c85da..dde4704936fd 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1550,7 +1550,7 @@ static ssize_t fill_seg6ipt_encap(char *buffer, size_t buflen, srh->first_segment = segs->num_segs - 1; for (i = 0; i < segs->num_segs; i++) { - memcpy(&srh->segments[i], &segs->seg[i], + memcpy(&srh->segments[segs->num_segs - i - 1], &segs->seg[i], sizeof(struct in6_addr)); }