-
Notifications
You must be signed in to change notification settings - Fork 7k
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
net: ip_k66f: Rework of network stack to support raw sockets when CONFIG_NET_{UDP|TCP} enabled #30934
net: ip_k66f: Rework of network stack to support raw sockets when CONFIG_NET_{UDP|TCP} enabled #30934
Conversation
1d41c93
to
42ef386
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okeyish, we are missing tests to check the functionality. Could you add test(s) to tests/net/socket/af_packet
to check couple of cases:
- we have a packet socket and UDP socket bound, and we receive a UDP packet to bound port (in this case the data should be delivered to both sockets)
- two sockets bound, but UDP is not listening the received data port, in this case only packet socket should receive data
at least these cases should be checked
64625dd
to
9ee0de3
Compare
9ee0de3
to
66ce5e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me.
66ce5e6
to
61145ce
Compare
…ocket The setup_socket() function calls socket() with proto changed to network order. In this case functions with zsock_* prefix are called instead of zpacket_*. The problem is with 'packet_is_supported()' method from sockets_packet.c, which returns false when ETH_P_ALL proto is converted with htons(). This patch fixes this issue by removing the htons() call. Signed-off-by: Lukasz Majewski <lukma@denx.de> Suggested-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The new function - namely conn_raw_socket(); has been introduced to handle raw sockets processing. Its code, up till now, only was executed when IS_ENABLED(CONFIG_NET_SOCKETS_PACKET) was defined. After this change it can be reused when one would like to handle raw sockets also when CONFIG_NET_{UDP|TCP} are enabled. Signed-off-by: Lukasz Majewski <lukma@denx.de>
This patch brings support for AF_PACKET and SOCK_RAW type of sockets. In net_conn_input() function the new flag has been introduced - 'raw_pkt_continue' to indicate if there are other than AF_PACKET connections registered. If we do not have other connections than AF_PACKET, the packet is solely handled in net_conn_input() (or to be more specific in its helper function - conn_raw_socket()). Otherwise, it is passed back to net_conn_input in IPv4/6 processing. Signed-off-by: Lukasz Majewski <lukma@denx.de>
The af_packet test has been augmented to check if sent UDP packet from one port to another (via net interface) is also passed to open SOCK_RAW connection. The test_packet_sockets() function has been reused to setup the SOCK_RAW sockets for this test. It is important to note that the packet is passed to receive part of net stack after being sent. Signed-off-by: Lukasz Majewski <lukma@denx.de>
61145ce
to
7d773e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Lukasz!
After those commits it will be possible to handle raw sockets in user programs when also UDP and TCP support is enabled.
It first moves eligible code to
conn_raw_socket()
new function and afterwards reuses it also when UDP and TCP support isenabled.