diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2017-04-12 04:16:08 +0000 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2017-04-12 04:41:35 +0000 |
commit | 06f2713ec361b286f1d64b515a113c19a5d203b1 (patch) | |
tree | 6db1b24e8b0b6a8ec095c2d4430dbb323cffccc9 /packet/bgp/bgp.go | |
parent | 7f95cdc871e21d194ebfaf9c10d0596f17ff2971 (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>
Diffstat (limited to 'packet/bgp/bgp.go')
-rw-r--r-- | packet/bgp/bgp.go | 12 |
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 } |