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

net: ip_k66f: Rework of network stack to support raw sockets when CONFIG_NET_{UDP|TCP} enabled #30934

Merged

Conversation

lmajewski
Copy link
Collaborator

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 is
enabled.

Copy link
Member

@jukkar jukkar left a 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:

  1. 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)
  2. 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

@lmajewski lmajewski force-pushed the ip_k66f-pr-net-sock-raw-rework branch 2 times, most recently from 64625dd to 9ee0de3 Compare December 22, 2020 09:08
@lmajewski lmajewski requested a review from jukkar December 22, 2020 10:51
@lmajewski lmajewski force-pushed the ip_k66f-pr-net-sock-raw-rework branch from 9ee0de3 to 66ce5e6 Compare January 12, 2021 11:52
@github-actions github-actions bot added the area: Tests Issues related to a particular existing or missing test label Jan 12, 2021
@jukkar jukkar requested a review from rlubos January 13, 2021 08:43
Copy link
Contributor

@rlubos rlubos left a 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.

@jukkar jukkar added this to the v2.5.0 milestone Jan 13, 2021
@lmajewski lmajewski force-pushed the ip_k66f-pr-net-sock-raw-rework branch from 66ce5e6 to 61145ce Compare January 14, 2021 11:16
Lukasz Majewski added 4 commits January 14, 2021 16:13
…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>
@lmajewski lmajewski force-pushed the ip_k66f-pr-net-sock-raw-rework branch from 61145ce to 7d773e3 Compare January 14, 2021 15:15
Copy link
Member

@jukkar jukkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Lukasz!

@jukkar jukkar merged commit 3302896 into zephyrproject-rtos:master Jan 15, 2021
@lmajewski lmajewski deleted the ip_k66f-pr-net-sock-raw-rework branch January 15, 2021 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking area: Tests Issues related to a particular existing or missing test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants