summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2017-04-12 04:16:08 +0000
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2017-04-12 04:41:35 +0000
commit06f2713ec361b286f1d64b515a113c19a5d203b1 (patch)
tree6db1b24e8b0b6a8ec095c2d4430dbb323cffccc9
parent7f95cdc871e21d194ebfaf9c10d0596f17ff2971 (diff)
don't To4() nexthop address when AFI is not IPv4
support for IPv6 NLRI with IPv4 nexthop Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r--packet/bgp/bgp.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/packet/bgp/bgp.go b/packet/bgp/bgp.go
index d7479172..dec650a5 100644
--- a/packet/bgp/bgp.go
+++ b/packet/bgp/bgp.go
@@ -5391,22 +5391,22 @@ func (p *PathAttributeMpReachNLRI) String() string {
func NewPathAttributeMpReachNLRI(nexthop string, nlri []AddrPrefixInterface) *PathAttributeMpReachNLRI {
t := BGP_ATTR_TYPE_MP_REACH_NLRI
- ip := net.ParseIP(nexthop)
- if ip.To4() != nil {
- ip = ip.To4()
- }
p := &PathAttributeMpReachNLRI{
PathAttribute: PathAttribute{
Flags: PathAttrFlags[t],
Type: t,
},
- Nexthop: ip,
- Value: nlri,
+ Value: nlri,
}
if len(nlri) > 0 {
p.AFI = nlri[0].AFI()
p.SAFI = nlri[0].SAFI()
}
+ nh := net.ParseIP(nexthop)
+ if nh.To4() != nil && p.AFI != AFI_IP6 {
+ nh = nh.To4()
+ }
+ p.Nexthop = nh
return p
}