summaryrefslogtreecommitdiff
path: root/nuttx/net
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-08-18 13:42:51 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-08-18 13:42:51 -0600
commit2c560fceac3e8d113996f809935c7b088a37a6cb (patch)
tree88ca303f426abc35a221b8235966f7368070a455 /nuttx/net
parentdeb371ec5233020ec1f2a673b43e35b4305add72 (diff)
downloadnuttx-2c560fceac3e8d113996f809935c7b088a37a6cb.tar.gz
nuttx-2c560fceac3e8d113996f809935c7b088a37a6cb.tar.bz2
nuttx-2c560fceac3e8d113996f809935c7b088a37a6cb.zip
PKT sockets: Change how the IFF_NOARP flag is handled. This should be set only when data is moved into the buffer and cleared after tested by the ARP logic. Setting it globally can cause packets to be sent with no valid MAC addresses
Diffstat (limited to 'nuttx/net')
-rw-r--r--nuttx/net/arp/arp_out.c7
-rw-r--r--nuttx/net/pkt/pkt_send.c16
2 files changed, 12 insertions, 11 deletions
diff --git a/nuttx/net/arp/arp_out.c b/nuttx/net/arp/arp_out.c
index 76f9c1fe3..d365dfdc2 100644
--- a/nuttx/net/arp/arp_out.c
+++ b/nuttx/net/arp/arp_out.c
@@ -138,13 +138,16 @@ void arp_out(FAR struct net_driver_s *dev)
in_addr_t ipaddr;
in_addr_t destipaddr;
-#ifdef CONFIG_NET_PKT
+#if defined(CONFIG_NET_PKT) || defined(CONFIG_NET_ARP_SEND)
/* Skip sending ARP requests when the frame to be transmitted was
* written into a packet socket.
*/
- if ((dev->d_flags & IFF_NOARP) == IFF_NOARP)
+ if ((dev->d_flags & IFF_NOARP) != 0)
{
+ /* Clear the indication and let the packet continue on its way. */
+
+ dev->d_flags &= ~IFF_NOARP;
return;
}
#endif
diff --git a/nuttx/net/pkt/pkt_send.c b/nuttx/net/pkt/pkt_send.c
index 8de736086..c136c45a1 100644
--- a/nuttx/net/pkt/pkt_send.c
+++ b/nuttx/net/pkt/pkt_send.c
@@ -101,7 +101,7 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
if (pstate)
{
- /* Check if the outgoing packet is available. If my have been claimed
+ /* Check if the outgoing packet is available. It may have been claimed
* by a send interrupt serving a different thread -OR- if the output
* buffer currently contains unprocessed incoming data. In these cases
* we will just have to wait for the next polling cycle.
@@ -127,6 +127,12 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
devif_pkt_send(dev, pstate->snd_buffer, pstate->snd_buflen);
pstate->snd_sent = pstate->snd_buflen;
+
+ /* Make sure no ARP request overwrites this ARP request. This
+ * flag will be cleared in arp_out().
+ */
+
+ dev->d_flags |= IFF_NOARP;
}
/* Don't allow any further call backs. */
@@ -260,10 +266,6 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
dev = netdev_findbyname("eth0");
- /* Make sure no ARP frame is sent instead of the frame just written */
-
- dev->d_flags |= IFF_NOARP;
-
/* Notify the device driver that new TX data is available.
* NOTES: This is in essence what netdev_txnotify() does, which
* is not possible to call since it expects a net_ipaddr_t as
@@ -283,10 +285,6 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
/* Make sure that no further interrupts are processed */
pkt_callback_free(conn, state.snd_cb);
-
- /* Clear the no-ARP bit in the device flags */
-
- dev->d_flags &= ~IFF_NOARP;
}
}