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/