Subject: | two bugs (patches included) |
These were found in Net::BGP 0.05, perl version 5.6.1 on NetBSD 1.6.
Bug 1: Constants are implemented as subroutines in various BGP modules.
Perl doesn't evaluate CONSTANT - $number properly. It always returns
the value of CONSTANT. Instead, (CONSTANT) - $number needs to be used.
This caused a bug in receieving a partial BGP header, when trying to
calculate "BGP_MESSAGE_HEADER_LENGTH - $num_read"
Bug 2: in high volume spots, occasionally syswrite returns undef, with
errno set to EAGAIN (normal for non-blocking I/O). BGP::Transport
was treating this as a fatal error and shutting down the connection.
(the patch I included may be OS specific. It uses Errno and EAGAIN)
-Robert
diff -cr /usr/pkg/lib/perl5/site_perl/5.6.1/Net/BGP/Transport.pm lib/site_perl/5.6.1/Net/BGP/Transport.pm
*** /usr/pkg/lib/perl5/site_perl/5.6.1/Net/BGP/Transport.pm Thu Jul 3 15:38:00 2003
--- lib/site_perl/5.6.1/Net/BGP/Transport.pm Mon Oct 27 13:29:59 2003
***************
*** 5,10 ****
--- 5,11 ----
package Net::BGP::Transport;
use strict;
+ use Errno qw(EAGAIN);
use vars qw(
$VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS @BGP @GENERIC
@BGP_EVENT_MESSAGE_MAP @BGP_EVENTS @BGP_FSM @BGP_STATES
***************
*** 581,588 ****
if ( ! defined($sent) ) {
return if $oktofail; # In a _cease process - Don't complain...
! warn $this->parent->asstring . ": Error on socket write: $! - Connection is shutdown\n";
! $this->_cease;
return;
}
--- 582,591 ----
if ( ! defined($sent) ) {
return if $oktofail; # In a _cease process - Don't complain...
! if ($!{EAGAIN} == 0) {
! warn $this->parent->asstring . ": Error on socket write: $! - Connection is shutdown\n";
! $this->_cease;
! }
return;
}
***************
*** 618,624 ****
}
elsif ( $num_read != BGP_MESSAGE_HEADER_LENGTH ) {
$this->{_in_msg_buf_state} = AWAITING_HEADER_FRAGMENT;
! $this->{_in_msg_buf_bytes_exp} = BGP_MESSAGE_HEADER_LENGTH - $num_read;
$this->{_in_msg_buffer} = $buffer;
}
else {
--- 621,627 ----
}
elsif ( $num_read != BGP_MESSAGE_HEADER_LENGTH ) {
$this->{_in_msg_buf_state} = AWAITING_HEADER_FRAGMENT;
! $this->{_in_msg_buf_bytes_exp} = (BGP_MESSAGE_HEADER_LENGTH) - ($num_read);
$this->{_in_msg_buffer} = $buffer;
}
else {