bgp: ignore link-local address

According to RFC 2545, both a global address and a link-local address
can be sent as a next_hop address in BGPUpdate message.
Since the link-local address is not needed in Ryu BGP,
Ryu BGP ignore it if the address family is IPv6 unicast.

Signed-off-by: Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Hiroshi Yokoi 2014-09-19 17:24:32 +09:00 committed by FUJITA Tomonori
parent 594fb6a191
commit ff064e662a

View File

@ -2014,6 +2014,16 @@ class BGPPathAttributeMpReachNLRI(_PathAttribute):
elif afi == addr_family.IP:
next_hop = addrconv.ipv4.bin_to_text(next_hop_bin)
elif afi == addr_family.IP6:
# next_hop_bin can include global address and link-local address
# according to RFC2545. Since a link-local address isn't needed in
# Ryu BGPSpeaker, we ignore it if both addresses were sent.
# The link-local address is supposed to follow after
# a global address and next_hop_len will be 32 bytes,
# so we use the first 16 bytes, which is a global address,
# as a next_hop and change the next_hop_len to 16.
if next_hop_len == 32:
next_hop_bin = next_hop_bin[:16]
next_hop_len = 16
next_hop = addrconv.ipv6.bin_to_text(next_hop_bin)
else:
raise ValueError('Invalid address familly(%d)' % afi)