net/tcp: tcp_send_[un]buffered.c: Check routing table in psock_send_addrchck(). Previously only ARP table was considered when determining if the data will actually be sent.

This commit is contained in:
Juho Grundstrom 2018-02-22 16:24:15 -06:00 committed by Gregory Nutt
parent 5f83631a97
commit c065f0fd49
2 changed files with 72 additions and 8 deletions

View File

@ -285,6 +285,7 @@ static inline void send_ipselect(FAR struct net_driver_s *dev,
#ifdef CONFIG_NET_ETHERNET
static inline bool psock_send_addrchck(FAR struct tcp_conn_s *conn)
{
/* Only Ethernet drivers are supported by this function */
/* REVISIT: Could the MAC address not also be in a routing table? */
if (conn->dev->d_lltype != NET_LL_ETHERNET)
@ -297,11 +298,41 @@ static inline bool psock_send_addrchck(FAR struct tcp_conn_s *conn)
if (conn->domain == PF_INET)
#endif
{
#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND)
return (arp_find(conn->u.ipv4.raddr) != NULL);
#else
return true;
/* For historical reasons, we will return true if both the ARP and the
* routing table are disabled.
*/
bool ret = true;
#ifdef CONFIG_NET_ROUTE
in_addr_t router;
#endif
#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND)
if (arp_find(conn->u.ipv4.raddr) != NULL)
{
/* Return true if the address was found in the ARP table */
return true;
}
/* Otherwise, return false */
ret = false;
#endif
#ifdef CONFIG_NET_ROUTE
if (net_ipv4_router(conn->u.ipv4.raddr, &router) == OK)
{
/* Return true if the address was found in the routing table */
return true;
}
/* Otherwise, return false */
ret = false;
#endif
return ret;
}
#endif /* CONFIG_NET_IPv4 */

View File

@ -233,10 +233,13 @@ static inline void tcpsend_ipselect(FAR struct net_driver_s *dev,
#ifdef CONFIG_NET_ETHERNET
static inline bool psock_send_addrchck(FAR struct tcp_conn_s *conn)
{
/* Only Ethernet drivers are supported by this function */
/* REVISIT: Could the MAC address not also be in a routing table? */
if (conn->dev->d_lltype != NET_LL_ETHERNET)
{
/* Return true for non-Ethernet devices. */
return true;
}
@ -245,11 +248,41 @@ static inline bool psock_send_addrchck(FAR struct tcp_conn_s *conn)
if (conn->domain == PF_INET)
#endif
{
#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND)
return (arp_find(conn->u.ipv4.raddr) != NULL);
#else
return true;
/* For historical reasons, we will return true if both the ARP and the
* routing table are disabled.
*/
bool ret = true;
#ifdef CONFIG_NET_ROUTE
in_addr_t router;
#endif
#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND)
if (arp_find(conn->u.ipv4.raddr) != NULL)
{
/* Return true if the address was found in the ARP table */
return true;
}
/* Otherwise, return false */
ret = false;
#endif
#ifdef CONFIG_NET_ROUTE
if (net_ipv4_router(conn->u.ipv4.raddr, &router) == OK)
{
/* Return true if the address was found in the routing table */
return true;
}
/* Otherwise, return false */
ret = false;
#endif
return ret;
}
#endif /* CONFIG_NET_IPv4 */