[ip] make mesh-local addresses non-preferred (#6532)

This commit marks anycast addresses and mesh-local addresses as
IPv6 deprecated addresses.
This commit is contained in:
Yakun Xu
2021-05-13 08:23:07 -07:00
committed by GitHub
parent 4fd20f7cf2
commit 85cc73b34b
5 changed files with 16 additions and 14 deletions
+1 -1
View File
@@ -427,7 +427,7 @@ typedef struct otIp6AddressInfo
const otIp6Address *mAddress; ///< A pointer to the IPv6 address.
uint8_t mPrefixLength; ///< The prefix length of mAddress if it is a unicast address.
uint8_t mScope : 4; ///< The scope of this address.
bool mIsAnycast : 1; ///< Whether this is an anycast address.
bool mPreferred : 1; ///< Whether this is a preferred address.
} otIp6AddressInfo;
/**
+7 -7
View File
@@ -45,12 +45,12 @@ namespace Ip6 {
class AddressInfo : public otIp6AddressInfo
{
public:
AddressInfo(const NetifUnicastAddress &aAddress, Instance &aInstance)
explicit AddressInfo(const NetifUnicastAddress &aAddress)
{
mAddress = &aAddress.mAddress;
mPrefixLength = aAddress.mPrefixLength;
mScope = aAddress.GetScope();
mIsAnycast = aInstance.Get<Mle::MleRouter>().IsAnycastLocator(aAddress.GetAddress());
mPreferred = aAddress.mPreferred;
}
explicit AddressInfo(const NetifMulticastAddress &aAddress)
@@ -58,7 +58,7 @@ public:
mAddress = &aAddress.GetAddress();
mPrefixLength = kMulticastPrefixLength;
mScope = aAddress.GetAddress().GetScope();
mIsAnycast = false;
mPreferred = false;
}
private:
@@ -439,7 +439,7 @@ void Netif::AddUnicastAddress(NetifUnicastAddress &aAddress)
VerifyOrExit(mAddressCallback != nullptr);
{
AddressInfo addressInfo(aAddress, GetInstance());
AddressInfo addressInfo(aAddress);
mAddressCallback(&addressInfo,
/* IsAdded */ true, mAddressCallbackContext);
@@ -457,7 +457,7 @@ void Netif::RemoveUnicastAddress(const NetifUnicastAddress &aAddress)
VerifyOrExit(mAddressCallback != nullptr);
{
AddressInfo addressInfo(aAddress, GetInstance());
AddressInfo addressInfo(aAddress);
mAddressCallback(&addressInfo, /* IsAdded */ false, mAddressCallbackContext);
}
@@ -543,12 +543,12 @@ bool Netif::IsUnicastAddressExternal(const NetifUnicastAddress &aAddress) const
return mExtUnicastAddressPool.IsPoolEntry(aAddress);
}
void NetifUnicastAddress::InitAsThreadOrigin(void)
void NetifUnicastAddress::InitAsThreadOrigin(bool aPreferred)
{
Clear();
mPrefixLength = NetworkPrefix::kLength;
mAddressOrigin = OT_ADDRESS_ORIGIN_THREAD;
mPreferred = true;
mPreferred = aPreferred;
mValid = true;
}
+5 -3
View File
@@ -80,12 +80,14 @@ public:
* This method clears and initializes the unicast address as a preferred, valid, thread-origin address with 64-bit
* prefix length.
*
* @param[in] aPreferred Whether to initialize as a preferred address.
*
*/
void InitAsThreadOrigin(void);
void InitAsThreadOrigin(bool aPreferred = false);
/**
* This method clears and initializes the unicast address as a preferred, valid, thread-origin, realm-local scope
* (overridden) address with 64-bit prefix length.
* This method clears and initializes the unicast address as a valid (but not preferred), thread-origin, realm-local
* scope (overridden) address with 64-bit prefix length.
*
*/
void InitAsThreadOriginRealmLocalScope(void);
+1 -1
View File
@@ -124,7 +124,7 @@ Mle::Mle(Instance &aInstance)
mParentCandidate.Clear();
ResetCounters();
mLinkLocal64.InitAsThreadOrigin();
mLinkLocal64.InitAsThreadOrigin(/* aPreferred */ true);
mLinkLocal64.GetAddress().SetToLinkLocalAddress(Get<Mac::Mac>().GetExtAddress());
mLeaderAloc.InitAsThreadOriginRealmLocalScope();
+2 -2
View File
@@ -344,7 +344,7 @@ static void UpdateUnicastLinux(const otIp6AddressInfo &aAddressInfo, bool aIsAdd
req.nh.nlmsg_len = NLMSG_ALIGN(req.nh.nlmsg_len) + rta->rta_len;
if (aAddressInfo.mIsAnycast)
if (!aAddressInfo.mPreferred)
{
struct ifa_cacheinfo cacheinfo;
@@ -402,7 +402,7 @@ static void UpdateUnicast(otInstance *aInstance, const otIp6AddressInfo &aAddres
#if defined(__APPLE__)
ifr6.ifra_lifetime.ia6t_expire = ND6_INFINITE_LIFETIME;
ifr6.ifra_lifetime.ia6t_preferred = ND6_INFINITE_LIFETIME;
ifr6.ifra_lifetime.ia6t_preferred = (aAddressInfo.mPreferred ? ND6_INFINITE_LIFETIME : 0);
#endif
rval = ioctl(sIpFd, aIsAdded ? SIOCAIFADDR_IN6 : SIOCDIFADDR_IN6, &ifr6);