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

add dnsmasq for NetworkManager shared network #3865

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

jkt628
Copy link

@jkt628 jkt628 commented Feb 8, 2025

required by home-assistant/supervisor#5577

Summary by CodeRabbit

  • New Features
    • Updated configuration settings to enable a lightweight DNS forwarder and DHCP server across supported platforms.
    • Disabled the TFTP functionality within the DNS service to streamline network operations and enhance security.

Copy link

coderabbitai bot commented Feb 8, 2025

📝 Walkthrough

Walkthrough

This pull request introduces changes to two build configuration files in the external buildroot repository. In both the generic_x86_64_defconfig and rpi4_64_defconfig files, the DNSMasq package is enabled with the configuration option BR2_PACKAGE_DNSMASQ=y, while the TFTP feature is explicitly disabled with BR2_PACKAGE_DNSMASQ_TFTP=n. These modifications adjust the build configurations to include DNSMasq as a lightweight DNS forwarder and DHCP server without TFTP support.

Changes

File(s) Change Summary
buildroot…/generic_x86_64_defconfig, buildroot…/rpi4_64_defconfig Added new configuration options: BR2_PACKAGE_DNSMASQ=y and BR2_PACKAGE_DNSMASQ_TFTP=n

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 98efed8 and 3e8484f.

📒 Files selected for processing (2)
  • buildroot-external/configs/generic_x86_64_defconfig (1 hunks)
  • buildroot-external/configs/rpi4_64_defconfig (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • buildroot-external/configs/rpi4_64_defconfig
  • buildroot-external/configs/generic_x86_64_defconfig

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@agners
Copy link
Member

agners commented Feb 11, 2025

Hm, ok so there is more than it than just Supervisor changes 😢. It should be fairly low-risk to add dnsmasq. What is a bit concern is bloating. We already now struggle to fit things for generic-x86-64 😢 .

We certainly should check that there is no init scripts or systemd units deployed. In a quick look the dhcpd package excludes init scripts when NetworkManager is selected, but I don't see this for dnsmasq 🤔

@jkt628
Copy link
Author

jkt628 commented Feb 11, 2025

Hm, ok so there is more than it than just Supervisor changes 😢. It should be fairly low-risk to add dnsmasq. What is a bit concern is bloating. We already now struggle to fit things for generic-x86-64 😢 .

there are also home-assistant/cli#533 and home-assistant/home-assistant.io#37140. (i started on frontend yesterday but, even though i've coded for 50 years, i have never done a front end so i'm having to learn some new tricks. at least retirement is not being wasted!)

can you provide some parameters around "fit" for generic_x86_64? i have a system arriving today for testing custom HAOS so i can hopefully address this concern.

We certainly should check that there is no init scripts or systemd units deployed. In a quick look the dhcpd package excludes init scripts when NetworkManager is selected, but I don't see this for dnsmasq 🤔

on rpi4_64 the only references to dnsmasq are apparmor, dbus and NetworkManager. it runs only by NetworkManager, this taken from ps axf:

    506 ?        Ssl    0:59 /usr/sbin/NetworkManager --no-daemon
   9279 ?        S      0:00  \_ /usr/sbin/dnsmasq --conf-file=/dev/null --no-hosts --keep-in-foreground --bind-interfac

i should know more about generic_x86_64 soon.

Copy link
Member

@sairon sairon left a comment

Choose a reason for hiding this comment

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

I guess you added only the platforms you were able to test, however, the options should be added to all the board configs pre-emptively, as there's AFAIK no mechanism that enables the functionality depending on the board in other PRs.

Regarding the concerns @agners raised - the binary itself is ~400 KiB on x86 before FS compression - not great, not terrible. Install seems to be sane and install only the binary and harmless stuff:


>>> dnsmasq 2.90 Installing to target
GIT_DIR=. PATH="/build/output_generic_x86_64/host/bin:/build/output_generic_x86_64/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" CC="/build/output_generic_x86_64/host/bin/x86_64-buildroot-linux-gnu-gcc" /usr/bin/make -j33 -C /build/output_generic_x86_64/build/dnsmasq-2.90 COPTS="-DNO_TFTP -DHAVE_DBUS" PREFIX=/usr CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -O2 -g0 -D_FORTIFY_SOURCE=1" DESTDIR=/build/output_generic_x86_64/target LDFLAGS="" LIBS+= install
make[1]: Entering directory '/build/output_generic_x86_64/build/dnsmasq-2.90'
install -d /build/output_generic_x86_64/target/usr/sbin
install -d /build/output_generic_x86_64/target/usr/share/man/man8
install -m 644 man/dnsmasq.8 /build/output_generic_x86_64/target/usr/share/man/man8 
install -m 755 src/dnsmasq /build/output_generic_x86_64/target/usr/sbin
make[2]: Entering directory '/build/output_generic_x86_64/build/dnsmasq-2.90/src'
make[2]: 'dnsmasq' is up to date.
make[2]: Leaving directory '/build/output_generic_x86_64/build/dnsmasq-2.90/src'
make[1]: Leaving directory '/build/output_generic_x86_64/build/dnsmasq-2.90'
mkdir -p /build/output_generic_x86_64/target/var/lib/misc/
/usr/bin/install -m 0644 -D /build/output_generic_x86_64/build/dnsmasq-2.90/dbus/dnsmasq.conf /build/output_generic_x86_64/target/etc/dbus-1/system.d/dnsmasq.conf

What I wonder (but would have to be probably tested), would the DNS resolving, mDNS and whatnot work properly also for the clients? We use fairly exotic setup for that, which might be different from what NM expects. I think @agners is more knowledgeable in this area than me 😇

@@ -126,6 +126,8 @@ BR2_PACKAGE_IPTABLES_NFTABLES=y
BR2_PACKAGE_IPTABLES_NFTABLES_DEFAULT=y
BR2_PACKAGE_NETWORK_MANAGER=y
BR2_PACKAGE_NETWORK_MANAGER_CLI=y
BR2_PACKAGE_DNSMASQ=y
Copy link
Member

Choose a reason for hiding this comment

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

I see this was added manually, ideally make ... savedefconfig result of the modified config (e.g. using menuconfig) should be committed to the repo. The correctly formatted defconfig would have the changes around these lines:

diff --git a/buildroot-external/configs/generic_x86_64_defconfig b/buildroot-external/configs/generic_x86_64_defconfig
index f67c710da..49c0380e9 100644
--- a/buildroot-external/configs/generic_x86_64_defconfig
+++ b/buildroot-external/configs/generic_x86_64_defconfig
@@ -119,6 +119,8 @@ BR2_PACKAGE_BLUEZ5_UTILS_PLUGINS_AUDIO=y
 BR2_PACKAGE_BLUEZ5_UTILS_PLUGINS_HID=y
 BR2_PACKAGE_DHCP=y
 BR2_PACKAGE_DHCP_CLIENT=y
+BR2_PACKAGE_DNSMASQ=y
+# BR2_PACKAGE_DNSMASQ_TFTP is not set
 BR2_PACKAGE_DROPBEAR=y
 # BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set
 BR2_PACKAGE_IPROUTE2=y

Copy link
Author

Choose a reason for hiding this comment

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

I see this was added manually, ideally make ... savedefconfig result of the modified config (e.g. using menuconfig) should be committed to the repo.

i'll figure out that as i make the other changes.

@@ -126,6 +126,8 @@ BR2_PACKAGE_IPTABLES_NFTABLES=y
BR2_PACKAGE_IPTABLES_NFTABLES_DEFAULT=y
BR2_PACKAGE_NETWORK_MANAGER=y
BR2_PACKAGE_NETWORK_MANAGER_CLI=y
BR2_PACKAGE_DNSMASQ=y
BR2_PACKAGE_DNSMASQ_TFTP=n
Copy link
Member

Choose a reason for hiding this comment

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

This is not correct, as you can see above, disabling should be done through the # ... is not set stanza.

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft February 11, 2025 15:44
@jkt628
Copy link
Author

jkt628 commented Feb 11, 2025

I guess you added only the platforms you were able to test,

correct, that is in the commit message.

however, the options should be added to all the board configs pre-emptively

i wondered about that. i'll update all the platforms and commit message, too.

@jkt628 jkt628 force-pushed the feat/ipv4-method-shared branch from 3e8484f to 5d92e00 Compare February 11, 2025 17:35
@jkt628
Copy link
Author

jkt628 commented Feb 11, 2025

What I wonder (but would have to be probably tested), would the DNS resolving, mDNS and whatnot work properly also for the clients?

i have connected my phone and tablet to the shared network and they seem to work fine. the only problem i can remember is frigate-nvr could not connect my cameras due to iptables / netfilter configuration, but that was with home-assistant/supervised-installer and easily fixed, i will have to test again with HAOS.

@jkt628 jkt628 requested a review from sairon February 11, 2025 19:17
@jkt628
Copy link
Author

jkt628 commented Feb 12, 2025

i should know more about generic_x86_64 soon.

initial report: not working, 😢 . i see the AP on my desktop and phone but cannot connect. i found this in the journal:

Feb 12 13:53:26 haos-x86-64 NetworkManager[423]: <warn>  [1739368406.3078] iptables: command /usr/sbin/iptables failed: Child process exited with code 1
Feb 12 13:53:26 haos-x86-64 NetworkManager[423]: <warn>  [1739368406.3132] iptables: command /usr/sbin/iptables failed: Child process exited with code 1
Feb 12 13:53:26 haos-x86-64 NetworkManager[423]: <warn>  [1739368406.3189] iptables: command /usr/sbin/iptables failed: Child process exited with code 1

but do not see similar on rpi4_64.

digging in....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants