[conntrack-tools] conntrackd: improve error handling in tcp_send

Pablo Neira netfilter-cvslog-bounces at lists.netfilter.org
Mon Sep 21 12:20:42 CEST 2009


Gitweb:		http://git.netfilter.org/cgi-bin/gitweb.cgi?p=conntrack-tools.git;a=commit;h=81d97cfa2654827029492b23fc11bcb86e8e3912
commit 81d97cfa2654827029492b23fc11bcb86e8e3912
Author:     Pablo Neira Ayuso <pablo at netfilter.org>
AuthorDate: Mon Sep 21 11:24:43 2009 +0200
Commit:     Pablo Neira Ayuso <pablo at netfilter.org>
CommitDate: Mon Sep 21 11:24:43 2009 +0200

    conntrackd: improve error handling in tcp_send
    
    With this patch, we increase the error stats if:
     * we failed to connect to the other peer.
     * some unexpected error made connect() fail.
     * sendto returned ECONNRESET or EPIPE.
    
    Moreover, we propagate the sendto() errors to upper layers
    under failure as Samuel Gauthier suggested.
    
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
       via  81d97cfa2654827029492b23fc11bcb86e8e3912 (commit)
      from  530eed5796faa5fd16c39743a4516bef0e26449c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 81d97cfa2654827029492b23fc11bcb86e8e3912
Author: Pablo Neira Ayuso <pablo at netfilter.org>
Date:   Mon Sep 21 11:24:43 2009 +0200

    conntrackd: improve error handling in tcp_send
    
    With this patch, we increase the error stats if:
     * we failed to connect to the other peer.
     * some unexpected error made connect() fail.
     * sendto returned ECONNRESET or EPIPE.
    
    Moreover, we propagate the sendto() errors to upper layers
    under failure as Samuel Gauthier suggested.
    
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

-----------------------------------------------------------------------

 src/tcp.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
With this patch, we increase the error stats if:
 * we failed to connect to the other peer.
 * some unexpected error made connect() fail.
 * sendto returned ECONNRESET or EPIPE.

Moreover, we propagate the sendto() errors to upper layers
under failure as Samuel Gauthier suggested.

Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

diff --git a/src/tcp.c b/src/tcp.c
index f99c1cb..2b7ca19 100644
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -301,9 +301,11 @@ ssize_t tcp_send(struct tcp_sock *m, const void *data, int size)
 			} else if (errno == ECONNREFUSED) {
 				/* connection refused. */
 				m->state = TCP_CLIENT_DISCONNECTED;
+				m->stats.error++;
 			} else {
 				/* unexpected error, give up. */
 				m->state = TCP_CLIENT_DISCONNECTED;
+				m->stats.error++;
 			}
 			break;
 		} else {
@@ -318,9 +320,10 @@ ssize_t tcp_send(struct tcp_sock *m, const void *data, int size)
 				close(m->fd);
 				tcp_client_init(m, tcp_client_conf);
 				m->state = TCP_CLIENT_DISCONNECTED;
+				m->stats.error++;
 			} else {
 				m->stats.error++;
-				return 0;
+				return -1;
 			}
 		}
 	}



More information about the netfilter-cvslog mailing list