Skip to content

Network: fix regression errors#2051

Merged
limetech merged 1 commit into
unraid:masterfrom
bergware:master
Feb 26, 2025
Merged

Network: fix regression errors#2051
limetech merged 1 commit into
unraid:masterfrom
bergware:master

Conversation

@bergware

@bergware bergware commented Feb 25, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced wireless network stability by ensuring missing details default to safe values.
    • Streamlined network interface actions to apply updates consistently and simplify command execution.

@coderabbitai

coderabbitai Bot commented Feb 25, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes update two components. In the wireless attributes function, direct array access is replaced with the null coalescing operator in saveAttr to handle missing keys without error. In the network configuration script, the conditional check for port existence is removed so that the stop and start commands for network interfaces execute unconditionally, streamlining the control flow.

Changes

File(s) Change Summary
emhttp/plugins/dynamix/include/Wireless.php Updated saveAttr to use the null coalescing operator (??) for ATTR1 (bss), ATTR2 (signal), and ATTR3 (security) to prevent undefined index errors.
emhttp/plugins/dynamix/scripts/netconfig Removed the conditional check for port existence, making the stop (rc.inet1 {ifname}_stop) and start commands execute unconditionally, along with related commands.

Sequence Diagram(s)

sequenceDiagram
    participant Script as Netconfig Script
    participant RCInet1 as "/etc/rc.d/rc.inet1"
    participant Ini as "create_network_ini"
    participant WG as "update_wireguard"

    Script->>RCInet1: Execute "{ifname}_stop"
    Script->>RCInet1: Execute "{ifname}_{cmd}" (start interface)
    Script->>Ini: Execute "create_network_ini {ifname}"
    alt dns not set
        Script->>WG: Call update_wireguard({ifname})
    end
Loading

Possibly related PRs

Poem

I'm a bunny hopping through code so fine,
Null coalescing makes wireless assignments shine.
Port checks removed—simple commands now steer,
Interfaces start and stop with a hop so clear.
In every line, a joyful tech parade,
My whiskers twitch for changes perfectly made! 🐇

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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/include/Wireless.php (1)

103-105: Use of null coalescing operator enhances error handling.

The addition of the null coalescing operator (??) provides a fallback empty string value when the specified keys don't exist in the $wlan[$index] array. This prevents PHP from generating undefined index notices.

This change improves code robustness by handling potentially missing array keys gracefully. It's a good use of PHP's null coalescing operator which is more concise than the equivalent isset() check.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5a4dc6e and af5d627.

📒 Files selected for processing (2)
  • emhttp/plugins/dynamix/include/Wireless.php (1 hunks)
  • emhttp/plugins/dynamix/scripts/netconfig (2 hunks)
🔇 Additional comments (2)
emhttp/plugins/dynamix/scripts/netconfig (2)

157-159: Removed conditional check before starting interface with updated configuration.

The code now unconditionally executes the start command, creates the network configuration file, and updates WireGuard regardless of whether the port exists.

This change simplifies the control flow but removes a safeguard. Ensure this behavior is intentional and aligns with how the networking stack handles non-existent interfaces.

The underlying system commands might fail gracefully when an interface doesn't exist, but since all errors are redirected to /dev/null, they won't be visible in logs, which might make troubleshooting more difficult.


93-93:

Details

❓ Verification inconclusive

Removed conditional check for port existence before stopping interface.

The code now unconditionally executes the stop command for a network interface regardless of whether the port exists.

This change appears to fix a regression by ensuring the stop command always executes. However, verify this behavior is intended since it will attempt to stop interfaces even if they don't physically exist.


🏁 Script executed:

#!/bin/bash
# Check if the port_exists function is used elsewhere to verify interfaces
rg -A 2 -B 2 "port_exists" --type php

Length of output: 37


Attention: Confirm intended behavior for unconditionally stopping network interfaces

The code now removes any check for the interface’s existence and always executes the stop command:

exec("/etc/rc.d/rc.inet1 ".escapeshellarg("{$ifname}_stop")." >/dev/null");

Our repository search for any occurrence of port_exists (both in PHP and shell scripts) returned no results, suggesting that the prior conditional check wasn’t being used elsewhere. Please verify manually that invoking the stop command on non-existent interfaces is acceptable and won’t lead to any unintended side effects.

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