Skip to content

Commit

Permalink
Networking: Apply the same ARP fix for the Neighbor Solicitation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-nutt committed Feb 2, 2015
1 parent e4c6027 commit bba3fcc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
7 changes: 4 additions & 3 deletions net/icmpv6/icmpv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ int icmpv6_wait_cancel(FAR struct icmpv6_notify_s *notify);
* received, or (2) a timeout occurs.
*
* Assumptions:
* This function is called from icmpv6_neighbor() and executes in the normal
* tasking environment.
* This function is called from icmpv6_neighbor() and must execute with
* the network un-locked (interrupts may be disabled to keep the things
* stable).
*
****************************************************************************/

Expand All @@ -283,7 +284,7 @@ int icmpv6_wait(FAR struct icmpv6_notify_s *notify,
*
* Assumptions:
* This function is called from the MAC device driver indirectly through
* icmpv6_icmpv6in() and may be execute from the interrupt level.
* icmpv6_icmpv6in() will execute with the network locked.
*
****************************************************************************/

Expand Down
12 changes: 12 additions & 0 deletions net/icmpv6/icmpv6_neighbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr)
struct timespec delay;
struct icmpv6_neighbor_s state;
FAR const uint16_t *lookup;
#ifdef CONFIG_NET_NOINTS
irqstate_t flags;
#endif
net_lock_t save;
int ret;

Expand Down Expand Up @@ -376,12 +379,21 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr)

/* Now wait for response to the ARP response to be received. The
* optimal delay would be the work case round trip time.
* NOTE: The network is locked.
*/

delay.tv_sec = CONFIG_ICMPv6_NEIGHBOR_DELAYSEC;
delay.tv_nsec = CONFIG_ICMPv6_NEIGHBOR_DELAYNSEC;

#ifdef CONFIG_NET_NOINTS
flags = irqsave(); /* Keep things stable */
net_unlock(save); /* Unlock the network with interrupts disabled */
#endif
ret = icmpv6_wait(&notify, &delay);
#ifdef CONFIG_NET_NOINTS
save = net_lock(); /* Re-lock the network with interrupts disabled */
irqrestore(flags);
#endif

/* icmpv6_wait will return OK if and only if the matching ARP response
* is received. Otherwise, it will return -ETIMEDOUT.
Expand Down
7 changes: 4 additions & 3 deletions net/icmpv6/icmpv6_notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ int icmpv6_wait_cancel(FAR struct icmpv6_notify_s *notify)
* received, or (2) a timeout occurs.
*
* Assumptions:
* This function is called from icmpv6_neighbor() and executes in the normal
* tasking environment.
* This function is called from icmpv6_neighbor() and must execute with
* the network un-locked (interrupts may be disabled to keep the things
* stable).
*
****************************************************************************/

Expand Down Expand Up @@ -225,7 +226,7 @@ int icmpv6_wait(FAR struct icmpv6_notify_s *notify,
*
* Assumptions:
* This function is called from the MAC device driver indirectly through
* icmpv6_icmpv6in() and may be execute from the interrupt level.
* icmpv6_icmpv6in() will execute with the network locked.
*
****************************************************************************/

Expand Down

0 comments on commit bba3fcc

Please sign in to comment.