Skip to content

backport networking fixes and improvements#2191

Closed
bergware wants to merge 1 commit into
unraid:masterfrom
bergware:backport-networking-fixes-and-improvements
Closed

backport networking fixes and improvements#2191
bergware wants to merge 1 commit into
unraid:masterfrom
bergware:backport-networking-fixes-and-improvements

Conversation

@bergware

@bergware bergware commented May 9, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Introduced background monitoring of network interfaces to automatically manage static IP assignments when interfaces go up or down.
    • Added support for dynamic metric assignment for network routes based on interface indices.
    • Enhanced Docker network integration with improved handling of virtual interfaces and metrics.
    • Improved static IP management and tracking for VLANs and Docker-related interfaces.
  • Bug Fixes

    • Refined IP address selection to prefer primary global addresses, improving reliability of IP retrieval in various scripts.
    • Improved robustness of VLAN removal in the web interface.
  • Chores

    • Updated script comments and metadata to reflect recent changes.
    • Standardized and simplified internal logic for metric calculations and interface management.
  • Documentation

    • Updated inline comments and documentation for clarity and accuracy regarding metric assignment and interface handling.

@coderabbitai

coderabbitai Bot commented May 9, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces dynamic, interface index-based metric assignment for network interfaces across scripts and templates. It simplifies metric calculation logic, refines IP address selection using more precise ip command filters, and adds new helper functions for interface management. A new background script monitors interface state and manages static IP assignments accordingly. Docker, wireless, and network initialization scripts are all updated to use these new mechanisms.

Changes

File(s) Change Summary
emhttp/plugins/dynamix/Eth0.page, emhttp/plugins/dynamix/EthX.page Simplified the metric function to use only the interface name, removed protocol and index parameters, and updated all calls to match the new signature. Adjusted metric calculation to use interface index. Updated JavaScript VLAN removal logic for robustness.
emhttp/plugins/dynamix/include/RoutingTable.php Enhanced route filtering by excluding additional route types ("linkdown", "broadcast") in IP route queries for both IPv4 and IPv6.
emhttp/plugins/dynamix/scripts/reload_services, emhttp/plugins/dynamix/scripts/update_services Moved service reload delay from within the script to the scheduling command, eliminating internal sleep and instead sleeping before script execution.
etc/rc.d/rc.docker Improved network interface and Docker network management: added interface index helper, refined IP address selection, always recreates custom networks, simplified shim/vhost interface handling, and adjusted metric calculations to use interface indices.
etc/rc.d/rc.inet1 Updated comments, added interface index helper, renamed carrier_up to carrier, disabled IPv6 on macvtap interfaces, and changed static IP metric assignment to use interface index plus 1000.
etc/rc.d/rc.library.source Changed IP address listing from -temporary to primary in ip commands for more accurate primary address selection. Updated version comment.
etc/rc.d/rc.local Added silent background execution for interface monitoring via monitor_interface, and silenced output for monitor_nchan.
etc/rc.d/rc.nginx Refined LAN IP address retrieval in SSL setup to use scope global primary dev, and reordered parsing for accuracy. Updated header date.
etc/rc.d/rc.wireless Added Docker config support, helper functions for variable extraction and interface index, dynamic metric assignment (index+3000), Docker shim interface handling, improved IP cleanup, and conditional service restarts based on static DNS settings.
sbin/create_network_ini Added helper functions for variable extraction, interface index, and netmask/CIDR conversion. Improved IP address retrieval, tracked static IP assignments, and integrated Docker virtual interface management based on DHCP events.
sbin/monitor_interface New script: Monitors interfaces and manages static IP assignments from statics.ini, adding/removing addresses as interfaces go up/down. Reloads config on file changes and ensures stable state before acting. Runs as a background process.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WebGUI
    participant NetworkScript
    participant MonitorInterface

    User->>WebGUI: Configure static IP / VLAN / Docker settings
    WebGUI->>NetworkScript: Save config, trigger network scripts
    NetworkScript->>MonitorInterface: Update statics.ini (static IPs)
    MonitorInterface->>MonitorInterface: Monitor interface states
    MonitorInterface->>NetworkScript: Add/remove static IPs as interfaces go up/down
Loading
sequenceDiagram
    participant DockerScript
    participant System
    participant Interface

    DockerScript->>System: Delete existing custom network
    DockerScript->>System: Recreate custom network
    DockerScript->>Interface: Assign IP with metric (index-based)
    DockerScript->>Interface: Disable IPv6 on shim/vhost
Loading

Possibly related PRs

  • Fix PHP error in networking #2059: Fixes a PHP error in the metric function when no metrics are found. Related as both PRs modify the same function, but this PR changes the function signature and logic.
  • Network enhancements #2045: Introduces a metric function with protocol and index parameters and additional gateway logic. The current PR simplifies and directly modifies this function, making them closely related.

Poem

🐇
Metrics now dance by index, not guess,
IPs are assigned with less of a mess.
Interfaces watched in a background trance,
Docker and Wi-Fi join the new dance.
With scripts refined, and logic anew,
The network hops smarter—thanks to this crew!


📜 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 98f1c72 and 41b8059.

📒 Files selected for processing (13)
  • emhttp/plugins/dynamix/Eth0.page (8 hunks)
  • emhttp/plugins/dynamix/EthX.page (6 hunks)
  • emhttp/plugins/dynamix/include/RoutingTable.php (1 hunks)
  • emhttp/plugins/dynamix/scripts/reload_services (0 hunks)
  • emhttp/plugins/dynamix/scripts/update_services (1 hunks)
  • etc/rc.d/rc.docker (9 hunks)
  • etc/rc.d/rc.inet1 (28 hunks)
  • etc/rc.d/rc.library.source (3 hunks)
  • etc/rc.d/rc.local (1 hunks)
  • etc/rc.d/rc.nginx (2 hunks)
  • etc/rc.d/rc.wireless (6 hunks)
  • sbin/create_network_ini (10 hunks)
  • sbin/monitor_interface (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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 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.

@bergware bergware closed this May 9, 2025
@bergware bergware deleted the backport-networking-fixes-and-improvements branch May 29, 2025 23:30
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.

1 participant