Skip to content

Commit dcbd870

Browse files
authored
[dhcp6] obsolete DHCPv6 Server Unicast Option per RFC 9915 (openthread#13146)
This commit updates the DHCPv6 Prefix Delegation (PD) client to comply with RFC 9915, which obsoletes the Server Unicast option (Option 12) and the UseMulticast status code. Changes: - Removed `mServerAddress` and `ProcessServerUnicastOption()` from `Dhcp6PdClient`. - Modified `Dhcp6PdClient::SendMessage` to always transmit via multicast to `ff02::1:2`. - Removed `UseMulticast` status code handling in `HandleReply()`. - Added `otMessageFree` weak stub in simulation platform's `infra_if.c` to resolve linking errors on simulation radio-only targets when DHCPv6 PD client is enabled. - Updated `test_dhcp6_pd_client.cpp` to expect multicast and removed the obsolete UseMulticast test case.
1 parent 494a486 commit dcbd870

5 files changed

Lines changed: 75 additions & 333 deletions

File tree

examples/platforms/simulation/infra_if.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,4 +363,11 @@ OT_TOOL_WEAK void otPlatInfraIfRecvIcmp6Nd(otInstance *aInstance,
363363
DieNow(OT_EXIT_FAILURE);
364364
}
365365

366+
OT_TOOL_WEAK void otMessageFree(otMessage *aMessage)
367+
{
368+
OT_UNUSED_VARIABLE(aMessage);
369+
fprintf(stderr, "\n\rWeak otMessageFree() is incorrectly used\n\r");
370+
DieNow(OT_EXIT_FAILURE);
371+
}
372+
366373
#endif // OPENTHREAD_SIMULATION_IMPLEMENT_INFRA_IF && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE

src/core/border_router/dhcp6_pd_client.cpp

Lines changed: 12 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ Dhcp6PdClient::Dhcp6PdClient(Instance &aInstance)
5151
, mMaxSolicitTimeout(kMaxSolicitTimeout)
5252
, mTimer(aInstance)
5353
{
54-
mServerAddress.Clear();
5554
}
5655

5756
void Dhcp6PdClient::Start(void)
@@ -268,18 +267,9 @@ void Dhcp6PdClient::SendMessage(void)
268267

269268
SuccessOrExit(AppendIaPdOption(*message));
270269

271-
LogInfo("Sending %s %s%s", MsgTypeToString(msgType),
272-
mServerAddress.IsUnspecified() ? "(multicast)" : "(unicast) to:",
273-
mServerAddress.IsUnspecified() ? "" : mServerAddress.ToString().AsCString());
270+
LogInfo("Sending %s (multicast)", MsgTypeToString(msgType));
274271

275-
if (!mServerAddress.IsUnspecified())
276-
{
277-
dstAddr = mServerAddress;
278-
}
279-
else
280-
{
281-
GetAllRelayAgentsAndServersMulticastAddress(dstAddr);
282-
}
272+
GetAllRelayAgentsAndServersMulticastAddress(dstAddr);
283273

284274
Get<InfraIf>().SendDhcp6(*message.Release(), dstAddr);
285275

@@ -535,7 +525,7 @@ void Dhcp6PdClient::HandleAdvertise(const Message &aMessage)
535525

536526
mPdPrefix = *favoredPdPrefix;
537527

538-
SaveServerDuidAndAddress(aMessage);
528+
SaveServerDuid(aMessage);
539529

540530
if (!mRetxTracker.IsFirstAttempt() || (preference == 255))
541531
{
@@ -562,20 +552,6 @@ void Dhcp6PdClient::HandleReply(const Message &aMessage)
562552
ExitNow();
563553
}
564554

565-
if (status == StatusCodeOption::kUseMulticast)
566-
{
567-
// Per RFC 8514 Section 18.2.10, if the client receives a Reply
568-
// message with a status code of UseMulticast, the client
569-
// records the receipt of the message and sends subsequent
570-
// messages to the server using multicast. The client re-sends the
571-
// original message using multicast.
572-
573-
VerifyOrExit(!mServerAddress.IsUnspecified());
574-
mServerAddress.Clear();
575-
SendMessage();
576-
ExitNow();
577-
}
578-
579555
if (mState == kStateReleasing)
580556
{
581557
// Per RFC 8415 Section 18.2.10.2: When the client receives a
@@ -599,7 +575,7 @@ void Dhcp6PdClient::HandleReply(const Message &aMessage)
599575
ExitNow();
600576
}
601577

602-
SaveServerDuidAndAddress(aMessage);
578+
SaveServerDuid(aMessage);
603579
CommitPdPrefix(*favoredPdPrefix);
604580

605581
ExitNow();
@@ -613,7 +589,7 @@ void Dhcp6PdClient::HandleReply(const Message &aMessage)
613589

614590
if (matchedPdPrefix != nullptr)
615591
{
616-
SaveServerDuidAndAddress(aMessage);
592+
SaveServerDuid(aMessage);
617593
CommitPdPrefix(*matchedPdPrefix);
618594

619595
if (mPdPrefix.mPreferredLifetime >= kMinPreferredLifetime)
@@ -631,7 +607,7 @@ void Dhcp6PdClient::HandleReply(const Message &aMessage)
631607

632608
if (favoredPdPrefix != nullptr)
633609
{
634-
SaveServerDuidAndAddress(aMessage);
610+
SaveServerDuid(aMessage);
635611
CommitPdPrefix(*favoredPdPrefix);
636612
ExitNow();
637613
}
@@ -685,32 +661,20 @@ Dhcp6PdClient::PdPrefix *Dhcp6PdClient::SelectFavoredPrefix(PdPrefixArray &aPdPr
685661
return favoredPdPrefix;
686662
}
687663

688-
void Dhcp6PdClient::SaveServerDuidAndAddress(const Message &aMessage)
664+
void Dhcp6PdClient::SaveServerDuid(const Message &aMessage)
689665
{
690-
// Reads the server DUID and Server Unicast option from the given
691-
// message and saves them. The message is assumed to have already
692-
// been validated to contain a Server ID option.
666+
// Reads the server DUID from the given message and saves it.
667+
// The message is assumed to have already been validated to contain
668+
// a Server ID option.
693669

694-
OffsetRange serverDuidOffsetRange;
695-
Ip6::Address serverAddress;
670+
OffsetRange serverDuidOffsetRange;
696671

697672
SuccessOrAssert(ServerIdOption::ReadDuid(aMessage, serverDuidOffsetRange));
698673
mServerDuid.SetLength(static_cast<uint8_t>(serverDuidOffsetRange.GetLength()));
699674
aMessage.ReadBytes(serverDuidOffsetRange, mServerDuid.GetArrayBuffer());
700-
701-
ProcessServerUnicastOption(aMessage, serverAddress);
702-
703-
if (!serverAddress.IsUnspecified())
704-
{
705-
mServerAddress = serverAddress;
706-
}
707675
}
708676

709-
void Dhcp6PdClient::ClearServerDuid(void)
710-
{
711-
mServerDuid.Clear();
712-
mServerAddress.Clear();
713-
}
677+
void Dhcp6PdClient::ClearServerDuid(void) { mServerDuid.Clear(); }
714678

715679
void Dhcp6PdClient::ClearPdPrefix(void)
716680
{
@@ -970,28 +934,6 @@ bool Dhcp6PdClient::ShouldSkipPrefixOption(const IaPrefixOption &aPrefixOption)
970934
return shouldSkip;
971935
}
972936

973-
void Dhcp6PdClient::ProcessServerUnicastOption(const Message &aMessage, Ip6::Address &aServerAddress) const
974-
{
975-
// Searches the message for a `ServerUnicastOption`. If found, the
976-
// server address is retrieved from it. Otherwise, `aServerAddress`
977-
// is set to `::` (unspecified address).
978-
979-
OffsetRange offsetRange;
980-
ServerUnicastOption serverUnicastOption;
981-
982-
aServerAddress.Clear();
983-
984-
SuccessOrExit(Option::FindOption(aMessage, Option::kServerUnicast, offsetRange));
985-
SuccessOrExit(aMessage.Read(offsetRange, serverUnicastOption));
986-
987-
aServerAddress = serverUnicastOption.GetServerAddress();
988-
989-
LogInfo("Processed Sever Unicast Option, serverAddr:%s", aServerAddress.ToString().AsCString());
990-
991-
exit:
992-
return;
993-
}
994-
995937
void Dhcp6PdClient::ProcessPreferenceOption(const Message &aMessage, uint8_t &aPreference) const
996938
{
997939
// Searches for `PreferenceOption` in the message. If it is not

src/core/border_router/dhcp6_pd_client.hpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,8 @@ class Dhcp6PdClient : public InstanceLocator
246246
PdPrefixArray &aPdPrefixes,
247247
Dhcp6::StatusCodeOption::Status &aStatus) const;
248248
bool ShouldSkipPrefixOption(const Dhcp6::IaPrefixOption &aPrefixOption) const;
249-
void ProcessServerUnicastOption(const Message &aMessage, Ip6::Address &aServerAddress) const;
250249
void ProcessPreferenceOption(const Message &aMessage, uint8_t &aPreference) const;
251-
void SaveServerDuidAndAddress(const Message &aMessage);
250+
void SaveServerDuid(const Message &aMessage);
252251
void ClearServerDuid(void);
253252
void ClearPdPrefix(void);
254253
void CommitPdPrefix(const PdPrefix &aPdPrefix);
@@ -259,14 +258,13 @@ class Dhcp6PdClient : public InstanceLocator
259258

260259
using DelayTimer = TimerMilliIn<Dhcp6PdClient, &Dhcp6PdClient::HandleTimer>;
261260

262-
State mState;
263-
bool mPdPrefixCommited;
264-
RetxTracker mRetxTracker;
265-
uint32_t mMaxSolicitTimeout;
266-
PdPrefix mPdPrefix;
267-
ServerDuid mServerDuid;
268-
Ip6::Address mServerAddress;
269-
DelayTimer mTimer;
261+
State mState;
262+
bool mPdPrefixCommited;
263+
RetxTracker mRetxTracker;
264+
uint32_t mMaxSolicitTimeout;
265+
PdPrefix mPdPrefix;
266+
ServerDuid mServerDuid;
267+
DelayTimer mTimer;
270268
};
271269

272270
} // namespace BorderRouter

src/core/net/dhcp6_types.hpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ class Option
161161
kElapsedTime = 8, ///< Elapsed Time Option.
162162
kRelayMessage = 9, ///< Relay Message Option.
163163
kAuthentication = 11, ///< Authentication Option.
164-
kServerUnicast = 12, ///< Server Unicast Option.
165164
kStatusCode = 13, ///< Status Code Option.
166165
kRapidCommit = 14, ///< Rapid Commit Option.
167166
kUserClass = 15, ///< User Class Option.
@@ -1019,36 +1018,6 @@ class IaPrefixOption : public Option
10191018
// Can be followed by sub-options.
10201019
} OT_TOOL_PACKED_END;
10211020

1022-
/**
1023-
* Represents a Server Unicast Option.
1024-
*/
1025-
OT_TOOL_PACKED_BEGIN
1026-
class ServerUnicastOption : public Option
1027-
{
1028-
public:
1029-
/**
1030-
* Initializes the DHCPv6 Option.
1031-
*/
1032-
void Init(void) { SetCode(kServerUnicast), SetLength(sizeof(*this) - sizeof(Option)); }
1033-
1034-
/**
1035-
* Returns the server IPv6 address.
1036-
*
1037-
* @returns the server IPv6 address.
1038-
*/
1039-
const Ip6::Address &GetServerAddress(void) const { return mServerAddress; }
1040-
1041-
/**
1042-
* Sets the server IPv6 address.
1043-
*
1044-
* @param[in] aServerAddress The server IPv6 address.
1045-
*/
1046-
void SetServerAddress(const Ip6::Address &aServerAddress) { mServerAddress = aServerAddress; }
1047-
1048-
private:
1049-
Ip6::Address mServerAddress;
1050-
} OT_TOOL_PACKED_END;
1051-
10521021
/**
10531022
* Represents an SOL_MAX_RT Option (Max Solicit timeout value).
10541023
*/

0 commit comments

Comments
 (0)