From 3a2d0a06f40144d8457622b221a40c22d7e341c8 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 22 Feb 2018 16:41:14 -0600 Subject: [PATCH] net/tcp: Generalize Juho Grundstrom's IPv4 change for IPv6 as well. --- net/tcp/tcp_send_buffered.c | 38 +++++++++++++++++++++++++++++++---- net/tcp/tcp_send_unbuffered.c | 38 +++++++++++++++++++++++++++++++---- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index 829cda78b6b..1d15f33e2ac 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -342,11 +342,41 @@ static inline bool psock_send_addrchck(FAR struct tcp_conn_s *conn) else #endif { -#if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) - return (neighbor_findentry(conn->u.ipv6.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 + net_ipv6addr_t router; #endif + +#if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) + if (neighbor_findentry(conn->u.ipv6.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_ipv6_router(conn->u.ipv6.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_IPv6 */ } diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c index a24c964797b..58ec05fd0f5 100644 --- a/net/tcp/tcp_send_unbuffered.c +++ b/net/tcp/tcp_send_unbuffered.c @@ -292,11 +292,41 @@ static inline bool psock_send_addrchck(FAR struct tcp_conn_s *conn) else #endif { -#if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) - return (neighbor_findentry(conn->u.ipv6.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 + net_ipv6addr_t router; #endif + +#if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) + if (neighbor_findentry(conn->u.ipv6.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_ipv6_router(conn->u.ipv6.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_IPv6 */ }