diff --git a/src/core/tcp.c b/src/core/tcp.c index f20b44a9..8d4af978 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -960,7 +960,7 @@ tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port, The send MSS is updated when an MSS option is received. */ pcb->mss = INITIAL_MSS; #if TCP_CALCULATE_EFF_SEND_MSS - pcb->mss = tcp_eff_send_mss(pcb->mss, &pcb->local_ip, &pcb->remote_ip); + pcb->mss = tcp_eff_send_mss_netif(pcb->mss, netif, &pcb->remote_ip); #endif /* TCP_CALCULATE_EFF_SEND_MSS */ pcb->cwnd = 1; pcb->ssthresh = TCP_WND; @@ -1903,21 +1903,15 @@ tcp_next_iss(struct tcp_pcb *pcb) #if TCP_CALCULATE_EFF_SEND_MSS /** * Calculates the effective send mss that can be used for a specific IP address - * by using ip_route to determine the netif used to send to the address and - * calculating the minimum of TCP_MSS and that netif's mtu (if set). + * by calculating the minimum of TCP_MSS and the mtu (if set) of the target + * netif (if not NULL). */ u16_t -tcp_eff_send_mss_impl(u16_t sendmss, const ip_addr_t *dest -#if LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING - , const ip_addr_t *src -#endif /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */ - ) +tcp_eff_send_mss_netif(u16_t sendmss, struct netif *outif, const ip_addr_t *dest) { u16_t mss_s; - struct netif *outif; s16_t mtu; - outif = ip_route(src, dest); #if LWIP_IPV6 #if LWIP_IPV4 if (IP_IS_V6(dest)) diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c index 108028b2..940fc9fa 100644 --- a/src/core/tcp_out.c +++ b/src/core/tcp_out.c @@ -1216,7 +1216,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif if (seg->flags & TF_SEG_OPTS_MSS) { u16_t mss; #if TCP_CALCULATE_EFF_SEND_MSS - mss = tcp_eff_send_mss(TCP_MSS, &pcb->local_ip, &pcb->remote_ip); + mss = tcp_eff_send_mss_netif(TCP_MSS, netif, &pcb->remote_ip); #else /* TCP_CALCULATE_EFF_SEND_MSS */ mss = TCP_MSS; #endif /* TCP_CALCULATE_EFF_SEND_MSS */ diff --git a/src/include/lwip/priv/tcp_priv.h b/src/include/lwip/priv/tcp_priv.h index 03ebcb63..ffffb977 100644 --- a/src/include/lwip/priv/tcp_priv.h +++ b/src/include/lwip/priv/tcp_priv.h @@ -459,16 +459,10 @@ err_t tcp_zero_window_probe(struct tcp_pcb *pcb); void tcp_trigger_input_pcb_close(void); #if TCP_CALCULATE_EFF_SEND_MSS -u16_t tcp_eff_send_mss_impl(u16_t sendmss, const ip_addr_t *dest -#if LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING - , const ip_addr_t *src -#endif /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */ - ); -#if LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING -#define tcp_eff_send_mss(sendmss, src, dest) tcp_eff_send_mss_impl(sendmss, dest, src) -#else /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */ -#define tcp_eff_send_mss(sendmss, src, dest) tcp_eff_send_mss_impl(sendmss, dest) -#endif /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */ +u16_t tcp_eff_send_mss_netif(u16_t sendmss, struct netif *outif, + const ip_addr_t *dest); +#define tcp_eff_send_mss(sendmss, src, dest) \ + tcp_eff_send_mss_netif(sendmss, ip_route(src, dest), dest) #endif /* TCP_CALCULATE_EFF_SEND_MSS */ #if LWIP_CALLBACK_API