Skip to content
Permalink
Browse files

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 <patrik.flykt@intel.com>
  • Loading branch information...
Patrik Flykt authored and galak committed Apr 12, 2019
1 parent a3ec56c commit 7e14cff8d70ee1852c011d0b02eb266c27745016
Showing with 15 additions and 15 deletions.
  1. +15 −15 subsys/net/l2/ethernet/ethernet.c
@@ -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;
}
@@ -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) {

0 comments on commit 7e14cff

Please sign in to comment.
You can’t perform that action at this time.