Skip to content

Commit

Permalink
net: ethernet: Set NET_ETH_PTYPE_ARP for IPv4 link local packet type
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pfl authored and galak committed Apr 17, 2019
1 parent a3ec56c commit 7e14cff
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions subsys/net/l2/ethernet/ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,6 @@ static bool ethernet_fill_in_dst_on_ipv4_mcast(struct net_pkt *pkt,
static struct net_pkt *ethernet_ll_prepare_on_ipv4(struct net_if *iface,
struct net_pkt *pkt)
{
if (net_pkt_ipv4_auto(pkt)) {
return pkt;
}

if (ethernet_ipv4_dst_is_broadcast_or_mcast(pkt)) {
return pkt;
}
Expand Down Expand Up @@ -520,19 +516,23 @@ static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
net_pkt_family(pkt) == AF_INET) {
struct net_pkt *tmp;

tmp = ethernet_ll_prepare_on_ipv4(iface, pkt);
if (!tmp) {
ret = -ENOMEM;
goto error;
} else if (IS_ENABLED(CONFIG_NET_ARP) && tmp != pkt) {
/* Original pkt got queued and is replaced
* by an ARP request packet.
*/
pkt = tmp;
if (net_pkt_ipv4_auto(pkt)) {
ptype = htons(NET_ETH_PTYPE_ARP);
net_pkt_set_family(pkt, AF_INET);
} else {
ptype = htons(NET_ETH_PTYPE_IP);
tmp = ethernet_ll_prepare_on_ipv4(iface, pkt);
if (!tmp) {
ret = -ENOMEM;
goto error;
} else if (IS_ENABLED(CONFIG_NET_ARP) && tmp != pkt) {
/* Original pkt got queued and is replaced
* by an ARP request packet.
*/
pkt = tmp;
ptype = htons(NET_ETH_PTYPE_ARP);
net_pkt_set_family(pkt, AF_INET);
} else {
ptype = htons(NET_ETH_PTYPE_IP);
}
}
} else if (IS_ENABLED(CONFIG_NET_IPV6) &&
net_pkt_family(pkt) == AF_INET6) {
Expand Down

0 comments on commit 7e14cff

Please sign in to comment.