From 4397eed0633ded762e951cab00f65bff1751b5a5 Mon Sep 17 00:00:00 2001 From: Luuk Hendriks Date: Wed, 20 Dec 2023 12:42:37 +0100 Subject: [PATCH] RFC4684 (MPLS with other AFI as nexthop) got lost --- src/bgp/message/nlri.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/bgp/message/nlri.rs b/src/bgp/message/nlri.rs index 03506829..32383993 100644 --- a/src/bgp/message/nlri.rs +++ b/src/bgp/message/nlri.rs @@ -670,7 +670,6 @@ impl NextHop { Ipv4Unicast | Ipv4Multicast | - Ipv4MplsUnicast | Ipv4RouteTarget | L2VpnVpls | L2VpnEvpn @@ -690,14 +689,21 @@ impl NextHop { _ => error!() } } - Ipv6Multicast | - Ipv6MplsUnicast - => { + Ipv6Multicast => { match len { 16 => NextHop::Unicast(parse_ipv6addr(parser)?.into()), _ => error!() } } + // RFC4684: the nexthop for MPLS can be of the other AFI than the + // NLRI themselves are. + Ipv4MplsUnicast | Ipv6MplsUnicast => { + match len { + 4 => NextHop::Unicast(parse_ipv4addr(parser)?.into()), + 16 => NextHop::Unicast(parse_ipv6addr(parser)?.into()), + _ => error!() + } + } Ipv4MplsVpnUnicast => { match len { 12 => NextHop::MplsVpnUnicast(