net: tcp: Precompute appdata properly
TCP packets need the computed packet length early so they can fill in a correct sequence number in their generated ACKs. Waiting for packet_received() is too late. Precompute it before needed, and skip the evaluation later. Change-Id: I25547009f88277e0042c74f2005a141819797886 Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
02174b8e0f
commit
3a8b73067d
1 changed files with 16 additions and 6 deletions
|
@ -56,6 +56,10 @@ enum net_verdict packet_received(struct net_conn *conn,
|
|||
struct net_buf *buf,
|
||||
void *user_data);
|
||||
|
||||
static void set_appdata_values(struct net_buf *buf,
|
||||
enum net_ip_protocol proto,
|
||||
size_t total_len);
|
||||
|
||||
#if defined(CONFIG_NET_TCP)
|
||||
static struct sockaddr *create_sockaddr(struct net_buf *buf,
|
||||
struct sockaddr *addr)
|
||||
|
@ -769,6 +773,7 @@ static enum net_verdict tcp_established(struct net_conn *conn,
|
|||
return NET_DROP;
|
||||
}
|
||||
|
||||
set_appdata_values(buf, IPPROTO_TCP, net_buf_frags_len(buf));
|
||||
context->tcp->send_ack += net_nbuf_appdatalen(buf);
|
||||
|
||||
ret = packet_received(conn, buf, user_data);
|
||||
|
@ -1822,12 +1827,17 @@ enum net_verdict packet_received(struct net_conn *conn,
|
|||
if (context->recv_cb) {
|
||||
size_t total_len = net_buf_frags_len(buf);
|
||||
|
||||
if (net_nbuf_family(buf) == AF_INET6) {
|
||||
set_appdata_values(buf, NET_IPV6_BUF(buf)->nexthdr,
|
||||
total_len);
|
||||
} else {
|
||||
set_appdata_values(buf, NET_IPV4_BUF(buf)->proto,
|
||||
total_len);
|
||||
/* TCP packets get appdata earlier in tcp_established() */
|
||||
if (net_context_get_ip_proto(context) != IPPROTO_TCP) {
|
||||
if (net_nbuf_family(buf) == AF_INET6) {
|
||||
set_appdata_values(buf,
|
||||
NET_IPV6_BUF(buf)->nexthdr,
|
||||
total_len);
|
||||
} else {
|
||||
set_appdata_values(buf,
|
||||
NET_IPV4_BUF(buf)->proto,
|
||||
total_len);
|
||||
}
|
||||
}
|
||||
|
||||
NET_DBG("Set appdata to %p len %u (total %zu)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue