diff options
author | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2014-09-19 17:24:32 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-09-27 18:28:20 +0900 |
commit | ff064e662af44ab355f7fff6126a2fa672409778 (patch) | |
tree | 818982eda205cfff9741f7de7288ef26de6571c3 | |
parent | 594fb6a191a30256d21c332ea41c6ddbcc201fac (diff) |
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>
-rw-r--r-- | ryu/lib/packet/bgp.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ryu/lib/packet/bgp.py b/ryu/lib/packet/bgp.py index 60e3b49c..ff6d7afe 100644 --- a/ryu/lib/packet/bgp.py +++ b/ryu/lib/packet/bgp.py @@ -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) |