Skip to content

Commit

Permalink
[routing-manager] update valid on-link prefix (PIO) condition (openth…
Browse files Browse the repository at this point in the history
…read#10791)

This commit updates `RoutingManager::IsValidOnLinkPrefix()`, which
checks whether a received PIO is a suitable on-link prefix. The
updated check requires the `L` (on-link) flag to be set, along with
either the `A` (autonomous address-configuration) flag or the `P`
(DHCPv6-PD preferred) flag. This aligns the implementation with the
latest SNAC router draft.
  • Loading branch information
abtink authored Oct 8, 2024
1 parent 722b150 commit a8bf8e7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/core/border_router/routing_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,8 @@ bool RoutingManager::IsValidOnLinkPrefix(const PrefixInfoOption &aPio)

aPio.GetPrefix(prefix);

return IsValidOnLinkPrefix(prefix) && aPio.IsOnLinkFlagSet() && aPio.IsAutoAddrConfigFlagSet();
return IsValidOnLinkPrefix(prefix) && aPio.IsOnLinkFlagSet() &&
(aPio.IsAutoAddrConfigFlagSet() || aPio.IsDhcp6PdPreferredFlagSet());
}

bool RoutingManager::IsValidOnLinkPrefix(const Ip6::Prefix &aOnLinkPrefix)
Expand Down
18 changes: 15 additions & 3 deletions src/core/net/nd6.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ class PrefixInfoOption : public Option, private Clearable<PrefixInfoOption>
*/
void ClearAutoAddrConfigFlag(void) { mFlags &= ~kAutoConfigFlagMask; }

/**
* Indicates whether or not the DhCPv6-PD Preferred (P) flag is set.
*
* @retval TRUE The DHCPv6-PD Preferred (P) flag is set.
* @retval FALSE The DHCPv6-PD Preferred (P) flag is not set.
*/
bool IsDhcp6PdPreferredFlagSet(void) const { return (mFlags & kDhcp6PdPreferredFlagMask) != 0; }

/**
* Sets the valid lifetime of the prefix in seconds.
*
Expand Down Expand Up @@ -272,7 +280,7 @@ class PrefixInfoOption : public Option, private Clearable<PrefixInfoOption>
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | Type | Length | Prefix Length |L|A| Reserved1 |
// | Type | Length | Prefix Length |L|A|R|P| Rsvd1 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | Valid Lifetime |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Expand All @@ -288,9 +296,13 @@ class PrefixInfoOption : public Option, private Clearable<PrefixInfoOption>
// + +
// | |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
// Reference for P Flag (DHCPv6-PD preferred flag):
// https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-6man-pio-pflag.xml

static constexpr uint8_t kAutoConfigFlagMask = 0x40; // Autonomous address-configuration flag.
static constexpr uint8_t kOnLinkFlagMask = 0x80; // On-link flag.
static constexpr uint8_t kOnLinkFlagMask = 0x80; // On-link - L flag.
static constexpr uint8_t kAutoConfigFlagMask = 0x40; // Autonomous address-configuration - A flag.
static constexpr uint8_t kDhcp6PdPreferredFlagMask = 0x10; // DHCPv6-PD preferred - P flag.

uint8_t mPrefixLength; // The prefix length in bits.
uint8_t mFlags; // The flags field.
Expand Down

0 comments on commit a8bf8e7

Please sign in to comment.