public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] net: dhcp6: Send DHCPv6 using multicast MAC
@ 2025-01-27 22:06 seanedmond
  2025-03-04 19:40 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: seanedmond @ 2025-01-27 22:06 UTC (permalink / raw)
  To: u-boot; +Cc: joe.hershberger, rfried.dev, trini

From: Sean Edmond <seanedmond@microsoft.com>

In IPv6, the broadcast MAC address is not used.  Instead, it should use
the multicast address (see RFC RFC2464).

Signed-off-by: Sean Edmond <seanedmond@microsoft.com>
---
 net/dhcpv6.c | 12 ++++++------
 net/dhcpv6.h |  8 +++++++-
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/net/dhcpv6.c b/net/dhcpv6.c
index 54619ee6983..984a64a4ff3 100644
--- a/net/dhcpv6.c
+++ b/net/dhcpv6.c
@@ -29,6 +29,10 @@
 int updated_sol_max_rt_ms = SOL_MAX_RT_MS;
 /* state machine parameters/variables */
 struct dhcp6_sm_params sm_params;
+/* DHCPv6 all server IP6 address */
+const struct in6_addr dhcp_mcast_ip6 = DHCP6_MULTICAST_ADDR;
+/* IPv6 multicast ethernet address */
+const u8 net_dhcp6_mcast_ethaddr[6] = IPV6_ALL_NODE_ETH_ADDR(dhcp_mcast_ip6);
 
 static void dhcp6_state_machine(bool timeout, uchar *rx_pkt, unsigned int len);
 
@@ -171,7 +175,6 @@ static int dhcp6_add_option(int option_id, uchar *pkt)
  */
 static void dhcp6_send_solicit_packet(void)
 {
-	struct in6_addr dhcp_bcast_ip6;
 	int len = 0;
 	uchar *pkt;
 	uchar *dhcp_pkt_start_ptr;
@@ -200,9 +203,8 @@ static void dhcp6_send_solicit_packet(void)
 	len = pkt - dhcp_pkt_start_ptr;
 
 	/* send UDP packet to DHCP6 multicast address */
-	string_to_ip6(DHCP6_MULTICAST_ADDR, sizeof(DHCP6_MULTICAST_ADDR), &dhcp_bcast_ip6);
 	net_set_udp_handler(dhcp6_handler);
-	net_send_udp_packet6((uchar *)net_bcast_ethaddr, &dhcp_bcast_ip6,
+	net_send_udp_packet6((uchar *)net_dhcp6_mcast_ethaddr, (struct in6_addr *)&dhcp_mcast_ip6,
 			     PORT_DHCP6_S, PORT_DHCP6_C, len);
 }
 
@@ -218,7 +220,6 @@ static void dhcp6_send_solicit_packet(void)
  */
 static void dhcp6_send_request_packet(void)
 {
-	struct in6_addr dhcp_bcast_ip6;
 	int len = 0;
 	uchar *pkt;
 	uchar *dhcp_pkt_start_ptr;
@@ -252,9 +253,8 @@ static void dhcp6_send_request_packet(void)
 	len = pkt - dhcp_pkt_start_ptr;
 
 	/* send UDP packet to DHCP6 multicast address */
-	string_to_ip6(DHCP6_MULTICAST_ADDR, strlen(DHCP6_MULTICAST_ADDR), &dhcp_bcast_ip6);
 	net_set_udp_handler(dhcp6_handler);
-	net_send_udp_packet6((uchar *)net_bcast_ethaddr, &dhcp_bcast_ip6,
+	net_send_udp_packet6((uchar *)net_dhcp6_mcast_ethaddr, (struct in6_addr *)&dhcp_mcast_ip6,
 			     PORT_DHCP6_S, PORT_DHCP6_C, len);
 }
 
diff --git a/net/dhcpv6.h b/net/dhcpv6.h
index 65c8e4c71d3..d41a3c30615 100644
--- a/net/dhcpv6.h
+++ b/net/dhcpv6.h
@@ -40,7 +40,13 @@
 /* vendor-class-data to send in vendor clas option */
 #define DHCP6_VCI_STRING	"U-Boot"
 
-#define DHCP6_MULTICAST_ADDR	"ff02::1:2"	/* DHCP multicast address */
+/*
+ * All-DHCPv6 server multicast address
+ */
+#define DHCP6_MULTICAST_ADDR { { { 0xFF, 0x02, 0x00, 0x00, \
+								   0x00, 0x00, 0x00, 0x00, \
+								   0x00, 0x00, 0x00, 0x00, \
+								   0x00, 0x01, 0x00, 0x02 } } }
 
 /* DHCP6 States supported */
 enum dhcp6_state {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: dhcp6: Send DHCPv6 using multicast MAC
  2025-01-27 22:06 [PATCH] net: dhcp6: Send DHCPv6 using multicast MAC seanedmond
@ 2025-03-04 19:40 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2025-03-04 19:40 UTC (permalink / raw)
  To: seanedmond; +Cc: u-boot, joe.hershberger, rfried.dev

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

On Mon, Jan 27, 2025 at 02:06:13PM -0800, seanedmond@linux.microsoft.com wrote:

> From: Sean Edmond <seanedmond@microsoft.com>
> 
> In IPv6, the broadcast MAC address is not used.  Instead, it should use
> the multicast address (see RFC RFC2464).
> 
> Signed-off-by: Sean Edmond <seanedmond@microsoft.com>
> ---
>  net/dhcpv6.c | 12 ++++++------
>  net/dhcpv6.h |  8 +++++++-
>  2 files changed, 13 insertions(+), 7 deletions(-)

This fails to build on sandbox for example currently, please rebase.
Thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-03-04 19:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-27 22:06 [PATCH] net: dhcp6: Send DHCPv6 using multicast MAC seanedmond
2025-03-04 19:40 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox