From 95745b6cf9a5ed229c5494bb0b531215dec38dbe Mon Sep 17 00:00:00 2001 From: Serguei Bezverkhi Date: Fri, 8 May 2020 10:32:27 -0400 Subject: fix ipv6 nexthop Signed-off-by: Serguei Bezverkhi --- internal/pkg/apiutil/attribute.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'internal') diff --git a/internal/pkg/apiutil/attribute.go b/internal/pkg/apiutil/attribute.go index 48463a0c..1610a181 100644 --- a/internal/pkg/apiutil/attribute.go +++ b/internal/pkg/apiutil/attribute.go @@ -45,7 +45,9 @@ func UnmarshalAttribute(an *any.Any) (bgp.PathAttributeInterface, error) { case *api.NextHopAttribute: nexthop := net.ParseIP(a.NextHop).To4() if nexthop == nil { - return nil, fmt.Errorf("invalid nexthop address: %s", a.NextHop) + if nexthop = net.ParseIP(a.NextHop).To16(); nexthop == nil { + return nil, fmt.Errorf("invalid nexthop address: %s", a.NextHop) + } } return bgp.NewPathAttributeNextHop(a.NextHop), nil case *api.MultiExitDiscAttribute: @@ -1363,7 +1365,9 @@ func unmarshalAttribute(an *any.Any) (bgp.PathAttributeInterface, error) { case *api.NextHopAttribute: nexthop := net.ParseIP(a.NextHop).To4() if nexthop == nil { - return nil, fmt.Errorf("invalid nexthop address: %s", a.NextHop) + if nexthop = net.ParseIP(a.NextHop).To16(); nexthop == nil { + return nil, fmt.Errorf("invalid nexthop address: %s", a.NextHop) + } } return bgp.NewPathAttributeNextHop(a.NextHop), nil case *api.MultiExitDiscAttribute: -- cgit v1.2.3