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>
This commit is contained in:
parent
02dcceef29
commit
627feb92d4
|
@ -20,3 +20,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __NET_CONTEXT_H
|
||||
#define __NET_CONTEXT_H
|
||||
|
||||
void *net_context_get_internal_connection(struct net_context *context);
|
||||
|
||||
#endif /* #ifndef __NET_CONTEXT_H */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue