diff options
author | Rohit Grover <rohit.grover@arm.com> | 2016-08-24 10:28:04 +0100 |
---|---|---|
committer | Anas Nashif <nashif@linux.intel.com> | 2016-10-08 21:20:28 +0000 |
commit | 627feb92d4b01556891e232db6b9c9181899965b (patch) | |
tree | 4d35bf25aba41f990685e8ea77864f4c297e8555 /net | |
parent | 02dcceef29375ff188059a96174e8491a6a9b4ab (diff) |
net: fetch valid conn. to determine MSS in data_is_sent_and_acked()
Packets sent out through net_tx_fiber go through psock_send() where
they wait for data_is_sent_and_acked() to process them.
data_is_sent_and_acked() looks at the underlying connection's
MSS (maximum segment size) before putting them on the wire through
uip_send(). The trouble is that that linkage between the outgoing
buffer and the connection hasn't been established at the point
data_is_sent_and_acked() is called--this normally happens through
a call to uip_set_conn().
So data_is_sent_and_acked() fetches an invalid connection handle
and makes its choice using an arbitrary MSS. In my particular case,
this arbitrary value was 0, and so packets weren't being sent out.
Change-Id: I42e8ae104ac20f8df8780c8aee6964ed37113ba0
Signed-off-by: Rohit Grover <rohit.grover@arm.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/ip/contiki/ip/psock.c | 17 | ||||
-rw-r--r-- | net/ip/net_context.c | 1 |
2 files changed, 13 insertions, 5 deletions
diff --git a/net/ip/contiki/ip/psock.c b/net/ip/contiki/ip/psock.c index 1ae215ac4..a343850a7 100644 --- a/net/ip/contiki/ip/psock.c +++ b/net/ip/contiki/ip/psock.c @@ -35,6 +35,7 @@ #include <string.h> #include <net/ip_buf.h> +#include <net/net_context.h> #ifdef CONFIG_NETWORK_IP_STACK_DEBUG_TCP_PSOCK #define DEBUG 1 @@ -152,18 +153,24 @@ data_is_sent_and_acked(CC_REGISTER_ARG struct psock *s) s->sendptr, s->sendlen, uip_mss(s->net_buf)); + struct uip_conn *conn = net_context_get_internal_connection(ip_buf_context(s->net_buf)); + if (!conn) { + s->state = STATE_BLOCKED_SEND; + return 0; + } + if(s->state != STATE_DATA_SENT || uip_rexmit(s->net_buf)) { - if(s->sendlen > uip_mss(s->net_buf)) { - uip_send(s->net_buf, s->sendptr, uip_mss(s->net_buf)); + if(s->sendlen > conn->mss) { + uip_send(s->net_buf, s->sendptr, conn->mss); } else { uip_send(s->net_buf, s->sendptr, s->sendlen); } s->state = STATE_DATA_SENT; return 0; } else if(s->state == STATE_DATA_SENT && uip_acked(s->net_buf)) { - if(s->sendlen > uip_mss(s->net_buf)) { - s->sendlen -= uip_mss(s->net_buf); - s->sendptr += uip_mss(s->net_buf); + if(s->sendlen > conn->mss) { + s->sendlen -= conn->mss; + s->sendptr += conn->mss; } else { s->sendptr += s->sendlen; s->sendlen = 0; diff --git a/net/ip/net_context.c b/net/ip/net_context.c index 3cfcc3969..4d2c63a65 100644 --- a/net/ip/net_context.c +++ b/net/ip/net_context.c @@ -32,6 +32,7 @@ #include <net/net_ip.h> #include <net/net_socket.h> +#include <net/net_context.h> #include "contiki/ip/simple-udp.h" #include "contiki/ipv6/uip-ds6.h" |