summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSerguei Bezverkhi <sbezverk@cisco.com>2020-05-08 10:32:27 -0400
committerSerguei Bezverkhi <sbezverk@cisco.com>2020-05-08 10:32:27 -0400
commit95745b6cf9a5ed229c5494bb0b531215dec38dbe (patch)
treef274f3a910d6b0de7119c9f070fe0a242082c61a
parenta8ed57e6612d4d6356adb7fb8bdd1a32ca24c3eb (diff)
fix ipv6 nexthop
Signed-off-by: Serguei Bezverkhi <sbezverk@cisco.com>
-rw-r--r--internal/pkg/apiutil/attribute.go8
1 files changed, 6 insertions, 2 deletions
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: