Skip to content

Commit 7e14cff

Browse files
pflgalak
authored andcommitted
net: ethernet: Set NET_ETH_PTYPE_ARP for IPv4 link local packet type
IPv4 link local uses ARP to detect conflicting addresses. Properly set the ethernet packet type to NET_ETH_PTYPE_ARP when probing for address duplicates. Signed-off-by: Patrik Flykt <[email protected]>
1 parent a3ec56c commit 7e14cff

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

subsys/net/l2/ethernet/ethernet.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,6 @@ static bool ethernet_fill_in_dst_on_ipv4_mcast(struct net_pkt *pkt,
293293
static struct net_pkt *ethernet_ll_prepare_on_ipv4(struct net_if *iface,
294294
struct net_pkt *pkt)
295295
{
296-
if (net_pkt_ipv4_auto(pkt)) {
297-
return pkt;
298-
}
299-
300296
if (ethernet_ipv4_dst_is_broadcast_or_mcast(pkt)) {
301297
return pkt;
302298
}
@@ -520,19 +516,23 @@ static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
520516
net_pkt_family(pkt) == AF_INET) {
521517
struct net_pkt *tmp;
522518

523-
tmp = ethernet_ll_prepare_on_ipv4(iface, pkt);
524-
if (!tmp) {
525-
ret = -ENOMEM;
526-
goto error;
527-
} else if (IS_ENABLED(CONFIG_NET_ARP) && tmp != pkt) {
528-
/* Original pkt got queued and is replaced
529-
* by an ARP request packet.
530-
*/
531-
pkt = tmp;
519+
if (net_pkt_ipv4_auto(pkt)) {
532520
ptype = htons(NET_ETH_PTYPE_ARP);
533-
net_pkt_set_family(pkt, AF_INET);
534521
} else {
535-
ptype = htons(NET_ETH_PTYPE_IP);
522+
tmp = ethernet_ll_prepare_on_ipv4(iface, pkt);
523+
if (!tmp) {
524+
ret = -ENOMEM;
525+
goto error;
526+
} else if (IS_ENABLED(CONFIG_NET_ARP) && tmp != pkt) {
527+
/* Original pkt got queued and is replaced
528+
* by an ARP request packet.
529+
*/
530+
pkt = tmp;
531+
ptype = htons(NET_ETH_PTYPE_ARP);
532+
net_pkt_set_family(pkt, AF_INET);
533+
} else {
534+
ptype = htons(NET_ETH_PTYPE_IP);
535+
}
536536
}
537537
} else if (IS_ENABLED(CONFIG_NET_IPV6) &&
538538
net_pkt_family(pkt) == AF_INET6) {

0 commit comments

Comments
 (0)