Network enhancements#2045
Conversation
- Remove non-existing ports from configuration file - New option for additional ports: "Enable default gateway" - Check refinements, do not execute on non-existing ports
WalkthroughThe changes update several network configuration components. The Changes
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
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
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (4)
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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 usemin="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
📒 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-brflag 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
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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
-brflag withip 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
metricfunction intelligently determines the appropriate metric value for a network interface by:
- Checking if a bridge or bond exists for the interface
- Finding existing metric values from the current routes
- 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
selectGWfunction 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
Summary by CodeRabbit
New Features
Bug Fixes
Chores