summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-22 10:09:10 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-22 10:09:10 -0600
commit95115e7b88cc4af494e8b41029e709385a59b7ea (patch)
treed10de42f0b973cf01151c7d1c1efa16ec4980a2a
parentfe707e4a546c72263c70be87c5fc5b5a13306075 (diff)
downloadnuttx-95115e7b88cc4af494e8b41029e709385a59b7ea.tar.gz
nuttx-95115e7b88cc4af494e8b41029e709385a59b7ea.tar.bz2
nuttx-95115e7b88cc4af494e8b41029e709385a59b7ea.zip
Armv7-M: Remove Px4-only setting of stack to 0xff. This is incompatible with standard NuttX stack montitoring logic
-rw-r--r--nuttx/arch/arm/src/armv7-m/up_initialstate.c4
-rw-r--r--nuttx/net/socket/net_sendfile.c86
-rw-r--r--nuttx/net/tcp/tcp_appsend.c5
-rw-r--r--nuttx/net/tcp/tcp_send.c6
-rw-r--r--nuttx/net/tcp/tcp_send_buffered.c90
-rw-r--r--nuttx/net/tcp/tcp_send_unbuffered.c86
6 files changed, 216 insertions, 61 deletions
diff --git a/nuttx/arch/arm/src/armv7-m/up_initialstate.c b/nuttx/arch/arm/src/armv7-m/up_initialstate.c
index 1cee97288..f84173845 100644
--- a/nuttx/arch/arm/src/armv7-m/up_initialstate.c
+++ b/nuttx/arch/arm/src/armv7-m/up_initialstate.c
@@ -97,10 +97,6 @@ void up_initial_state(struct tcb_s *tcb)
/* Set the stack limit value */
xcp->regs[REG_R10] = (uint32_t)tcb->stack_alloc_ptr + 64;
-
- /* Fill the stack with a watermark value */
-
- memset(tcb->stack_alloc_ptr, 0xff, tcb->adj_stack_size);
#endif
/* Save the task entry point (stripping off the thumb bit) */
diff --git a/nuttx/net/socket/net_sendfile.c b/nuttx/net/socket/net_sendfile.c
index b64d3d1c9..dbaf66e2a 100644
--- a/nuttx/net/socket/net_sendfile.c
+++ b/nuttx/net/socket/net_sendfile.c
@@ -66,6 +66,7 @@
#include "netdev/netdev.h"
#include "devif/devif.h"
#include "arp/arp.h"
+#include "neighbor/neighbor.h"
#include "tcp/tcp.h"
#include "socket/socket.h"
@@ -233,6 +234,69 @@ static uint16_t ack_interrupt(FAR struct net_driver_s *dev, FAR void *pvconn,
}
/****************************************************************************
+ * Function: sendfile_addrcheck
+ *
+ * Description:
+ * Check if the destination IP address is in the IPv4 ARP or IPv6 Neighbor
+ * tables. If not, then the send won't actually make it out... it will be
+ * replaced with an ARP request (IPv4) or a Neighbor Solicitation (IPv6).
+ *
+ * NOTE 1: This could be an expensive check if there are a lot of
+ * entries in the ARP or Neighbor tables.
+ *
+ * NOTE 2: If we are actually harvesting IP addresses on incoming IP
+ * packets, then this check should not be necessary; the MAC mapping
+ * should already be in the ARP table in many cases (IPv4 only).
+ *
+ * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP
+ * address mapping is already in the ARP table.
+ *
+ * Parameters:
+ * conn - The TCP connection structure
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Running at the interrupt level
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ETHERNET
+static inline bool sendfile_addrcheck(FAR struct tcp_conn_s *conn)
+{
+#ifdef CONFIG_NET_IPv4
+#ifdef CONFIG_NET_IPv6
+ 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;
+#endif
+ }
+#endif /* CONFIG_NET_IPv4 */
+
+#ifdef CONFIG_NET_IPv6
+#ifdef CONFIG_NET_IPv4
+ else
+#endif
+ {
+#if !defined(CONFIG_NET_ICMPv6_SEND)
+ return (neighbor_findentry(conn->u.ipv6.raddr) != NULL);
+#else
+ return true;
+#endif
+ }
+#endif /* CONFIG_NET_IPv6 */
+}
+
+#else /* CONFIG_NET_ETHERNET */
+# sendfile_addrcheck(r) (true)
+#endif /* CONFIG_NET_ETHERNET */
+
+/****************************************************************************
* Function: sendfile_interrupt
*
* Description:
@@ -337,26 +401,12 @@ static uint16_t sendfile_interrupt(FAR struct net_driver_s *dev, FAR void *pvcon
tcp_setsequence(conn->sndseq, seqno);
- /* Check if the destination IP address is in the ARP table. If not,
- * then the send won't actually make it out... it will be replaced with
- * an ARP request.
- *
- * NOTE 1: This could be an expensive check if there are a lot of entries
- * in the ARP table. Hence, we only check on the first packet -- when
- * snd_sent is zero.
- *
- * NOTE 2: If we are actually harvesting IP addresses on incoming IP
- * packets, then this check should not be necessary; the MAC mapping
- * should already be in the ARP table in many cases.
- *
- * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP
- * address mapping is already in the ARP table.
+ /* Check if the destination IP address is in the ARP or Neighbor
+ * table. If not, then the send won't actually make it out... it
+ * will be replaced with an ARP request or Neighbor Solicitation.
*/
-#if defined(CONFIG_NET_ETHERNET) && !defined(CONFIG_NET_ARP_IPIN) && \
- !defined(CONFIG_NET_ARP_SEND)
- if (pstate->snd_sent != 0 || arp_find(conn->u.ipv4.raddr) != NULL)
-#endif
+ if (pstate->snd_sent != 0 || sendfile_addrcheck(conn))
{
/* Update the amount of data sent (but not necessarily ACKed) */
diff --git a/nuttx/net/tcp/tcp_appsend.c b/nuttx/net/tcp/tcp_appsend.c
index a8f93fdd6..7c91636ec 100644
--- a/nuttx/net/tcp/tcp_appsend.c
+++ b/nuttx/net/tcp/tcp_appsend.c
@@ -226,7 +226,7 @@ void tcp_rexmit(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
#endif
{
DEBUGASSERT(IFF_IS_IPv4(dev->d_flags));
- hdrlen = IPv4TCP_HDRLEN;
+ hdrlen = IPv4_HDRLEN;
}
#endif /* CONFIG_NET_IPv4 */
@@ -236,9 +236,10 @@ void tcp_rexmit(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
#endif
{
DEBUGASSERT(IFF_IS_IPv6(dev->d_flags));
- hdrlen = IPv6TCP_HDRLEN;
+ hdrlen = IPv6_HDRLEN;
}
#endif /* CONFIG_NET_IPv6 */
+lldbg("hdrlen=%d\n", hdrlen); // REMOVE ME
/* If the application has data to be sent, or if the incoming packet had
* new data in it, we must send out a packet.
diff --git a/nuttx/net/tcp/tcp_send.c b/nuttx/net/tcp/tcp_send.c
index d9b717846..ae1c573d9 100644
--- a/nuttx/net/tcp/tcp_send.c
+++ b/nuttx/net/tcp/tcp_send.c
@@ -176,7 +176,7 @@ static inline void tcp_ipv4_sendcomplete(FAR struct net_driver_s *dev,
#endif /* CONFIG_NET_IPv4 */
/****************************************************************************
- * Name: tcp_pv6_sendcomplete
+ * Name: tcp_ipv6_sendcomplete
*
* Description:
* Complete the final portions of the send operation. This function sets
@@ -304,7 +304,8 @@ static void tcp_sendcommon(FAR struct net_driver_s *dev,
FAR struct tcp_conn_s *conn,
FAR struct tcp_hdr_s *tcp)
{
- /* Copy the IP address into the IPv6 header */
+ /* Copy the IP address into the IPv6 header */
+lldbg("d_len=%d\n", dev->d_len); // REMOVE ME
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
@@ -386,6 +387,7 @@ void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
uint16_t flags, uint16_t len)
{
FAR struct tcp_hdr_s *tcp = tcp_header(dev);
+lldbg("sndlen=%d len=%d d_len=%d\n", dev->d_sndlen, len, dev->d_len); // REMOVE ME
tcp->flags = flags;
dev->d_len = len;
diff --git a/nuttx/net/tcp/tcp_send_buffered.c b/nuttx/net/tcp/tcp_send_buffered.c
index 7a69c261a..9b9a83f0f 100644
--- a/nuttx/net/tcp/tcp_send_buffered.c
+++ b/nuttx/net/tcp/tcp_send_buffered.c
@@ -72,6 +72,7 @@
#include "socket/socket.h"
#include "netdev/netdev.h"
#include "arp/arp.h"
+#include "neighbor/neighbor.h"
#include "tcp/tcp.h"
#include "devif/devif.h"
@@ -247,6 +248,69 @@ static inline void send_ipselect(FAR struct net_driver_s *dev,
#endif
/****************************************************************************
+ * Function: psock_send_addrchck
+ *
+ * Description:
+ * Check if the destination IP address is in the IPv4 ARP or IPv6 Neighbor
+ * tables. If not, then the send won't actually make it out... it will be
+ * replaced with an ARP request (IPv4) or a Neighbor Solicitation (IPv6).
+ *
+ * NOTE 1: This could be an expensive check if there are a lot of
+ * entries in the ARP or Neighbor tables.
+ *
+ * NOTE 2: If we are actually harvesting IP addresses on incoming IP
+ * packets, then this check should not be necessary; the MAC mapping
+ * should already be in the ARP table in many cases (IPv4 only).
+ *
+ * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP
+ * address mapping is already in the ARP table.
+ *
+ * Parameters:
+ * conn - The TCP connection structure
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Running at the interrupt level
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ETHERNET
+static inline bool psock_send_addrchck(FAR struct tcp_conn_s *conn)
+{
+#ifdef CONFIG_NET_IPv4
+#ifdef CONFIG_NET_IPv6
+ 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;
+#endif
+ }
+#endif /* CONFIG_NET_IPv4 */
+
+#ifdef CONFIG_NET_IPv6
+#ifdef CONFIG_NET_IPv4
+ else
+#endif
+ {
+#if !defined(CONFIG_NET_ICMPv6_SEND)
+ return (neighbor_findentry(conn->u.ipv6.raddr) != NULL);
+#else
+ return true;
+#endif
+ }
+#endif /* CONFIG_NET_IPv6 */
+}
+
+#else /* CONFIG_NET_ETHERNET */
+# psock_send_addrchck(r) (true)
+#endif /* CONFIG_NET_ETHERNET */
+
+/****************************************************************************
* Function: psock_send_interrupt
*
* Description:
@@ -286,6 +350,7 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
FAR sq_entry_t *entry;
FAR sq_entry_t *next;
uint32_t ackno;
+lldbg("TCP_ACKDATA\n"); // REMOVE ME
/* Get the offset address of the TCP header */
@@ -591,6 +656,7 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
if (dev->d_sndlen > 0)
{
/* Another thread has beat us sending data, wait for the next poll */
+lldbg("d_sndlen > 0, ABORTING\n"); // REMOVE ME
return flags;
}
@@ -607,25 +673,12 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
(flags & (TCP_POLL | TCP_REXMIT)) &&
!(sq_empty(&conn->write_q)))
{
- /* Check if the destination IP address is in the ARP table. If not,
- * then the send won't actually make it out... it will be replaced with
- * an ARP request.
- *
- * NOTE 1: This could be an expensive check if there are a lot of
- * entries in the ARP table.
- *
- * NOTE 2: If we are actually harvesting IP addresses on incoming IP
- * packets, then this check should not be necessary; the MAC mapping
- * should already be in the ARP table in many cases.
- *
- * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP
- * address mapping is already in the ARP table.
+ /* Check if the destination IP address is in the ARP or Neighbor
+ * table. If not, then the send won't actually make it out... it
+ * will be replaced with an ARP request or Neighbor Solicitation.
*/
-#if defined(CONFIG_NET_ETHERNET) && !defined(CONFIG_NET_ARP_IPIN) && \
- !defined(CONFIG_NET_ARP_SEND)
- if (arp_find(conn->u.ipv4.raddr) != NULL)
-#endif
+ if (psock_send_addrchck(conn))
{
FAR struct tcp_wrbuffer_s *wrb;
size_t sndlen;
@@ -740,6 +793,9 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
flags &= ~TCP_POLL;
}
+else { // REMOVE ME
+lldbg("NOT sending!!!\n"); // REMOVE ME
+} // REMOVE ME
}
/* Continue waiting */
diff --git a/nuttx/net/tcp/tcp_send_unbuffered.c b/nuttx/net/tcp/tcp_send_unbuffered.c
index e93dbc830..81f608402 100644
--- a/nuttx/net/tcp/tcp_send_unbuffered.c
+++ b/nuttx/net/tcp/tcp_send_unbuffered.c
@@ -60,6 +60,7 @@
#include "netdev/netdev.h"
#include "devif/devif.h"
#include "arp/arp.h"
+#include "neighbor/neighbor.h"
#include "tcp/tcp.h"
#include "socket/socket.h"
@@ -198,6 +199,69 @@ static inline void tcpsend_ipselect(FAR struct net_driver_s *dev,
#endif
/****************************************************************************
+ * Function: psock_send_addrchck
+ *
+ * Description:
+ * Check if the destination IP address is in the IPv4 ARP or IPv6 Neighbor
+ * tables. If not, then the send won't actually make it out... it will be
+ * replaced with an ARP request (IPv4) or a Neighbor Solicitation (IPv6).
+ *
+ * NOTE 1: This could be an expensive check if there are a lot of
+ * entries in the ARP or Neighbor tables.
+ *
+ * NOTE 2: If we are actually harvesting IP addresses on incoming IP
+ * packets, then this check should not be necessary; the MAC mapping
+ * should already be in the ARP table in many cases (IPv4 only).
+ *
+ * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP
+ * address mapping is already in the ARP table.
+ *
+ * Parameters:
+ * conn - The TCP connection structure
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Running at the interrupt level
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ETHERNET
+static inline bool psock_send_addrchck(FAR struct tcp_conn_s *conn)
+{
+#ifdef CONFIG_NET_IPv4
+#ifdef CONFIG_NET_IPv6
+ 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;
+#endif
+ }
+#endif /* CONFIG_NET_IPv4 */
+
+#ifdef CONFIG_NET_IPv6
+#ifdef CONFIG_NET_IPv4
+ else
+#endif
+ {
+#if !defined(CONFIG_NET_ICMPv6_SEND)
+ return (neighbor_findentry(conn->u.ipv6.raddr) != NULL);
+#else
+ return true;
+#endif
+ }
+#endif /* CONFIG_NET_IPv6 */
+}
+
+#else /* CONFIG_NET_ETHERNET */
+# psock_send_addrchck(r) (true)
+#endif /* CONFIG_NET_ETHERNET */
+
+/****************************************************************************
* Function: tcpsend_interrupt
*
* Description:
@@ -466,26 +530,12 @@ static uint16_t tcpsend_interrupt(FAR struct net_driver_s *dev,
devif_send(dev, &pstate->snd_buffer[pstate->snd_sent], sndlen);
- /* Check if the destination IP address is in the ARP table. If not,
- * then the send won't actually make it out... it will be replaced with
- * an ARP request.
- *
- * NOTE 1: This could be an expensive check if there are a lot of entries
- * in the ARP table. Hence, we only check on the first packet -- when
- * snd_sent is zero.
- *
- * NOTE 2: If we are actually harvesting IP addresses on incoming IP
- * packets, then this check should not be necessary; the MAC mapping
- * should already be in the ARP table in many cases.
- *
- * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP
- * address mapping is already in the ARP table.
+ /* Check if the destination IP address is in the ARP or Neighbor
+ * table. If not, then the send won't actually make it out... it
+ * will be replaced with an ARP request or Neighbor Solicitation.
*/
-#if defined(CONFIG_NET_ETHERNET) && !defined(CONFIG_NET_ARP_IPIN) && \
- !defined(CONFIG_NET_ARP_SEND)
- if (pstate->snd_sent != 0 || arp_find(conn->u.ipv4.raddr) != NULL)
-#endif
+ if (pstate->snd_sent != 0 || psock_send_addrchck(conn))
{
/* Update the amount of data sent (but not necessarily ACKed) */