]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[TCP]: SNMPv2 tcpAttemptFails counter error
authorWei Yongjun <yjwei@nanjing-fnst.com>
Mon, 31 Jul 2006 03:35:54 +0000 (20:35 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 2 Aug 2006 20:38:19 +0000 (13:38 -0700)
Refer to RFC2012, tcpAttemptFails is defined as following:
  tcpAttemptFails OBJECT-TYPE
      SYNTAX      Counter32
      MAX-ACCESS  read-only
      STATUS      current
      DESCRIPTION
              "The number of times TCP connections have made a direct
              transition to the CLOSED state from either the SYN-SENT
              state or the SYN-RCVD state, plus the number of times TCP
              connections have made a direct transition to the LISTEN
              state from the SYN-RCVD state."
      ::= { tcp 7 }

When I lookup into RFC793, I found that the state change should occured
under following condition:
  1. SYN-SENT -> CLOSED
     a) Received ACK,RST segment when SYN-SENT state.

  2. SYN-RCVD -> CLOSED
     b) Received SYN segment when SYN-RCVD state(came from LISTEN).
     c) Received RST segment when SYN-RCVD state(came from SYN-SENT).
     d) Received SYN segment when SYN-RCVD state(came from SYN-SENT).

  3. SYN-RCVD -> LISTEN
     e) Received RST segment when SYN-RCVD state(came from LISTEN).

In my test, those direct state transition can not be counted to
tcpAttemptFails.

Signed-off-by: Wei Yongjun <yjwei@nanjing-fnst.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/tcp.h
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_minisocks.c
net/ipv6/tcp_ipv6.c

index 0720bddff1e9cee11ac9f176b4ef2d59c1356ded..7a093d0aa0fed4642ecdb3637e03ed0bdbb2e234 100644 (file)
@@ -914,6 +914,9 @@ static inline void tcp_set_state(struct sock *sk, int state)
 
 static inline void tcp_done(struct sock *sk)
 {
+       if(sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV)
+               TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS);
+
        tcp_set_state(sk, TCP_CLOSE);
        tcp_clear_xmit_timers(sk);
 
index f6f39e8142917e5a7fa841adaaf096b340c7c1d6..4b04c3edd4a95518a878e294096424c053037912 100644 (file)
@@ -438,7 +438,6 @@ void tcp_v4_err(struct sk_buff *skb, u32 info)
                               It can f.e. if SYNs crossed.
                             */
                if (!sock_owned_by_user(sk)) {
-                       TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS);
                        sk->sk_err = err;
 
                        sk->sk_error_report(sk);
@@ -874,7 +873,6 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
 drop_and_free:
        reqsk_free(req);
 drop:
-       TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS);
        return 0;
 }
 
index 0ccb7cb22b1518a3fc14f4ed2d95829615716753..624e2b2c7f53a737e98197c0928f6eaad4189a86 100644 (file)
@@ -589,8 +589,10 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb,
                /* RFC793: "second check the RST bit" and
                 *         "fourth, check the SYN bit"
                 */
-               if (flg & (TCP_FLAG_RST|TCP_FLAG_SYN))
+               if (flg & (TCP_FLAG_RST|TCP_FLAG_SYN)) {
+                       TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS);
                        goto embryonic_reset;
+               }
 
                /* ACK sequence verified above, just make sure ACK is
                 * set.  If ACK not set, just silently drop the packet.
index b76fd7fba5f5b0cb6a76e6a658c53df86734e5f6..b843a650be7156ba31ee696854b2130b2a6ea0fd 100644 (file)
@@ -427,7 +427,6 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        case TCP_SYN_RECV:  /* Cannot happen.
                               It can, it SYNs are crossed. --ANK */ 
                if (!sock_owned_by_user(sk)) {
-                       TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS);
                        sk->sk_err = err;
                        sk->sk_error_report(sk);                /* Wake people up to see the error (see connect in sock.c) */
 
@@ -831,7 +830,6 @@ drop:
        if (req)
                reqsk_free(req);
 
-       TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS);
        return 0; /* don't send reset */
 }