diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-03-25 02:15:36 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-03-25 21:10:02 +0900 |
commit | 593f1d384f4307b9160359a3a5e1c98dce5c9edf (patch) | |
tree | 29b376d5226ae91eb040c482befd126502f901db /packet/bgp.go | |
parent | 746ffa1cf79c935f6ea30e8e4e53bc6028015ceb (diff) |
packet: fix mpreach nlri path attribute
RFC2545#section-3 says, when AFI is ipv6, mpreach nlri may include
a link-local address just after a global address as a nexthop.
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp.go')
-rw-r--r-- | packet/bgp.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index 66059134..44f562eb 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -2264,10 +2264,11 @@ func NewPathAttributeClusterList(value []string) *PathAttributeClusterList { type PathAttributeMpReachNLRI struct { PathAttribute - Nexthop net.IP - AFI uint16 - SAFI uint8 - Value []AddrPrefixInterface + Nexthop net.IP + LinkLocalNexthop net.IP + AFI uint16 + SAFI uint8 + Value []AddrPrefixInterface } func (p *PathAttributeMpReachNLRI) DecodeFromBytes(data []byte) error { @@ -2302,13 +2303,22 @@ func (p *PathAttributeMpReachNLRI) DecodeFromBytes(data []byte) error { offset = 8 } addrlen := 4 + hasLinkLocal := false + if afi == AFI_IP6 { addrlen = 16 + hasLinkLocal = len(nexthopbin) == offset+2*addrlen } - if len(nexthopbin) != offset+addrlen { + + isValid := len(nexthopbin) == offset+addrlen || hasLinkLocal + + if !isValid { return NewMessageError(eCode, eSubCode, value, "mpreach nexthop length is incorrect") } p.Nexthop = nexthopbin[offset : +offset+addrlen] + if hasLinkLocal { + p.LinkLocalNexthop = nexthopbin[offset+addrlen : offset+2*addrlen] + } } // skip reserved if len(value) == 0 { |