Fix neighbor discovery ethernet address saving
authorSean Edmond <seanedmond@microsoft.com>
Mon, 29 Apr 2024 18:51:16 +0000 (11:51 -0700)
committerTom Rini <trini@konsulko.com>
Wed, 1 Jan 2025 20:40:04 +0000 (14:40 -0600)
When a successful neighbor advertisement is received, the ethernet
address should be saved for later use to avoid having to redo the
neighbor discovery process.

For example, with TFTP the address should get saved into
"net_server_ethaddr".  This is being done correctly with ARP for IPv4,
but not for neighbor discovery with IPv6.

Signed-off-by: Sean Edmond <seanedmond@microsoft.com>
Reviewed-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
net/ndisc.c

index d417c59..641cf6d 100644 (file)
@@ -460,8 +460,8 @@ int ndisc_receive(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len)
                        ndisc_extract_enetaddr(ndisc, neigh_eth_addr);
 
                        /* save address for later use */
-                       if (!net_nd_packet_mac)
-                               net_nd_packet_mac = neigh_eth_addr;
+                       if (net_nd_packet_mac)
+                               memcpy(net_nd_packet_mac, neigh_eth_addr, 6);
 
                        /* modify header, and transmit it */
                        memcpy(((struct ethernet_hdr *)net_nd_tx_packet)->et_dest,