-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Support multiple IPv4 netmasks per interface #68419
Support multiple IPv4 netmasks per interface #68419
Conversation
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 good, thanks, howerver we should get rid of those now deprecated functions usage within the codebase.
One of the users is recently added DHCPv4 server:
https://github.com/zephyrproject-rtos/zephyr/blob/main/subsys/net/lib/dhcpv4/dhcpv4_server.c#L1234
but in this particular case it should be straightforward fix, just take the netmask for the selected server_addr
.
e2b8dc5
to
2777801
Compare
2777801
to
6cc20ca
Compare
b780dea
to
51052ef
Compare
7dc45fa
to
ed8ccb1
Compare
The netmask should be tied to the IPv4 address instead of being global for the network interface. If there is only one IPv4 address specified to the network interface, nothing changes from user point of view. But if there are more than one IPv4 address / network interface, the netmask must be specified to each address separately. This means that net_if_ipv4_get_netmask() and net_if_ipv4_set_netmask() functions should not be used as they only work reliably if there is only one IPv4 address in the network interface. The new net_if_ipv4_get_netmask_by_addr() and net_if_ipv4_set_netmask_by_addr() functions should be used as they make sure that the netmask is tied to correct IPv4 address in the network interface. Signed-off-by: Jukka Rissanen <[email protected]>
Make sure that the tests work properly when each IPv4 address in the network interface gets its own netmask. Signed-off-by: Jukka Rissanen <[email protected]>
This commit deprecates these legacy netmask get/set routines net_if_ipv4_set_netmask() net_if_ipv4_set_netmask_by_index() net_if_ipv4_get_netmask() as they do not work well if there are multiple IPv4 address assigned to the network interface. User should use these functions instead net_if_ipv4_set_netmask_by_addr() net_if_ipv4_set_netmask_by_addr_by_index() net_if_ipv4_get_netmask_by_addr() as they make sure the netmask it bound to correct IPv4 address. Signed-off-by: Jukka Rissanen <[email protected]>
Make sure that the drivers use the new IPv4 netmask setting API. Signed-off-by: Jukka Rissanen <[email protected]>
Make sure that the samples use the new IPv4 netmask setting API. Signed-off-by: Jukka Rissanen <[email protected]>
Convert various array loops in the net_if.c to use the ARRAY_FOR_EACH() macro. This makes the code more robust as we do not need to keep track of the separate define that tells the array size. Signed-off-by: Jukka Rissanen <[email protected]>
No need to loop through network interface addresses, just listen DHCPv4 bound event and use that as a condition to continue. Signed-off-by: Jukka Rissanen <[email protected]>
Convert various networking subsystem files to use ARRAY_FOR_EACH macro to make the looping more robust. Signed-off-by: Jukka Rissanen <[email protected]>
ed8ccb1
to
c2f238c
Compare
Setting milestone as 3.7 as we are past the RC1 for 3.6. Please correct the milestone if you disagree |
The netmask should be tied to the IPv4 address instead of being global for the network interface.
If there is only one IPv4 address specified to the network interface, nothing changes from user point of view. But if there are more than one IPv4 address / network interface, the netmask must be specified to each address separately.
This means that the
net_if_ipv4_get_netmask()
andnet_if_ipv4_set_netmask()
functions should not be used as they will only work reliably if there is only one IPv4 address in the network interface.Instead new
net_if_ipv4_get_netmask_by_addr()
andnet_if_ipv4_set_netmask_by_addr()
should be used instead as they make sure that the netmask is tied to correct IPv4 address in the network interface.No need to try to rush and try to get this to 3.6, existing functionality works for most of the use cases.