net: tcp: Use our MTU to determine the mss for transmission
In the existing the value received from the other side by the TCP options is used as MSS for transmission. Since the MSS options are an announcement rather then a negotionation, it is likely the receiver will have a different and possibly bigger MSS than allowed by our side. This allow potentially for different a MSS in the receive and transmit path. Directly using the received MSS could cause problems when our MSS is only allowed to be small. At transmission, for that reason take the minimum of the received MSS and our desired MSS to find a value compatible to both sides of the link. Rename the function to net_tcp_get_recv_mss to net_tcp_get_supported_mss to better reflect its function in the new situation. Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
This commit is contained in:
parent
cf59606883
commit
f5679ab73e
|
@ -1468,7 +1468,7 @@ static void tcp_cb(struct tcp *conn, void *user_data)
|
|||
struct net_shell_user_data *data = user_data;
|
||||
const struct shell *shell = data->shell;
|
||||
int *count = data->user_data;
|
||||
uint16_t recv_mss = net_tcp_get_recv_mss(conn);
|
||||
uint16_t recv_mss = net_tcp_get_supported_mss(conn);
|
||||
|
||||
PR("%p %p %5u %5u %10u %10u %5u %s\n",
|
||||
conn, conn->context,
|
||||
|
|
|
@ -836,7 +836,7 @@ static int net_tcp_set_mss_opt(struct tcp *conn, struct net_pkt *pkt)
|
|||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
recv_mss = net_tcp_get_recv_mss(conn);
|
||||
recv_mss = net_tcp_get_supported_mss(conn);
|
||||
recv_mss |= (NET_TCP_MSS_OPT << 24) | (NET_TCP_MSS_SIZE << 16);
|
||||
|
||||
UNALIGNED_PUT(htonl(recv_mss), (uint32_t *)mss);
|
||||
|
@ -2916,7 +2916,7 @@ void net_tcp_foreach(net_tcp_cb_t cb, void *user_data)
|
|||
k_mutex_unlock(&tcp_lock);
|
||||
}
|
||||
|
||||
uint16_t net_tcp_get_recv_mss(const struct tcp *conn)
|
||||
uint16_t net_tcp_get_supported_mss(const struct tcp *conn)
|
||||
{
|
||||
sa_family_t family = net_context_get_family(conn->context);
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ extern "C" {
|
|||
* @return Maximum Segment Size
|
||||
*/
|
||||
#if defined(CONFIG_NET_NATIVE_TCP)
|
||||
uint16_t net_tcp_get_recv_mss(const struct tcp *conn);
|
||||
uint16_t net_tcp_get_supported_mss(const struct tcp *conn);
|
||||
#else
|
||||
static inline uint16_t net_tcp_get_recv_mss(const struct tcp *conn)
|
||||
static inline uint16_t net_tcp_get_supported_mss(const struct tcp *conn)
|
||||
{
|
||||
ARG_UNUSED(conn);
|
||||
return 0;
|
||||
|
|
|
@ -112,7 +112,8 @@
|
|||
|
||||
#define conn_mss(_conn) \
|
||||
((_conn)->recv_options.mss_found ? \
|
||||
(_conn)->recv_options.mss : (uint16_t)NET_IPV6_MTU)
|
||||
MIN((_conn)->recv_options.mss, \
|
||||
net_tcp_get_supported_mss(_conn)) : net_tcp_get_supported_mss(_conn))
|
||||
|
||||
#define conn_state(_conn, _s) \
|
||||
({ \
|
||||
|
|
Loading…
Reference in a new issue