-
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
Fix --interface-id and improve minmdns address policy #37360
base: master
Are you sure you want to change the base?
Fix --interface-id and improve minmdns address policy #37360
Conversation
…sier to understand and extend - make AddressPolicy cleaner by following a pattern seen with GetDefaultAdvertiser - explicit SetDefaultAddressPolicy calls are not required - no ifdefs needed to include a particular implementation of a default policy, only gn linking controls this - rename things a bit, DefaultAddressPolicy will now become BuiltinAddressPolicy to better reflect the fact that it is a wrapper for the builtin InterfaceIterator in InetInterface.cpp - provide a SingleInterfaceAddressPolicy which is stacked on top of an existing policy and restricts the interface id - apply the SingleInterfaceAddressPolicy when the --interface-id argument is provided *and* the minmdns dnssd backend is selected Signed-off-by: Maciej Grela <[email protected]>
Signed-off-by: Maciej Grela <[email protected]>
Signed-off-by: Maciej Grela <[email protected]>
Signed-off-by: Maciej Grela <[email protected]>
PR #37360: Size comparison from 7912cad to c937b09 Full report (3 builds for cc32xx, stm32)
|
Signed-off-by: Maciej Grela <[email protected]>
c937b09
to
05cc5a4
Compare
PR #37360: Size comparison from f957643 to 05cc5a4 Increases above 0.2%:
Full report (52 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
Signed-off-by: Maciej Grela <[email protected]>
PR #37360: Size comparison from f957643 to d81d570 Increases above 0.2%:
Full report (72 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
Align CHIP_MDNS_MINIMAL macro handling with best practices. Signed-off-by: Maciej Grela <[email protected]>
@@ -25,9 +25,22 @@ namespace { | |||
AddressPolicy * gAddressPolicy = nullptr; | |||
} // namespace | |||
|
|||
// This will be resolved at link time if a default policy is set | |||
#ifndef CHIP_MINMDNS_NONE_POLICY | |||
AddressPolicy * GetDefaultAddressPolicy(); |
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.
this should go in some header rather than declared here and then in other per-policy headers in a repeated manner.
We want to ensure a single declaration placement. Probably in AddressPolicy.h
. Full documentation on usage should be described there.
namespace mdns { | ||
namespace Minimal { | ||
|
||
void SetDefaultAddressPolicy(); | ||
AddressPolicy * GetDefaultAddressPolicy(); |
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.
This should probably be removed from here. Likely we may not need this header at all.
void SetAddressPolicy(); | ||
|
||
} // namespace LibNl | ||
AddressPolicy * GetDefaultAddressPolicy(); |
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.
Same here: this header should probably not exist at all. Declaration of this should be in AddressPolicy.h
if (!mParent->Next(&id, &type)) | ||
{ | ||
return false; | ||
} | ||
|
||
while (id != mSelectedIface) | ||
{ | ||
if (!mParent->Next(&id, &type)) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
*out_id = id; | ||
*out_type = type; | ||
return true; |
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.
Feels like the code could be shorter somehow... did not test, but maybe this works:
if (!mParent->Next(&id, &type)) | |
{ | |
return false; | |
} | |
while (id != mSelectedIface) | |
{ | |
if (!mParent->Next(&id, &type)) | |
{ | |
return false; | |
} | |
} | |
*out_id = id; | |
*out_type = type; | |
return true; | |
while (mParent->Next(&id, &type)) | |
{ | |
if (id != mSelectedIface) | |
{ | |
continue; | |
} | |
*out_id = id; | |
*out_type = type; | |
return true; | |
} | |
return false; |
@@ -85,6 +92,11 @@ static_library("server") { | |||
"${chip_root}/src/transport", | |||
] | |||
|
|||
if (chip_mdns_minimal) { |
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 think we have mdns as minimal or platform ... so this may pull a mdns dependency even for thread (at least CI link errors seem to indicate that).
PR #37360: Size comparison from f957643 to 086bc71 Increases above 0.2%:
Full report (32 builds for cc32xx, esp32, linux, nrfconnect, telink)
|
@@ -111,18 +111,16 @@ def wait(self, timeout=None): | |||
self.cv_stopped.wait() | |||
|
|||
def __startServer(self, runner, command): | |||
app_cmd = command + ['--interface-id', str(-1)] |
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.
Isn't this going to break running YAML tests on Darwin, by no longer passing that argument?
@@ -51,9 +51,6 @@ + (NSTask *)doStartAppWithName:(NSString *)name arguments:(NSArray<NSString *> * | |||
__auto_type * appTask = [self createTaskForPath:executable]; | |||
|
|||
__auto_type * forcedArguments = @[ | |||
// Make sure we only advertise on the local interface. |
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.
Again, this is going to break the Darwin tests, causing a lot of random failures due to cross-talk between runners. Stopping here.
This PR makes the --interface-id work on linux. Before even when --interface-id was specified the minmdns still advertises on all interfaces. This has been fixed by implementing a new address policy which, when stacked upon the default address policy, filters the available interfaces.
Additionally, some refactoring was performed on the address policy code to make it easier to understand and maintain (I hope). This PR also serves as an RFC for these changes to gather feedback on the refactored address policy approach.
After positive review I will move forward and try to add an automated test for --interface-id as a next step.
Testing
Manual testing on devcontainer so far.