Skip Menu |

This queue is for tickets about the Net-BGP CPAN distribution.

Report information
The Basics
Id: 49291
Status: resolved
Worked: 10 min
Priority: 0/
Queue: Net-BGP

People
Owner: Nobody in particular
Requestors: elisa.jasinska [...] ams-ix.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Bug in Update.pm on AS Path Attribute Flag 0x50 (incl. Extended Length)
Date: Mon, 31 Aug 2009 17:39:14 +0200
To: kevin brintnall via RT <bug-Net-BGP [...] rt.cpan.org>
From: Elisa Jasinska <elisa.jasinska [...] ams-ix.net>
Dear Kevin, Net::BGP seems to expect the flags value: 0x40 (Well-known, Transitive, Complete) for an AS path attribute. Now AS path can also include the extended length flag, which makes the flags value: 0x50 (Well-known, Transitive, Complete, Extended Length). The code seems to be able to handle the extended length and decode the length field with 2 bytes. But the validity check on the flag for this attribute type doesn't. Update.pm line 452: if ( $BGP_PATH_ATTR_FLAGS[$type] != $flags) { Net::BGP::Notification->throw( ErrorCode => BGP_ERROR_CODE_UPDATE_MESSAGE, ErrorSubCode => BGP_ERROR_SUBCODE_BAD_ATTR_FLAGS, ErrorData => $error_data ); } for $type == 2 it expects 0x40 according to: @BGP_PATH_ATTR_FLAGS = ( 0x00, ## TODO: change to undef after warnings enabled 0x40, 0x40, 0x40, 0x40, 0x80, 0x40, 0x40, 0xC0, 0xC0, ); I quickly fixed this by adding 0x50 as the last element of the array (index 8, it seems like this type code is not in use), so it looks as follows: @BGP_PATH_ATTR_FLAGS = ( 0x00, ## TODO: change to undef after warnings enabled 0x40, 0x40, 0x40, 0x40, 0x80, 0x40, 0x40, 0xC0, ## HACK 0x50, ); and Update.pm line 452 now checks for: ### HACK if ( $BGP_PATH_ATTR_FLAGS[$type] != $flags and $BGP_PATH_ATTR_FLAGS[8] != $flags) { Net::BGP::Notification->throw( ErrorCode => BGP_ERROR_CODE_UPDATE_MESSAGE, ErrorSubCode => BGP_ERROR_SUBCODE_BAD_ATTR_FLAGS, ErrorData => $error_data ); } But this is a very quick and dirty solution... maybe you would want to adapt @BGP_PATH_ATTR_FLAGS to an array of arrays, so it could actually hold multiple possibilities for one type code.... or something like that. Best regards Elisa -- Elisa Jasinska - AMS-IX NOC http://www.ams-ix.net/
From: Simon van der Linden <simon.vanderlinden [...] uclouvain.be>
Here is perhaps a better fix. As far as I understand RFC 4271, the Extended Length flag can be set for any attribute, so I made the check for known flag combinations ignore the Extended Length flag. The 2-byte length field seem to be correctly handled in any case.
Subject: extlen_check_fix.patch
diff --git a/Net-BGP-0.13/lib/Net/BGP/Update.pm b/Net-BGP-0.13/lib/Net/BGP/Update.pm index 728222e..f185f06 100644 --- a/Net-BGP-0.13/lib/Net/BGP/Update.pm +++ b/Net-BGP-0.13/lib/Net/BGP/Update.pm @@ -446,7 +446,7 @@ sub _decode_path_attributes if (defined $decode_sub[$type]) { $error_data = substr($buffer, $offset - $len_bytes - 2, $length + $len_bytes + 2); - if ( $BGP_PATH_ATTR_FLAGS[$type] != $flags ) { + if ( $BGP_PATH_ATTR_FLAGS[$type] != ($flags & ~$BGP_PATH_ATTR_FLAG_EXTLEN) ) { Net::BGP::Notification->throw( ErrorCode => BGP_ERROR_CODE_UPDATE_MESSAGE, ErrorSubCode => BGP_ERROR_SUBCODE_BAD_ATTR_FLAGS,
Subject: Re: [rt.cpan.org #49291] Bug in Update.pm on AS Path Attribute Flag 0x50 (incl. Extended Length)
Date: Sat, 18 Sep 2010 09:31:42 -0500
To: bug-Net-BGP [...] rt.cpan.org
From: kevin brintnall <kbrint [...] rufus.net>
Hi Simon, I think your fix is just right. I've uploaded version 0.14 to CPAN accordingly. You should see it appear shortly. Thanks for your contribution! -kb On Wed, Sep 15, 2010 at 3:52 AM, http://openid.vanderlinden.eu.org/simon via RT <bug-Net-BGP@rt.cpan.org> wrote: Show quoted text
> Queue: Net-BGP > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=49291 > > > Here is perhaps a better fix. As far as I understand RFC 4271, the > Extended Length flag can be set for any attribute, so I made the check > for known flag combinations ignore the Extended Length flag. The 2-byte > length field seem to be correctly handled in any case. >
-- kevin brintnall =~ /kbrint@rufus.net/
integrated fix.