wladwm / zettabgp

BGP & BMP Rust library
MIT License
13 stars 5 forks source link

evpn: fix type 2 serialization #19

Closed Tuetuopay closed 7 months ago

Tuetuopay commented 7 months ago

The MAC address is stored in reverse order from what it is on the wire; leading to a bad serialization when encoding back routes that were decoded from an actual bgp peer.

Fixes: 268ecb9 ("First release")

As a side note, why on earth are MAC addresses stored in reverse order? They are a sequence of bytes, not a compound number, thus there is no notion of "network byte order". Bytes are on the same order everywhere.

Thanks!

wladwm commented 7 months ago

Hi! Could you please chane Mac method names to something like: from -> from_network_bytes write_to -> write_to_network_byte

Tuetuopay commented 7 months ago

Hi, sure! However this still surprises me because MAC addresses don't have the notion of byte ordering, as they're stored on the wire the same way they are everywhere else: it's a byte array, not a word compounded of multiple bytes with endianess.

As it is right now, i'll do it, but this makes the structure be the opposite of what's expected. E.G. the MAC aa:bb:cc:dd:ee:ff will be stored as MacAddress { mac_address: [0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa] } which is highly unexpected.

Tuetuopay commented 7 months ago

Done.