net/icmpv6: Fix an error in the poll logic. It was assume that the input parmeter pvconn was valid. It was not. Instead, the poll logic must work like the sendto() and recvfrom() logic: It must keep a copy of the conn structure in the private data.
This commit is contained in:
parent
bcc61fed26
commit
4629cf9461
@ -427,7 +427,7 @@ void icmpv6_input(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Dispatch the ECHO reply to the waiting thread */
|
||||
|
||||
flags = devif_conn_event(dev, ipicmp, flags, dev->d_conncb);
|
||||
flags = devif_conn_event(dev, NULL, flags, dev->d_conncb);
|
||||
|
||||
/* Was the ECHO reply consumed by any waiting thread? */
|
||||
|
||||
|
@ -59,7 +59,8 @@
|
||||
|
||||
struct icmpv6_poll_s
|
||||
{
|
||||
struct pollfd *fds; /* Needed to handle poll events */
|
||||
FAR struct socket *psock; /* IPPROTO_ICMP6 socket structure */
|
||||
FAR struct pollfd *fds; /* Needed to handle poll events */
|
||||
FAR struct devif_callback_s *cb; /* Needed to teardown the poll */
|
||||
};
|
||||
|
||||
@ -92,7 +93,8 @@ static uint16_t icmpv6_poll_eventhandler(FAR struct net_driver_s *dev,
|
||||
FAR void *pvpriv, uint16_t flags)
|
||||
{
|
||||
FAR struct icmpv6_poll_s *info = (FAR struct icmpv6_poll_s *)pvpriv;
|
||||
FAR struct icmpv6_conn_s *conn = (FAR struct icmpv6_conn_s *)pvconn;
|
||||
FAR struct icmpv6_conn_s *conn;
|
||||
FAR struct socket *psock;
|
||||
pollevent_t eventset;
|
||||
|
||||
ninfo("flags: %04x\n", flags);
|
||||
@ -104,8 +106,21 @@ static uint16_t icmpv6_poll_eventhandler(FAR struct net_driver_s *dev,
|
||||
* sent out on.
|
||||
*/
|
||||
|
||||
if (info != NULL && dev == conn->dev)
|
||||
if (info != NULL)
|
||||
{
|
||||
/* Is this a response on the same device that we sent the request out
|
||||
* on?
|
||||
*/
|
||||
|
||||
psock = info->psock;
|
||||
DEBUGASSERT(psock != NULL && psock->s_conn != NULL);
|
||||
conn = psock->s_conn;
|
||||
if (dev != conn->dev)
|
||||
{
|
||||
ninfo("Wrong device\n");
|
||||
return flags;
|
||||
}
|
||||
|
||||
/* Check for data or connection availability events. */
|
||||
|
||||
eventset = 0;
|
||||
@ -197,6 +212,7 @@ int icmpv6_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
|
||||
|
||||
/* Initialize the poll info container */
|
||||
|
||||
info->psock = psock;
|
||||
info->fds = fds;
|
||||
info->cb = cb;
|
||||
|
||||
|
@ -50,22 +50,6 @@
|
||||
#include "devif/devif.h"
|
||||
#include "icmpv6/icmpv6.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user