Skip to content

Commit e8824c7

Browse files
committed
net: ethernet: Fix the multicast IPv4 to MAC address mapping
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]>
1 parent 45e4b83 commit e8824c7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

subsys/net/ip/l2/ethernet.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ static inline bool check_if_dst_is_broadcast_or_mcast(struct net_if *iface,
170170
hdr->dst.addr[4] = NET_IPV4_HDR(pkt)->dst.s4_addr[2];
171171
hdr->dst.addr[5] = NET_IPV4_HDR(pkt)->dst.s4_addr[3];
172172

173+
hdr->dst.addr[3] = hdr->dst.addr[3] & 0x7f;
174+
173175
net_pkt_ll_dst(pkt)->len = sizeof(struct net_eth_addr);
174176
net_pkt_ll_src(pkt)->addr = net_if_get_link_addr(iface)->addr;
175177
net_pkt_ll_src(pkt)->len = sizeof(struct net_eth_addr);
@@ -192,6 +194,9 @@ static enum net_verdict ethernet_send(struct net_if *iface,
192194
struct net_pkt *arp_pkt;
193195

194196
if (check_if_dst_is_broadcast_or_mcast(iface, pkt)) {
197+
struct net_eth_addr *dst = &NET_ETH_HDR(pkt)->dst;
198+
199+
net_pkt_ll_dst(pkt)->addr = (u8_t *)dst->addr;
195200
goto setup_hdr;
196201
}
197202

0 commit comments

Comments
 (0)