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: arp: Add support for gratuitous ARP transmission #71873
Conversation
Temporarily pelase DNM. |
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.
Tested it and it works ok, we just need to add some checks for VLAN interfaces.
subsys/net/l2/ethernet/Kconfig
Outdated
depends on NET_MGMT_EVENT_INFO | ||
|
||
config NET_ARP_GRATUITOUS_INTERVAL | ||
int "Time interval [s] between sending gratuitous ARP requests" |
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.
[s]
is confusing, I actually missed first what it was suppose to mean. Perhaps we could have here or at the end in sec
instead, or have a proper help text that could even mention the relevant RFC https://datatracker.ietf.org/doc/html/rfc5227
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.
I've updated the description.
subsys/net/l2/ethernet/arp.c
Outdated
{ | ||
struct in_addr *ipaddr; | ||
|
||
if (net_if_l2(iface) != &NET_L2_GET_NAME(ETHERNET)) { |
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.
We need to check also if the interface is VLAN one.
@@ -542,7 +542,8 @@ static void iface_event_handler(struct net_mgmt_event_callback *cb,
{
ARG_UNUSED(cb);
- if (net_if_l2(iface) != &NET_L2_GET_NAME(ETHERNET)) {
+ if (!(net_if_l2(iface) == &NET_L2_GET_NAME(ETHERNET) ||
+ net_eth_is_vlan_interface(iface))) {
return;
}
@@ -558,7 +559,8 @@ static void ipv4_event_handler(struct net_mgmt_event_callback *cb,
{
struct in_addr *ipaddr;
- if (net_if_l2(iface) != &NET_L2_GET_NAME(ETHERNET)) {
+ if (!(net_if_l2(iface) == &NET_L2_GET_NAME(ETHERNET) ||
+ net_eth_is_vlan_interface(iface))) {
return;
}
@@ -583,7 +585,8 @@ static void iface_cb(struct net_if *iface, void *user_data)
{
ARG_UNUSED(user_data);
- if (net_if_l2(iface) != &NET_L2_GET_NAME(ETHERNET)) {
+ if (!(net_if_l2(iface) == &NET_L2_GET_NAME(ETHERNET) ||
+ net_eth_is_vlan_interface(iface))) {
return;
}
This requires #71909 which contains the helper function returning this information, I had missed implementing it.
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.
Done
Add support for gratuitous ARP transmission by Zephyr network stack. This allows to prematurely fill the peer ARP table, so there's no need to send an explicit request when peer needs to send an actual packet. The gratuitous ARP is send when the network interface is brought up (joins the network) or a new IP address is added. The gratuitous ARP request is also sent periodically, with a configurable interval time. The gratuitous ARP should also be sent whenever MAC address of the interface is changed, but as Zephyr only allows to do this when interface is down, this is already covered by the first case (interface brought up). Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add you config to the build-all net tests, to make sure everything build properly. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
090a33b
to
813b128
Compare
I've addressed the comments and fixed the build error. |
Passed internal verification, removing DNM. |
Add support for gratuitous ARP transmission by Zephyr network stack.
This allows to prematurely fill the peer ARP table, so there's no need
to send an explicit request when peer needs to send an actual packet.
The gratuitous ARP is send when the network interface is brought up
(joins the network) or a new IP address is added. The gratuitous ARP
request is also sent periodically, with a configurable interval time.
The gratuitous ARP should also be sent whenever MAC address of the
interface is changed, but as Zephyr only allows to do this when
interface is down, this is already covered by the first case (interface
brought up).
Resolves #57839