Hi, Henk

Thank you for your report!

As you said, now Ryu expects Peer address starts with IPv4 address, not 12 bytes of padding:
https://github.com/osrg/ryu/blob/master/ryu/lib/packet/bmp.py#L211

This quick fix should fix your problem. Could you try this?

diff --git a/ryu/lib/packet/bmp.py b/ryu/lib/packet/bmp.py
index 9d1cda3..3e20647 100644
--- a/ryu/lib/packet/bmp.py
+++ b/ryu/lib/packet/bmp.py
@@ -208,7 +208,7 @@ class BMPPeerMessage(BMPMessage):
         if peer_flags & (1 << 7):
             peer_address = addrconv.ipv6.bin_to_text(peer_address)
         else:
-            peer_address = addrconv.ipv4.bin_to_text(peer_address[:4])
+            peer_address = addrconv.ipv4.bin_to_text(peer_address[-4:])

         peer_bgp_id = addrconv.ipv4.bin_to_text(peer_bgp_id)

@@ -234,7 +234,7 @@ class BMPPeerMessage(BMPMessage):
             flags |= (1 << 7)
             peer_address = addrconv.ipv6.text_to_bin(self.peer_address)
         else:
-            peer_address = addrconv.ipv4.text_to_bin(self.peer_address)
+ peer_address = b'\x00' * 12 + addrconv.ipv4.text_to_bin(self.peer_address)

         peer_bgp_id = addrconv.ipv4.text_to_bin(self.peer_bgp_id)

Thanks,
Fujimoto


On 2017年08月15日 23:52, Henk Smit wrote:

Hello,

I noticed a bug in your BMP collector implementation.

See RFC 7854:
https://tools.ietf.org/html/rfc7854#section-4.2

   o  Peer Address: The remote IP address associated with the TCP
      session over which the encapsulated PDU was received.  It is 4
      bytes long if an IPv4 address is carried in this field (with the
      12 most significant bytes zero-filled) and 16 bytes long if an
      IPv6 address is carried in this field.

If the peer-address is an IPv4 address, the format should be:
12 bytes with value zero, followed by 4 bytes with the IPv4 address
It seems your BMP implementation expects:
4 bytes with the IPv4 address, followed by 12 bytes with value zero

That's wrong.
See the RFC.
As a result, your BMP collector will always report IPv4-peers as 0.0.0.0.
The same problem happens with the local-address in the peer-up message. Also always wrongly reported as 0.0.0.0.

I checked, and existing implementations of BMP in routers follow the RFC.
I suggest your fix the problem on Ryu's end.
The fix should be easy, but I am not working on Ryu, so I am not going to fix this myself.


Is there still ongoing development of the BMP part of Ryu ?
An obvious bug like this would seem to indicate that very few people are using Ryu's BMP ? Or else maybe everybody is using IPv6 ? With IPv6 all 16 bytes in the address are used, so in that case, there is no confusion and no bug.

Thanks in advance,

henk.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to