Skip to content

Commit

Permalink
net/icmp: Save poll device in icmp_poll_s
Browse files Browse the repository at this point in the history
ICMP's conn->dev is changing in icmp_sendmsg, when sending to different
address, or when error occurs (like NETDEV_DOWN). Then the poll callback
cannot be dropped from previous dev in free, because the dev is wrong.

So add dev to struct icmp_poll_s just like struct udp_poll_s.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
  • Loading branch information
wengzhe committed Jun 6, 2023
1 parent c1bcf59 commit 53d7a8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions net/icmp/icmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct devif_callback_s; /* Forward reference */
struct icmp_poll_s
{
FAR struct socket *psock; /* IPPROTO_ICMP socket structure */
FAR struct net_driver_s *dev; /* Needed to free the callback structure */
FAR struct pollfd *fds; /* Needed to handle poll events */
FAR struct devif_callback_s *cb; /* Needed to teardown the poll */
};
Expand Down
3 changes: 2 additions & 1 deletion net/icmp/icmp_netpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
/* Initialize the poll info container */

info->psock = psock;
info->dev = conn->dev;
info->fds = fds;
info->cb = cb;

Expand Down Expand Up @@ -272,7 +273,7 @@ int icmp_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds)
{
/* Release the callback */

icmp_callback_free(conn->dev, conn, info->cb);
icmp_callback_free(info->dev, conn, info->cb);

/* Release the poll/select data slot */

Expand Down

0 comments on commit 53d7a8b

Please sign in to comment.