Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NLRI attribute: IP prefix parse error #118

Open
millionvoid opened this issue Jan 11, 2021 · 0 comments
Open

NLRI attribute: IP prefix parse error #118

millionvoid opened this issue Jan 11, 2021 · 0 comments

Comments

@millionvoid
Copy link

millionvoid commented Jan 11, 2021

In file: https://github.com/smartbgp/yabgp/blob/master/yabgp/message/attribute/nlri/ipv6_unicast.py
line 45: prefix_addr = str(netaddr.IPAddress(int(binascii.b2a_hex(nlri_data[1:offset]), 16))) \ + '/%s' % prefix_bit_len
It returns an address with extra leading zeros when prefix_bit_len is non-zero.
For example, an original IP prefix a::/96 will turn out to be 0:0: a::/96, because the parser netaddr.IPAddress does not know there are some zeros masked, it will put the missing zeros at the start of the IP address, causing this issue.
One possible correction is prefix_addr = str(netaddr.IPAddress(int(binascii.b2a_hex(nlri_data[1:offset]), 16)<<(full_length-prefix_bit_len))) \ + '/%s' % prefix_bit_len where full_length is 32 for ipv4 and 128 for ipv6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant