-
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: arp: Fix ARP protocol handler to not use Ethernet hdr directly #85955
Conversation
@@ -787,14 +787,6 @@ enum net_verdict net_arp_input(struct net_pkt *pkt, | |||
struct net_pkt *reply; | |||
struct in_addr *addr; | |||
|
|||
if (net_pkt_get_len(pkt) < (sizeof(struct net_arp_hdr) - |
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.
Is it ok to drop the length check though? I think we should still verify the packet length before accessing the ARP header. It could be simplified to just net_pkt_get_len(pkt) < (sizeof(struct net_arp_hdr)
I believe.
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 dropped it because it would not work any more, but I suppose we can add at least that ARP header len check there.
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.
Nice patch.
Just an idea:
net_arp_input
only uses ð_hdr->dst
and ð_hdr->src
. They could use net_pkt_lladdr_dst(pkt)
and net_pkt_lladdr_src(pkt)
directly instead, so we need not pass the header as separate pointer?
Note it is also passed to arp_prepare_reply
and then unused there. We can probably just remove it there.
9efbd06
to
6d46adc
Compare
|
The ARP protocol handler cannot directly access the Ethernet header because the caller has removed the header already when the handler is called. So change net_arp_input() and pass source and destination MAC address there instead of bogus pointer that was pointing to ARP header instead of Ethernet header. This requires changes to ARP tests. Signed-off-by: Jukka Rissanen <[email protected]>
6d46adc
to
8310457
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.
lgtm as far as I can tell.
The ARP protocol handler cannot directly access the Ethernet header because the caller has removed the header already when the handler is called.