Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetX Duo Socket Error NX_NOT_CONNECTED due to dropped SYN-ACKs #270

Open
codemonkeyboris opened this issue Apr 17, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@codemonkeyboris
Copy link

Describe the bug
We have a S7G2 Device connected to a Linux PC's ethernet. It is at static ip: 192.168.1.21. The Linux PC has two network interfaces, the WiFi on 10.202.16.196 and the eithernet on 192.168.1.1. The S7G2 device serves a webpage and when we pull it up on the Linux PC, we see the following traffic

image

And this appears to be glitching on the webpage due to the timeout and reset. After that the traffic looks fine and webpage works fine because all the traffice has the source from 192.168.1.1 on the same subnet with the S7G2 deivce.

Please also mention any information which could help others to understand
the problem you're facing:

  • What target device are you using?
    Renesas S7G2.

  • Which version of Eclipse ThreadX?
    6.1.9

  • What toolchain and environment?
    arm-gcc

  • What have you tried to diagnose or workaround this issue?

We did some digging and the problem appears to be when nx_tcp_server_socket_accept is called, we get a error return code: NX_NOT_CONNECTED (0x38). And this is happening when the WiFi interface sends SYN packets to the device from 10.202.16.196. The SYN-ACKs got dropped nx_ip_packet_send because nx_tcp_socket_next_hop_address == 0.

We further found that the we did not configure the gateway in the S7G2 device, which caused the next hop to be empty. If gateway is set to 192.168.1.1 on the device, we won't have this problem. However, we did not have this issue when we were using NetX (not Duo).

So I compared the two and found that in NetX, in nx_ycp_packet_process.c, when nx_ip_route_find is called, it had this piece of code to capture the error and assign the source IP to the next hop:

                    if (_nx_ip_route_find(ip_ptr, source_ip, &socket_ptr -> nx_tcp_socket_connect_interface,
                                          &socket_ptr -> nx_tcp_socket_next_hop_address) != NX_SUCCESS)
                    {
                        /* Cannot determine how to send packets to this TCP peer.  Since we are able to
                           receive the syn, use the incoming interface, and send the packet out directly. */

                        socket_ptr -> nx_tcp_socket_next_hop_address = source_ip;
                    }

And the above code does not exist in NetX Duo anymore.

                    if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V4)
                    {

                        /* Assume the interface that receives the incoming packet is the best interface
                           for sending responses. */
                        socket_ptr -> nx_tcp_socket_connect_interface = interface_ptr;
                        socket_ptr -> nx_tcp_socket_next_hop_address = NX_NULL;

                        /* Set the next hop address.  */
                        _nx_ip_route_find(ip_ptr, *source_ip, &socket_ptr -> nx_tcp_socket_connect_interface,
                                          &socket_ptr -> nx_tcp_socket_next_hop_address);

I put it back and it solved the problem I described above. So I would like to understand the idea behind this to remove it in NetX Duo code. Would it be safe to put it back? What kind of testing should we do to make sure putting this back does not break other functionalities?

Please advise and let me know if you need more information.

Thanks!

@codemonkeyboris codemonkeyboris added the bug Something isn't working label Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant