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: ethernet: Only try ARP for IP packets #84158

Merged
merged 7 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions subsys/net/ip/ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,6 @@ enum net_verdict net_ipv4_input(struct net_pkt *pkt, bool is_loopback)

enum net_verdict net_ipv4_prepare_for_send(struct net_pkt *pkt)
{
net_pkt_set_ll_proto_type(pkt, NET_ETH_PTYPE_IP);

if (IS_ENABLED(CONFIG_NET_IPV4_PMTU)) {
struct net_pmtu_entry *entry;
struct sockaddr_in dst = {
Expand Down
9 changes: 6 additions & 3 deletions subsys/net/l2/ethernet/arp.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ static struct arp_entry *arp_entry_find(sys_slist_t *list,

if (entry->iface == iface &&
net_ipv4_addr_cmp(&entry->ip, dst)) {
NET_DBG("found dst %s",
net_sprint_ipv4_addr(dst));

return entry;
}

Expand Down Expand Up @@ -463,7 +466,7 @@ struct net_pkt *net_arp_prepare(struct net_pkt *pkt,
NET_DBG("ARP using ll %s for IP %s",
net_sprint_ll_addr(net_pkt_lladdr_dst(pkt)->addr,
sizeof(struct net_eth_addr)),
net_sprint_ipv4_addr(&NET_IPV4_HDR(pkt)->dst));
net_sprint_ipv4_addr(NET_IPV4_HDR(pkt)->dst));

return pkt;
}
Expand Down Expand Up @@ -691,10 +694,10 @@ void net_arp_update(struct net_if *iface,
net_pkt_lladdr_dst(pkt)->addr =
(uint8_t *) &NET_ETH_HDR(pkt)->dst.addr;

NET_DBG("iface %d (%p) dst %s pending %p frag %p",
NET_DBG("iface %d (%p) dst %s pending %p frag %p ptype 0x%04x",
net_if_get_by_iface(iface), iface,
net_sprint_ipv4_addr(&entry->ip),
pkt, pkt->frags);
pkt, pkt->frags, net_pkt_ll_proto_type(pkt));

/* We directly send the packet without first queueing it.
* The pkt has already been queued for sending, once by
Expand Down
3 changes: 2 additions & 1 deletion subsys/net/l2/ethernet/ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,8 @@ static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
goto send;
}

if (IS_ENABLED(CONFIG_NET_IPV4) && net_pkt_family(pkt) == AF_INET) {
if (IS_ENABLED(CONFIG_NET_IPV4) && net_pkt_family(pkt) == AF_INET &&
net_pkt_ll_proto_type(pkt) == NET_ETH_PTYPE_IP) {
if (!net_pkt_ipv4_acd(pkt)) {
struct net_pkt *tmp;

Expand Down
3 changes: 0 additions & 3 deletions tests/net/arp/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,6 @@ ZTEST(arp_fn_tests, test_arp)

net_pkt_unref(pkt);

/* Clear the ARP cache so that old entries do not confuse the tests */
net_arp_clear_cache(iface);

/* Then feed in ARP request */
pkt = net_pkt_alloc_with_buffer(iface, sizeof(struct net_eth_hdr) +
sizeof(struct net_arp_hdr),
Expand Down
Loading