Skip to content
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

Mdns minimal mode #89

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

pemensik
Copy link
Member

@pemensik pemensik commented Aug 2, 2023

After discussion on Fedora mailing list we have come to conclusion that non-minimal mdns plugin version might be sufficient, if it were able to mimick mdns_minimal version in case of missing or unreadable /etc/mdns.allow file. Handling of .local domain were already the same. This change improves readability a bit and does similar thing for reverse addresses lookups. So mdns4 behaves exactly like mdns4_minimal, with an exception it tries to open /etc/mdns.allow first.

Attempt to make nss code more readable by moving some conditional stuff
to separate functions. Reduces ifdefs inside the resolution functions.
Use file path to signal when minimal or full variant is being compiled.
Move file opening only after it has correct mode.
@pemensik pemensik force-pushed the mdns-minimal-mode branch from 8684b7b to cb00179 Compare August 2, 2023 12:37
For .local domain mdns plugin behaved the same way as mdns_minimal, when
configuration file were not present. Extend such behaviour to reverse
queries as well. Because currently they are not changed by
configuration, just add a check whether the config file is present in
gethostbyaddr queries.

That should allow to reduce used plugins to just non-minimal variants,
which have minimal mode activated by not present config file. It adds
single extra fopen compared to pure minimal plugins resolution call.
@pemensik pemensik force-pushed the mdns-minimal-mode branch from cb00179 to eea9179 Compare August 2, 2023 12:40
Copy link

@zdohnal zdohnal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if the PR updated docs a little and adjusted function names to match the project.

@@ -78,14 +78,17 @@ addresses via mDNS, most people will want to use
`libnss_mdns.so.2` or `libnss_mdns6.so.2` in such a
situation causes long timeouts when resolving hosts since most modern
Unix/Linux applications check for IPv6 addresses first, followed by a
lookup for IPv4.
lookup for IPv4. When these plugins cannot open mdns.allow config file,
they will behave like minimal version below.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention the downside of having mdns.allow as well.

/* Reverse addresses are not supported in config file.
* They just check if config is missing to enable minimal mode
* from non-minimal plugins. */
static int avahi_is_file_present(const char *path) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about rather call it _nss_mdns_file_exists() and _nss_mdns_is_link_local() (and switch logic in the function to match the name) . They are static functions for this module with no relevance to avahi.

@Neustradamus Neustradamus mentioned this pull request Sep 5, 2023
@evverx evverx mentioned this pull request Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants