-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not advertise temporary/deprecated IPv6 addresses by minimal mDNS on Linux #22009
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -390,6 +390,13 @@ class InterfaceIterator | |
class DLL_EXPORT InterfaceAddressIterator | ||
{ | ||
public: | ||
enum class Flags : uint8_t | ||
{ | ||
kNotFinal = (1 << 0), // Not yet valid: Optimistic/DAD failed/tentative | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like it's exposing Linux flags in an API that is mean to work across a range of platforms that may not have these granular flags. Perhaps start with just one (since all of the logic below seems to be treating all of these the same), and expand in the future as needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The flags here correspond to RFC 8981 concepts, so I think they're universally meaningful (even if not exposed on all platforms). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to make it somewhat conceptual by saying I was unsure if we can simplify more. We could in theory just have a |
||
kTemporary = (1 << 1), // IFA_F_TEMPORARY on linux | ||
kDeprecated = (1 << 2), // IFA_F_DEPRECATED on linux | ||
}; | ||
|
||
/** | ||
* Constructs an InterfaceAddressIterator object. | ||
* | ||
|
@@ -520,6 +527,13 @@ class DLL_EXPORT InterfaceAddressIterator | |
*/ | ||
bool HasBroadcastAddress(); | ||
|
||
/** | ||
* Fetch the flags for the given interface address. | ||
* | ||
* Note: not all implementations may support all flags. | ||
*/ | ||
BitFlags<Flags> GetFlags(); | ||
|
||
private: | ||
#if CHIP_SYSTEM_CONFIG_USE_LWIP && !CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT | ||
enum | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,20 @@ | |
namespace mdns { | ||
namespace Minimal { | ||
|
||
using namespace chip::Inet; | ||
|
||
void IPv4Responder::AddAllResponses(const chip::Inet::IPPacketInfo * source, ResponderDelegate * delegate, | ||
const ResponseConfiguration & configuration) | ||
{ | ||
chip::Inet::IPAddress addr; | ||
for (chip::Inet::InterfaceAddressIterator it; it.HasCurrent(); it.Next()) | ||
IPAddress addr; | ||
for (InterfaceAddressIterator it; it.HasCurrent(); it.Next()) | ||
{ | ||
if (it.GetFlags().HasAny(InterfaceAddressIterator::Flags::kNotFinal, InterfaceAddressIterator::Flags::kTemporary, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment here and in IPv6 that we will not advertise addresses that are not current and stable |
||
InterfaceAddressIterator::Flags::kDeprecated)) | ||
{ | ||
continue; | ||
} | ||
|
||
if ((it.GetInterfaceId() == source->Interface) && (it.GetAddress(addr) == CHIP_NO_ERROR) && addr.IsIPv4()) | ||
{ | ||
IPResourceRecord record(GetQName(), addr); | ||
|
@@ -39,14 +47,20 @@ void IPv4Responder::AddAllResponses(const chip::Inet::IPPacketInfo * source, Res | |
void IPv6Responder::AddAllResponses(const chip::Inet::IPPacketInfo * source, ResponderDelegate * delegate, | ||
const ResponseConfiguration & configuration) | ||
{ | ||
for (chip::Inet::InterfaceAddressIterator it; it.HasCurrent(); it.Next()) | ||
for (InterfaceAddressIterator it; it.HasCurrent(); it.Next()) | ||
{ | ||
if (it.GetInterfaceId() != source->Interface) | ||
{ | ||
continue; | ||
} | ||
|
||
chip::Inet::IPAddress addr; | ||
if (it.GetFlags().HasAny(InterfaceAddressIterator::Flags::kNotFinal, InterfaceAddressIterator::Flags::kTemporary, | ||
InterfaceAddressIterator::Flags::kDeprecated)) | ||
{ | ||
continue; | ||
} | ||
|
||
IPAddress addr; | ||
if ((it.GetInterfaceId() == source->Interface) && (it.GetAddress(addr) == CHIP_NO_ERROR) && addr.IsIPv6()) | ||
{ | ||
IPResourceRecord record(GetQName(), addr); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to ifdef those flasg separately in case some platforms like Android don't have all of them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect CI to detect this. I believe for android we care about IFA_F_OPTIMISTIC and DADFAILED, however the flags kNotFinal and such can remain the same as if a platform does not have that concept, the flags are not set. This is what currently happen for all non-linux