From fb99ca86c4a8a8a2b67e1463b2653ef92ad0e6b6 Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Mon, 14 Jun 2021 23:43:05 -0400 Subject: [PATCH] zebra: handle ipv6-mapped-ipv4 with DVNI Properly handle ipv6-mapped-ipv4 with DVNI by converting the address to ipv4 and setting that as the DST field for the encap. Signed-off-by: Stephen Worley --- zebra/rt_netlink.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 31f35a92ad..7f6252e671 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1370,6 +1370,7 @@ static bool _netlink_route_encode_label_info(const struct nexthop *nexthop, struct rtattr *nest; struct mpls_label_stack *nh_label; enum lsp_types_t nh_label_type; + struct in_addr ipv4; nh_label = nexthop->nh_label; nh_label_type = nexthop->nh_label_type; @@ -1405,10 +1406,18 @@ static bool _netlink_route_encode_label_info(const struct nexthop *nexthop, return false; } else if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) { - if (!nl_attr_put(nlmsg, buflen, LWTUNNEL_IP_DST, - &nexthop->gate.ipv6, 16)) - return false; + if (IS_MAPPED_IPV6(&nexthop->gate.ipv6)) { + ipv4_mapped_ipv6_to_ipv4(&nexthop->gate.ipv6, + &ipv4); + if (!nl_attr_put(nlmsg, buflen, LWTUNNEL_IP_DST, + &ipv4, 4)) + return false; + } else { + if (!nl_attr_put(nlmsg, buflen, LWTUNNEL_IP_DST, + &nexthop->gate.ipv6, 16)) + return false; + } } else { if (IS_ZEBRA_DEBUG_KERNEL) zlog_debug( -- 2.39.5