Skip to content

NLRI attribute: IP prefix parse error #118

Open
@millionvoid

Description

@millionvoid

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions