net: tcp: Fix the TCP client not sending multiple SYN

TCP client only sent one SYN and if that was lost, the connection
was not initiated correctly.

Change-Id: Iebb0b719a3d01d2e4f56ed911b3ed94643e53941
Jira: ZEP-385
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2016-05-20 12:03:32 +03:00
commit 8bd355c49f
2 changed files with 43 additions and 2 deletions

View file

@ -71,6 +71,7 @@ struct net_context {
int connection_status; int connection_status;
void *conn; void *conn;
struct net_buf *pending; struct net_buf *pending;
uint8_t retry_count;
}; };
#endif #endif
}; };
@ -665,3 +666,30 @@ void net_context_tcp_set_pending(struct net_context *context,
context->pending = buf; context->pending = buf;
#endif #endif
} }
void net_context_tcp_set_retry_count(struct net_context *context,
uint8_t count)
{
#if !defined(CONFIG_NETWORKING_WITH_TCP)
return;
#else
if (!context) {
return;
}
context->retry_count = count;
#endif
}
uint8_t net_context_tcp_get_retry_count(struct net_context *context)
{
#if !defined(CONFIG_NETWORKING_WITH_TCP)
return 0;
#else
if (!context) {
return 0;
}
return context->retry_count;
#endif
}

View file

@ -75,6 +75,9 @@ void net_context_tcp_set_pending(struct net_context *context,
void net_context_set_connection_status(struct net_context *context, void net_context_set_connection_status(struct net_context *context,
int status); int status);
void net_context_unset_receiver_registered(struct net_context *context); void net_context_unset_receiver_registered(struct net_context *context);
extern void net_context_tcp_set_retry_count(struct net_context *context,
uint8_t count);
extern uint8_t net_context_tcp_get_retry_count(struct net_context *context);
/* Stacks for the tx & rx fibers. /* Stacks for the tx & rx fibers.
* FIXME: stack size needs fine-tuning * FIXME: stack size needs fine-tuning
@ -119,12 +122,13 @@ int net_send(struct net_buf *buf)
} }
#ifdef CONFIG_NETWORKING_WITH_TCP #ifdef CONFIG_NETWORKING_WITH_TCP
#define MAX_TCP_RETRY_COUNT 5 #define MAX_TCP_RETRY_COUNT 3
if (ip_buf_context(buf) && if (ip_buf_context(buf) &&
net_context_get_tuple(ip_buf_context(buf))->ip_proto == net_context_get_tuple(ip_buf_context(buf))->ip_proto ==
IPPROTO_TCP) { IPPROTO_TCP) {
struct uip_conn *conn; struct uip_conn *conn;
int status; int status;
uint8_t retry_count;
net_context_tcp_init(ip_buf_context(buf), buf, net_context_tcp_init(ip_buf_context(buf), buf,
NET_TCP_TYPE_CLIENT); NET_TCP_TYPE_CLIENT);
@ -159,7 +163,16 @@ int net_send(struct net_buf *buf)
case -EINPROGRESS: case -EINPROGRESS:
NET_DBG("Connection being established\n"); NET_DBG("Connection being established\n");
return status; retry_count = net_context_tcp_get_retry_count(
ip_buf_context(buf));
if (retry_count < MAX_TCP_RETRY_COUNT) {
net_context_tcp_set_retry_count(
ip_buf_context(buf), ++retry_count);
return status;
}
net_context_tcp_set_retry_count(ip_buf_context(buf),
0);
break;
case -ECONNRESET: case -ECONNRESET:
NET_DBG("Connection reset\n"); NET_DBG("Connection reset\n");