You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/08/25 14:05:10 UTC
[GitHub] [incubator-nuttx] anchao opened a new pull request, #6923: net: remove pvconn reference from all devif callback
anchao opened a new pull request, #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923
## Summary
net: cleanup pvconn reference to avoid confuse
net: remove pvconn reference from all devif callback
Do not use 'pvconn' argument to get the connection pointer since
pvconn is normally NULL for some events like NETDEV_DOWN.
Instead, the connection pointer can be reliably obtained from the
corresponding private member.
More reference:
https://github.com/apache/incubator-nuttx/pull/5252
https://github.com/apache/incubator-nuttx/pull/5434
## Impact
N/A
## Testing
tcp/udp/usrsock/icmp
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] fjpanag commented on pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
fjpanag commented on PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923#issuecomment-1228380069
@xiaoxiang781216 I have performed some tests, and I used the patch for some time. No issues so far.
Now I have applied the patch on the production firmware and I have left it working. However this will take a lot of time. In a real-world case the issue may appear after days of normal operation.
I suggest to merge this for the moment, and *if* I encounter any problems in the future, I will report back.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923#issuecomment-1229148524
@anchao please take a look.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] fjpanag commented on pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
fjpanag commented on PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923#issuecomment-1228726044
I just had one device crash again.
The original issue of the NULL pointer is indeed resolved, but I believe the new problem is strongly related to the original issue (or maybe this patch).
An assertion fails at `devif_callback.c` at line 85. A callback is double-freed during TCP close.
Here is the call trace:

What may be interesting to you is that the second worker was trying to execute `tcp_close_work()` at the same time, but it was blocked due to the network being locked:

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] PetervdPerk-NXP commented on pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
PetervdPerk-NXP commented on PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923#issuecomment-1227436699
The worst offender was the `struct work_s`.
As you're showing the callback doesn't consume that much memory.
LGTM.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] anchao commented on a diff in pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
anchao commented on code in PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923#discussion_r955589398
##########
net/tcp/tcp_close.c:
##########
@@ -306,13 +303,13 @@ static inline int tcp_close_disconnect(FAR struct socket *psock)
if ((conn->tcpstateflags == TCP_ESTABLISHED ||
conn->tcpstateflags == TCP_LAST_ACK) &&
- (cb = tcp_callback_alloc(conn)) != NULL)
+ (conn->clscb = tcp_callback_alloc(conn)) != NULL)
{
/* Set up to receive TCP data event callbacks */
- cb->flags = (TCP_NEWDATA | TCP_POLL | TCP_DISCONN_EVENTS);
- cb->event = tcp_close_eventhandler;
- cb->priv = cb; /* reference for event handler to free cb */
+ conn->clscb->flags = (TCP_NEWDATA | TCP_POLL | TCP_DISCONN_EVENTS);
Review Comment:
Done!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] anchao commented on a diff in pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
anchao commented on code in PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923#discussion_r955087144
##########
net/udp/udp_recvfrom.c:
##########
@@ -411,7 +411,6 @@ static void udp_terminate(FAR struct udp_recvfrom_s *pstate, int result)
*
* Input Parameters:
* dev The structure of the network driver that generated the event.
- * pvconn The connection structure associated with the socket
Review Comment:
Done
##########
net/icmpv6/icmpv6_netpoll.c:
##########
@@ -61,7 +61,6 @@
****************************************************************************/
static uint16_t icmpv6_poll_eventhandler(FAR struct net_driver_s *dev,
- FAR void *pvconn,
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923#discussion_r955057532
##########
net/tcp/tcp_connect.c:
##########
@@ -149,7 +148,6 @@ static void psock_teardown_callbacks(FAR struct tcp_connect_s *pstate,
*
* Input Parameters:
* dev The structure of the network driver that reported the event
- * pvconn The connection structure associated with the socket
Review Comment:
pvconn->pvpriv
##########
net/icmp/icmp_recvmsg.c:
##########
@@ -93,8 +93,7 @@ struct icmp_recvfrom_s
****************************************************************************/
static uint16_t recvfrom_eventhandler(FAR struct net_driver_s *dev,
- FAR void *pvconn,
Review Comment:
remove line 83
##########
net/tcp/tcp_sendfile.c:
##########
@@ -122,17 +122,8 @@ struct sendfile_s
****************************************************************************/
static uint16_t sendfile_eventhandler(FAR struct net_driver_s *dev,
- FAR void *pvconn, FAR void *pvpriv,
Review Comment:
update line 113
##########
net/tcp/tcp_recvfrom.c:
##########
@@ -363,7 +363,6 @@ static inline void tcp_sender(FAR struct net_driver_s *dev,
*
* Input Parameters:
* dev The structure of the network driver that generated the event.
- * pvconn The connection structure associated with the socket
Review Comment:
pvconn->pvpriv
##########
net/udp/udp_recvfrom.c:
##########
@@ -411,7 +411,6 @@ static void udp_terminate(FAR struct udp_recvfrom_s *pstate, int result)
*
* Input Parameters:
* dev The structure of the network driver that generated the event.
- * pvconn The connection structure associated with the socket
Review Comment:
pvconn->pvpriv
##########
net/icmpv6/icmpv6_netpoll.c:
##########
@@ -61,7 +61,6 @@
****************************************************************************/
static uint16_t icmpv6_poll_eventhandler(FAR struct net_driver_s *dev,
- FAR void *pvconn,
Review Comment:
update line 52
##########
net/tcp/tcp_send_buffered.c:
##########
@@ -311,17 +311,8 @@ static inline void send_ipselect(FAR struct net_driver_s *dev,
****************************************************************************/
static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
- FAR void *pvconn, FAR void *pvpriv,
Review Comment:
update line 302
##########
net/sixlowpan/sixlowpan_send.c:
##########
@@ -98,7 +98,6 @@ struct sixlowpan_send_s
****************************************************************************/
static uint16_t send_eventhandler(FAR struct net_driver_s *dev,
- FAR void *pvconn,
Review Comment:
update line 89
##########
net/tcp/tcp_send_unbuffered.c:
##########
@@ -169,17 +169,8 @@ static inline void tcpsend_ipselect(FAR struct net_driver_s *dev,
****************************************************************************/
static uint16_t tcpsend_eventhandler(FAR struct net_driver_s *dev,
- FAR void *pvconn,
Review Comment:
update line 100
##########
net/icmp/icmp_netpoll.c:
##########
@@ -61,7 +61,6 @@
****************************************************************************/
static uint16_t icmp_poll_eventhandler(FAR struct net_driver_s *dev,
- FAR void *pvconn,
Review Comment:
update line 52
##########
net/icmpv6/icmpv6_recvmsg.c:
##########
@@ -96,8 +96,7 @@ struct icmpv6_recvfrom_s
****************************************************************************/
static uint16_t recvfrom_eventhandler(FAR struct net_driver_s *dev,
- FAR void *pvconn,
Review Comment:
remove line 86
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923#issuecomment-1228314930
@fjpanag do you have the final result?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923#discussion_r955237350
##########
net/tcp/tcp_close.c:
##########
@@ -306,13 +303,13 @@ static inline int tcp_close_disconnect(FAR struct socket *psock)
if ((conn->tcpstateflags == TCP_ESTABLISHED ||
conn->tcpstateflags == TCP_LAST_ACK) &&
- (cb = tcp_callback_alloc(conn)) != NULL)
+ (conn->clscb = tcp_callback_alloc(conn)) != NULL)
{
/* Set up to receive TCP data event callbacks */
- cb->flags = (TCP_NEWDATA | TCP_POLL | TCP_DISCONN_EVENTS);
- cb->event = tcp_close_eventhandler;
- cb->priv = cb; /* reference for event handler to free cb */
+ conn->clscb->flags = (TCP_NEWDATA | TCP_POLL | TCP_DISCONN_EVENTS);
Review Comment:
```suggestion
conn->clscb->flags = TCP_NEWDATA | TCP_POLL | TCP_DISCONN_EVENTS;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] fjpanag commented on pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
fjpanag commented on PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923#issuecomment-1227646430
I am testing this PR, and everything seems to be working correctly.
I did test the snippet that was known to crash the system, and now it seems stable:
```c
sched_lock();
close(sd);
netlib_ifdown("eth0");
sched_unlock();
```
I will update a few devices with this change, to test long-term stability, and will report back if anything bad is observed.
*Testing also included the fix in #6918.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] anchao commented on pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
anchao commented on PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923#issuecomment-1227333175
@PetervdPerk-NXP
https://github.com/apache/incubator-nuttx/pull/6740
Could you please review this PR? since the using pvconn from devif callback will have some risk if netdev shutdown, In this PR, I brought back the "clscb" into tcp_conn_s, and compared the RAM consumption of tcp:
```
./tools/configure.sh spresense/rndis
Without this PR:
$ size nuttx
text data bss dec hex filename
324784 640 45348 370772 5a854 nuttx
With this PR:
$ size nuttx
text data bss dec hex filename
324752 640 45380 370772 5a854 nuttx
```
I do not know if this result is acceptable?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] anchao commented on pull request #6923: net: remove pvconn reference from all devif callback
Posted by GitBox <gi...@apache.org>.
anchao commented on PR #6923:
URL: https://github.com/apache/incubator-nuttx/pull/6923#issuecomment-1229848417
> I just had one device crash again.
@fjpanag
Thanks a lot for your analysis, I have a fix but can not evaluate the side effect, I am not sure if that can resolved your issue.
https://github.com/apache/incubator-nuttx/pull/6947
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org