Skip to content

Commit

Permalink
net: ethernet: Fix the multicast IPv4 to MAC address mapping
Browse files Browse the repository at this point in the history
The IPv4 multicast address to MAC address mapping was missing
the 4th byte high bit clearing.

We also need to have some storage for the multicast MAC address.
This was missing which could cause NULL pointer access.

Signed-off-by: Jukka Rissanen <[email protected]>
  • Loading branch information
jukkar authored and Anas Nashif committed Sep 17, 2017
1 parent af63ae2 commit 91041f9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions subsys/net/ip/l2/ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ static inline bool check_if_dst_is_broadcast_or_mcast(struct net_if *iface,
hdr->dst.addr[4] = NET_IPV4_HDR(pkt)->dst.s4_addr[2];
hdr->dst.addr[5] = NET_IPV4_HDR(pkt)->dst.s4_addr[3];

hdr->dst.addr[3] = hdr->dst.addr[3] & 0x7f;

net_pkt_ll_dst(pkt)->len = sizeof(struct net_eth_addr);
net_pkt_ll_src(pkt)->addr = net_if_get_link_addr(iface)->addr;
net_pkt_ll_src(pkt)->len = sizeof(struct net_eth_addr);
Expand All @@ -192,6 +194,9 @@ static enum net_verdict ethernet_send(struct net_if *iface,
struct net_pkt *arp_pkt;

if (check_if_dst_is_broadcast_or_mcast(iface, pkt)) {
struct net_eth_addr *dst = &NET_ETH_HDR(pkt)->dst;

net_pkt_ll_dst(pkt)->addr = (u8_t *)dst->addr;
goto setup_hdr;
}

Expand Down

0 comments on commit 91041f9

Please sign in to comment.