Hi, Yongjun.
Thanks for reporting.
I understand that we must care not only FIN_WAIT_2 but also CLOSING.
I will apply your modification into our source code.
Thanks,
On Tue, 26 May 2009 10:39:03 +0800
Wei Yongjun <yjwei@cn.fujitsu.com> wrote:
> The close process of TCP connection under linux which using
> port 7 as echo-strem is like the following:
>
> FIN,ACK ------------>
> <------------ FIN,ACK
> ACK ------------>
>
> Not awalys:
> FIN,ACK ------------>
> <------------ ACK
> <------------ FIN,ACK
> ACK ------------>
>
> So the ipsec.p2/p2_HTR_E_TCP_Padding.seq test will fail under linux.
>
> This patch fixed the problem with backwards compatibility.
>
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
> ---
> ipsec.p2/IPSEC.pm | 83 +++++++++++++++++++++++++++-------------------------
> 1 files changed, 43 insertions(+), 40 deletions(-)
>
> diff --git a/ipsec.p2/IPSEC.pm b/ipsec.p2/IPSEC.pm
> index 4e709aa..5420b37 100755
> --- a/ipsec.p2/IPSEC.pm
> +++ b/ipsec.p2/IPSEC.pm
> @@ -1844,7 +1844,7 @@ sub ipsecFinAckTcp2NUT($$$$$$$$){
> $CPP_HASH{'ACKFLAG'}=1;
> $CPP_HASH{'PSHFLAG'}=0;
> $CPP_HASH{'SYNFLAG'}=0;
> - $CPP_HASH{'FINFLAG'}=0;
> + $CPP_HASH{'FINFLAG'}=any;
> $CPP = undef;
> for my $i (keys %CPP_HASH){
> $CPP .= "-D$i=$CPP_HASH{$i} ";
> @@ -1875,47 +1875,50 @@ sub ipsecFinAckTcp2NUT($$$$$$$$){
>
> $seq=$ret{$base_path.'.Hdr_TCP.SequenceNumber'};
> $ack=$ret{$base_path.'.Hdr_TCP.AcknowledgmentNumber'};
> -
> - vLogHTML("Host-1 received Ack SequenceNumber=$seq, AcknowledgmentNumber=$ack from End-Node(NUT).<BR>");
> -
> - #---------------
> - # set new vCPP
> - #---------------
> - $CPP_HASH{'ACKFLAG'}=1;
> - $CPP_HASH{'PSHFLAG'}=0;
> - $CPP_HASH{'SYNFLAG'}=0;
> - $CPP_HASH{'FINFLAG'}=1;
> - $CPP = undef;
> - for my $i (keys %CPP_HASH){
> - $CPP .= "-D$i=$CPP_HASH{$i} ";
> - }
> - vLogHTML("vCPP: $CPP<BR>") if $test_debug;
> - vCPP("$CPP");
> -
> - #-----------------------------------------
> - # receive fin,ack reply or ns from NUT
> - #-----------------------------------------
> - my $match = undef;
> - %ret = vRecvWrapper($IF, 5, 0, 0, 0, @ack_to_host1_esp_s);
> - unless($ret{'recvCount'}){
> - vLogHTML('Cannot receive TCP Fin,Ack Reply.<BR>');
> - $retstat = 'NO_REPLY';
> - return ($retstat, %ret);
> - }
> - foreach my $frames (@ack_to_host1_esp_s){
> - if ($ret{recvFrame} eq $frames) {
> - $match++;
> - last;
> + $fin=$ret{$base_path.'.Hdr_TCP.FINFlag'};
> +
> + if (!$fin) {
> + vLogHTML("Host-1 received Ack SequenceNumber=$seq, AcknowledgmentNumber=$ack from End-Node(NUT).<BR>");
> +
> + #---------------
> + # set new vCPP
> + #---------------
> + $CPP_HASH{'ACKFLAG'}=1;
> + $CPP_HASH{'PSHFLAG'}=0;
> + $CPP_HASH{'SYNFLAG'}=0;
> + $CPP_HASH{'FINFLAG'}=1;
> + $CPP = undef;
> + for my $i (keys %CPP_HASH){
> + $CPP .= "-D$i=$CPP_HASH{$i} ";
> + }
> + vLogHTML("vCPP: $CPP<BR>") if $test_debug;
> + vCPP("$CPP");
> +
> + #-----------------------------------------
> + # receive fin,ack reply or ns from NUT
> + #-----------------------------------------
> + my $match = undef;
> + %ret = vRecvWrapper($IF, 5, 0, 0, 0, @ack_to_host1_esp_s);
> + unless($ret{'recvCount'}){
> + vLogHTML('Cannot receive TCP Fin,Ack Reply.<BR>');
> + $retstat = 'NO_REPLY';
> + return ($retstat, %ret);
> + }
> + foreach my $frames (@ack_to_host1_esp_s){
> + if ($ret{recvFrame} eq $frames) {
> + $match++;
> + last;
> + }
> + }
> + if(!$match){
> + vLogHTML('Cannot receive TCP Fin,Ack Reply.<BR>');
> + $retstat = 'NO_REPLY';
> + return ($retstat, %ret);
> }
> - }
> - if(!$match){
> - vLogHTML('Cannot receive TCP Fin,Ack Reply.<BR>');
> - $retstat = 'NO_REPLY';
> - return ($retstat, %ret);
> - }
>
> - $seq=$ret{$base_path.'.Hdr_TCP.SequenceNumber'};
> - $ack=$ret{$base_path.'.Hdr_TCP.AcknowledgmentNumber'};
> + $seq=$ret{$base_path.'.Hdr_TCP.SequenceNumber'};
> + $ack=$ret{$base_path.'.Hdr_TCP.AcknowledgmentNumber'};
> + }
>
> vLogHTML("Host-1 received Fin, Ack, SequenceNumber=$seq, AcknowledgmentNumber=$ack from End-Node(NUT).<BR>");
>
> --
> 1.5.3.8
>
>
>
>
--
Yukiyo Akisada <akisada@tahi.org>