net: revert tcpip_poll_tcp() to not require a data_buf

tcpip_poll_tcp() was changed with commit 61edc68c to take on a
data_buf parameter, which was then processed as the primary
buffer. That change led to incorrect behaviour where the handling
of the first data buffer on a connection got mixed with the SYN buf.
It is no longer clear why tcpip_poll_tcp() was modified with the
change 61edc68c originally. Reverting the modification to
tcpip_poll_tcp() leads to much better handling of TCP data; and
also obviates another pull-request submitted recently:
https://gerrit.zephyrproject.org/r/#/c/4226.

Change-Id: I947c0991495c538c41e6581c8d360526b1bb89ad
Signed-off-by: Rohit Grover <rohit.grover@arm.com>
This commit is contained in:
Rohit Grover 2016-09-02 10:50:44 +01:00 committed by Anas Nashif
commit 769e2541d1
4 changed files with 14 additions and 23 deletions

View file

@ -224,7 +224,7 @@ packet_input(struct net_buf *buf)
#if UIP_ACTIVE_OPEN
struct uip_conn *
tcp_connect(const uip_ipaddr_t *ripaddr, uint16_t port, void *appstate,
struct process *process, struct net_buf *buf)
struct process *process)
{
struct uip_conn *c;
@ -236,7 +236,7 @@ tcp_connect(const uip_ipaddr_t *ripaddr, uint16_t port, void *appstate,
c->appstate.p = process;
c->appstate.state = appstate;
tcpip_poll_tcp(c, buf);
tcpip_poll_tcp(c);
return c;
}
@ -422,7 +422,7 @@ eventhandler(process_event_t ev, process_data_t data, struct net_buf *buf)
{
if(!buf)
break;
/* Check the clock so see if we should call the periodic uIP
/* Check the clock to see if we should call the periodic uIP
processing. */
if(data == &periodic &&
!etimer_is_triggered(&periodic)) {
@ -840,18 +840,12 @@ tcpip_poll_udp(struct uip_udp_conn *conn)
/*---------------------------------------------------------------------------*/
#if UIP_TCP
void
tcpip_poll_tcp(struct uip_conn *conn, struct net_buf *data_buf)
tcpip_poll_tcp(struct uip_conn *conn)
{
/* We are sending here the initial SYN */
struct net_buf *buf = ip_buf_get_tx(conn->appstate.state);
uip_set_conn(data_buf) = conn;
/* The conn->buf will be freed after we have established the connection,
* sent the message and received an ack to it. This will happen in
* net_core.c:net_send().
*/
conn->buf = ip_buf_ref(data_buf);
uip_set_conn(buf) = conn;
conn->buf = ip_buf_ref(buf);
process_post_synch(&tcpip_process, TCP_POLL, conn, buf);
}

View file

@ -167,8 +167,7 @@ CCIF void tcp_unlisten(uint16_t port, struct process *handler);
*
*/
CCIF struct uip_conn *tcp_connect(const uip_ipaddr_t *ripaddr, uint16_t port,
void *appstate, struct process *process,
struct net_buf *buf);
void *appstate, struct process *process);
/**
* Cause a specified TCP connection to be polled.
@ -181,7 +180,7 @@ CCIF struct uip_conn *tcp_connect(const uip_ipaddr_t *ripaddr, uint16_t port,
* \param conn A pointer to the TCP connection that should be polled.
*
*/
void tcpip_poll_tcp(struct uip_conn *conn, struct net_buf *data_buf);
void tcpip_poll_tcp(struct uip_conn *conn);
void tcpip_resend_syn(struct uip_conn *conn, struct net_buf *buf);

View file

@ -442,7 +442,7 @@ PROCESS_THREAD(tcp, ev, data, buf, user_data)
PROCESS_END();
}
int net_context_tcp_init(struct net_context *context, struct net_buf *buf,
int net_context_tcp_init(struct net_context *context,
enum net_tcp_type tcp_type)
{
if (!context || context->tuple.ip_proto != IPPROTO_TCP) {
@ -491,7 +491,7 @@ int net_context_tcp_init(struct net_context *context, struct net_buf *buf,
tcp_connect((uip_ipaddr_t *)
&context->tuple.remote_addr->in6_addr,
UIP_HTONS(context->tuple.remote_port),
context, &context->tcp, buf);
context, &context->tcp);
#else /* CONFIG_NETWORKING_WITH_IPV6 */
NET_DBG("Connecting to ");
PRINT6ADDR((const uip_ipaddr_t *)&context->tuple.remote_addr->in_addr);
@ -500,7 +500,7 @@ int net_context_tcp_init(struct net_context *context, struct net_buf *buf,
tcp_connect((uip_ipaddr_t *)
&context->tuple.remote_addr->in_addr,
UIP_HTONS(context->tuple.remote_port),
context, &context->tcp, buf);
context, &context->tcp);
#endif /* CONFIG_NETWORKING_WITH_IPV6 */
#endif /* UIP_ACTIVE_OPEN */
}

View file

@ -69,8 +69,7 @@ struct simple_udp_connection *
net_context_get_udp_connection(struct net_context *context);
int net_context_get_receiver_registered(struct net_context *context);
void net_context_set_receiver_registered(struct net_context *context);
int net_context_tcp_init(struct net_context *context, struct net_buf *buf,
enum net_tcp_type);
int net_context_tcp_init(struct net_context *context, enum net_tcp_type);
int net_context_tcp_send(struct net_buf *buf);
void *net_context_get_internal_connection(struct net_context *context);
struct net_buf *net_context_tcp_get_pending(struct net_context *context);
@ -149,8 +148,7 @@ int net_send(struct net_buf *buf)
int status;
uint8_t retry_count;
net_context_tcp_init(ip_buf_context(buf), buf,
NET_TCP_TYPE_CLIENT);
net_context_tcp_init(ip_buf_context(buf), NET_TCP_TYPE_CLIENT);
status = net_context_get_connection_status(
ip_buf_context(buf));
@ -671,7 +669,7 @@ struct net_buf *net_receive(struct net_context *context, int32_t timeout)
break;
case IPPROTO_TCP:
#ifdef CONFIG_NETWORKING_WITH_TCP
ret = net_context_tcp_init(context, NULL, NET_TCP_TYPE_SERVER);
ret = net_context_tcp_init(context, NET_TCP_TYPE_SERVER);
if (ret) {
NET_DBG("TCP connection init failed\n");
ret = -ENOENT;