Skip to content

Network enhancements#2045

Merged
limetech merged 6 commits into
unraid:masterfrom
bergware:master
Feb 25, 2025
Merged

Network enhancements#2045
limetech merged 6 commits into
unraid:masterfrom
bergware:master

Conversation

@bergware

@bergware bergware commented Feb 25, 2025

Copy link
Copy Markdown
Contributor
  • Remove non-existing ports from configuration file
  • New option for additional ports: "Enable default gateway"
  • Check refinements, do not execute on non-existing ports

Summary by CodeRabbit

  • New Features

    • Introduced default gateway toggle options for both IPv4 and IPv6, making configuration more intuitive.
    • Enhanced user feedback on network interface status for better clarity.
    • Added a mechanism to check for the existence of network ports before executing commands.
    • Enhanced gateway management functionality with improved visibility of input fields based on user selections.
  • Bug Fixes

    • Improved network interface status detection and reduced the refresh interval for timely updates.
    • Refined the display logic for DHCP-related settings and associated metric inputs.
  • Chores

    • Enhanced overall configuration robustness by validating interface existence before applying changes.
    • Updated copyright years for maintenance details.

- Remove non-existing ports from configuration file
- New option for additional ports: "Enable default gateway"
- Check refinements, do not execute on non-existing ports
@coderabbitai

coderabbitai Bot commented Feb 25, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes update several network configuration components. The eth0 and ethX pages now use refined commands (with the -br flag) to determine interface statuses, and new variables (gw4, gw6) drive dynamic gateway UI elements. The logic for displaying gateway options based on DHCP and protocol selections has been improved. Additionally, helper scripts have been enhanced with a new port_exists() function and additional checks to process only valid interfaces. Minor updates include timeout adjustments, output formatting changes, and copyright notice updates.

Changes

File(s) Change Summary
emhttp/plugins/dynamix/Eth0.page Updated eth0 status check command to use ip -br link show; added variables (gw4, gw6) for gateway input control; refined DHCP-related UI logic and reduced portcheck timeout from 10 to 5 seconds.
emhttp/plugins/dynamix/EthX.page Revised interface status condition from checking "UP" to "DOWN"; added new HTML checkboxes for enabling default gateways (IPv4 & IPv6) across multiple interface instances.
emhttp/plugins/dynamix/include/CheckPort.php, emhttp/plugins/dynamix/include/PortToggle.php Modified network interface check commands to use ip -br; adjusted variable assignment and condition checks; updated copyright years and improved string formatting.
emhttp/plugins/dynamix/scripts/netconfig, sbin/create_network_ini Introduced a new port_exists() function and added checks for valid interfaces before executing commands; enhanced control flow to output gateway settings (USE_GW4, USE_GW6) in network configuration.
etc/rc.d/rc.inet1 Updated comments and modified logic for assigning dynamic metric values to interface IP addresses based on DHCP configuration.

Sequence Diagram(s)

sequenceDiagram
    participant Script as Netconfig Script
    participant PortCheck as Port Checking Function
    participant System as /sys/class/net
    Script->>PortCheck: Call port_exists(interface)
    PortCheck->>System: Check if interface exists
    System-->>PortCheck: Return true/false
    PortCheck-->>Script: Result of existence check
    alt Interface exists
        Script->>Other: Execute network configuration commands
    else
        Script->>Other: Skip processing for non-existent interface
    end
Loading
sequenceDiagram
    participant User as User
    participant UI as Eth0/EthX Page JavaScript
    participant Backend as Network Command Executor
    User->>UI: Change network settings (DHCP/Protocol)
    UI->>UI: Update gateway variables (gw4, gw6) and field visibility
    UI->>Backend: Execute updated network status check using `ip -br`
    Backend-->>UI: Return interface status
    UI->>User: Display updated interface status and gateway options
Loading

Possibly related PRs

  • Date and Time enhancements and other fixes #1949: The changes in the main PR for Eth0.page and the retrieved PR for EthX.page both involve modifications to the logic for checking the status of network interfaces and enhancements to user interface elements related to gateway settings, indicating a direct relationship at the code level.

Poem

I'm a bunny with a happy hop,
Updating code till bugs just stop.
New commands leap with streamlined flair,
Gateway toggles bouncing in the air.
Through checks and flows, our network sings,
A garden of code where each update brings!
🐇🌸 Happy hops to our new wings!


📜 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 7133443 and 814efed.

📒 Files selected for processing (1)
  • etc/rc.d/rc.inet1 (3 hunks)
🔇 Additional comments (4)
etc/rc.d/rc.inet1 (4)

10-10: Updated modification date to reflect recent changes.

The comment header has been updated with the current modification date (February 2025).


80-81: Good documentation of feature addition.

Clear documentation of the new feature: adding metric value to interface IP assignment, which aligns with the PR objective to provide more flexibility in network setup.


394-394: Improved flexibility for IPv4 interface metric assignment.

The hardcoded metric value of 1 has been replaced with a dynamic value from ${DHCP_METRIC:-1}. This change maintains backward compatibility while allowing for custom metric values, which enables more flexible routing configurations.


401-401: Improved flexibility for IPv6 interface metric assignment.

Similarly to the IPv4 change, the hardcoded metric value for IPv6 addresses has been replaced with the dynamic ${DHCP_METRIC:-1} variable. This ensures consistent behavior between IPv4 and IPv6 configurations.


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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
emhttp/plugins/dynamix/EthX.page (1)

384-384: Inconsistent minimum value for metric fields in template.

There's a discrepancy between minimum metric values - templates use min="1" while other interfaces use min="0". This could lead to inconsistent behavior.

-  <input type="text" name="METRIC:INDEX" min="1" max="9999" autocomplete="off" spellcheck="false" value="<?=_var($ethX,"METRIC:INDEX")?:metric('ethX',4)?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> *_(metric value, a lower value gets preference)_*
+  <input type="text" name="METRIC:INDEX" min="0" max="9999" autocomplete="off" spellcheck="false" value="<?=_var($ethX,"METRIC:INDEX")?:metric('ethX',4)?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> *_(metric value, a lower value gets preference)_*
-  <input type="text" name="METRIC6:INDEX" min="1" max="9999" autocomplete="off" spellcheck="false" value="<?=_var($ethX,"METRIC6:INDEX")?:metric('ethX',6)?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> *_(metric value, a lower value gets preference)_*
+  <input type="text" name="METRIC6:INDEX" min="0" max="9999" autocomplete="off" spellcheck="false" value="<?=_var($ethX,"METRIC6:INDEX")?:metric('ethX',6)?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> *_(metric value, a lower value gets preference)_*

Also applies to: 405-405

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 142bdb3 and ba0c169.

📒 Files selected for processing (3)
  • emhttp/plugins/dynamix/Eth0.page (26 hunks)
  • emhttp/plugins/dynamix/EthX.page (12 hunks)
  • sbin/create_network_ini (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • sbin/create_network_ini
  • emhttp/plugins/dynamix/Eth0.page
🔇 Additional comments (4)
emhttp/plugins/dynamix/EthX.page (4)

31-31: Command improvement for interface status check.

The change to use ip -br link show ethX | grep -om1 ' DOWN ' for checking interface status is a good improvement. The -br flag provides a more concise output format, making the pattern matching more reliable.


60-60: Updated selectGW function call.

The selectGW function is now called without parameters, which aligns with the new gateway management approach introduced in this PR. This function will likely handle all interface configurations based on the form state.


173-173: Added gateway enable/disable functionality for network interfaces.

New checkbox elements have been added to allow users to explicitly enable or disable default gateways for both IPv4 and IPv6 configurations. This implementation provides more flexibility in network setup and aligns with the PR objective of enhancing network configuration management.

Also applies to: 202-202, 279-279, 308-308, 373-373, 396-396


185-189: Enhanced gateway configuration with metric defaults.

The gateway configuration sections now include default metric values using the metric() function, providing better guidance to users when configuring network interfaces. The metric values determine routing priority, with lower values getting preference.

Also applies to: 212-216, 291-295, 318-322, 381-386, 402-407

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ba0c169 and 4f55564.

📒 Files selected for processing (2)
  • emhttp/plugins/dynamix/Eth0.page (26 hunks)
  • emhttp/plugins/dynamix/EthX.page (12 hunks)
🔇 Additional comments (13)
emhttp/plugins/dynamix/EthX.page (7)

31-31: Improved interface status check.

The command for checking interface status has been updated to use the more concise -br flag with ip link, making the output more consistent and easier to parse.


173-173: Added default gateway toggle for IPv4.

New UI element allows enabling/disabling the default gateway for IPv4, providing more flexibility in network configuration. This aligns well with the PR objectives.


185-192: Enhanced gateway configuration with metrics.

Added a dedicated section for IPv4 gateway metrics configuration, allowing more advanced routing setups. The metric value provides routing priority - lower values are more preferred for routing decisions.


202-202: Added default gateway toggle for IPv6.

Similar to the IPv4 enhancement, this UI element allows enabling/disabling the default gateway for IPv6 configurations.


212-219: Added IPv6 gateway metrics configuration.

Consistent with the IPv4 implementation, this provides metric configuration for IPv6 gateways, completing the dual-stack implementation.


60-60: Updated initialization to support gateway configuration.

Added call to the new selectGW function during form initialization to ensure gateway visibility is properly set based on initial configuration.


279-279: Consistent gateway configuration across VLAN interfaces.

Default gateway toggles have been added consistently across all interface types including VLANs, ensuring a uniform configuration experience.

Also applies to: 308-308, 373-373, 396-396

emhttp/plugins/dynamix/Eth0.page (6)

55-64: Well-implemented metric calculation function.

The new metric function intelligently determines the appropriate metric value for a network interface by:

  1. Checking if a bridge or bond exists for the interface
  2. Finding existing metric values from the current routes
  3. Using the existing metric if available, or calculating a new one by incrementing the highest existing metric

This ensures sensible default values when configuring gateways.


88-88: Consistent interface status check improvement.

Updated the command for checking eth0 status to match the same format used in EthX.page, ensuring consistency across the codebase.


337-357: Well-structured gateway selection function.

The new selectGW function handles the visibility of gateway configuration elements based on user selections. It works for both IPv4 and IPv6, and handles both initialization and user interaction cases efficiently.


267-290: Enhanced protocol selection with gateway handling.

The protocol selection function has been updated to properly manage gateway visibility based on protocol and DHCP settings. This provides a more intuitive UI experience where gateway options only appear when relevant.


499-499: Improved polling interval for port status checks.

Reduced the timeout for repeated port status checks from 10 seconds to 5 seconds, providing more responsive feedback to users about network interface status changes.


212-213: Default gateway handling for eth0 vs. other interfaces.

The code makes a distinction between eth0 (which always has a gateway when DHCP is enabled) and other interfaces (which use the checkbox to determine gateway status). This ensures backward compatibility for eth0 while providing flexibility for other interfaces.

Also applies to: 223-224

Comment thread emhttp/plugins/dynamix/Eth0.page Outdated
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