diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-09-21 11:24:43 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-09-21 11:24:43 +0200 |
commit | 81d97cfa2654827029492b23fc11bcb86e8e3912 (patch) | |
tree | 29f3dc0cf66183eb6dac9680ff86a3cf7afc37b9 /src/tcp.c | |
parent | 530eed5796faa5fd16c39743a4516bef0e26449c (diff) | |
download | conntrack-tools-81d97cfa2654827029492b23fc11bcb86e8e3912.tar.gz conntrack-tools-81d97cfa2654827029492b23fc11bcb86e8e3912.zip |
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@netfilter.org>
Diffstat (limited to 'src/tcp.c')
-rw-r--r-- | src/tcp.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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; } } } |