From 73064411ef5b91de6addbc9466079d5b6b8d3252 Mon Sep 17 00:00:00 2001 From: Aperence Date: Thu, 27 Aug 2026 14:48:46 +0200 Subject: [PATCH] route: add seg6 encapsulation to nexthop builder This commits adds the possibility to enable SRv6 encapsulation when creating a nexthop. A new `seg6` function is added to `RouteNextHopBuilder`, which allows to configure SRv6 encapsulation for a specific nexthop. This function follows a similar approach as `output_seg6`. Signed-off-by: Aperence --- src/route/builder.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/route/builder.rs b/src/route/builder.rs index 2a92444..7314aae 100644 --- a/src/route/builder.rs +++ b/src/route/builder.rs @@ -606,6 +606,28 @@ impl RouteNextHopBuilder { self } + /// Sets the nexthop SRv6 encapsulation mode and segments. + #[cfg(not(target_os = "android"))] + pub fn seg6(mut self, mode: Seg6Mode, segments: Vec) -> Self { + if segments.is_empty() { + return self; + } + + let mut header = Seg6Header::default(); + header.mode = mode; + header.segments = segments; + + self.nexthop + .attributes + .push(RouteAttribute::EncapType(RouteLwEnCapType::Seg6)); + let encap = RouteLwTunnelEncap::Seg6(RouteSeg6IpTunnel::Seg6(header)); + self.nexthop + .attributes + .push(RouteAttribute::Encap(vec![encap])); + + self + } + /// Set the nexthop weight /// /// Equal to `weight` property in `ip route`, but please be advised the