[PATCH] Fix neighbor discovery ethernet address saving

Vyacheslav V. Mitrofanov v.v.mitrofanov at yadro.com
Sun May 5 11:40:01 CEST 2024


On Mon, 2024-04-29 at 11:51 -0700, seanedmond at linux.microsoft.com
wrote:
> soc at yadro.com<mailto:soc at yadro.com>
> 
> From: Sean Edmond <seanedmond at microsoft.com>
> 
> 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 at microsoft.com>
> ---
>  net/ndisc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ndisc.c b/net/ndisc.c
> index d1cec0601c8..505515f2d95 100644
> --- a/net/ndisc.c
> +++ b/net/ndisc.c
> @@ -461,8 +461,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,
> --
> 2.42.0
> 
Hello, Sean. Thanks for your notice. I see that net_nd_packet_mac is
just a uchar pointer without memory allocation. It is dangerous to do 
memcpy and not necessary. All works as it has to be.


More information about the U-Boot mailing list