More network fixes and improvements#2194
Conversation
This reverts commit 741ece5.
WalkthroughThe updates modify four scripts related to network and process management. They adjust how background jobs are handled, refactor static IP address recording, simplify and change the logic for interface state monitoring, and introduce improved idle detection for nchan subscribers. No public APIs or exported declarations are added or removed. Changes
Sequence Diagram(s)sequenceDiagram
participant MonitorInterface
participant NetworkInterface
participant System
loop Every 3 seconds
MonitorInterface->>NetworkInterface: Check interface state
alt State changed to "up"
MonitorInterface->>System: ip addr add dev <line>
else State changed to "down" and new interface
MonitorInterface->>System: ip addr flush dev <interface> scope global
end
end
sequenceDiagram
participant MonitorNchan
participant Nginx
participant System
loop Every 30 seconds
MonitorNchan->>Nginx: Get subscriber count (curl to socket)
loop 3 times, 3s apart
MonitorNchan->>Nginx: Check subscriber count
end
alt Idle detected (all 3 checks zero)
MonitorNchan->>System: Log idle, stop nchan, cleanup
end
end
Suggested labels
Poem
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
sbin/create_network_ini (2)
185-186: Minor nit: unnecessary subshellAll four
echo "$(ip … | awk …)"statements spawn an extra subshell forecho.
printf(or plain command substitution withoutecho) is marginally faster and avoids an extra fork:-echo "$(ip -6 -br addr show … | awk …)" >>$STA +ip -6 -br addr show … | awk '{$2="";print;exit}' >>$STA
214-215: Duplicate code – could be extracted to a helperThe IPv4 and IPv6 static-address blocks for both parent and VLAN interfaces are identical except for the
ip -4/-6switch. A small function would remove four nearly-identical code chunks and cut maintenance cost.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
etc/rc.d/rc.docker(0 hunks)sbin/create_network_ini(4 hunks)sbin/monitor_interface(2 hunks)sbin/monitor_nchan(2 hunks)
💤 Files with no reviewable changes (1)
- etc/rc.d/rc.docker
🔇 Additional comments (2)
sbin/create_network_ini (1)
164-166: Static-IP line now contains interface + address – confirm downstream parsingThe new format (
eth0 192.0.2.10/24) is simpler, but any tool that used to rely on the previousIPADDR=<addr> METRIC=<n>layout must be adjusted.
monitor_interfacewas updated in this PR, so the change looks intentional. Just make sure no other scripts (e.g. plugin hooks) still expect the old layout.sbin/monitor_interface (1)
52-66:LASTdeduplication logic may miss multi-address interfaces
ip addr flush scope global dev $INTis skipped when the same interface appears twice in a row (common on multinet setups).
Consider tracking interface-state transitions instead of using a singleLASTvariable, or always flushing when the state actually changed todown.
Summary by CodeRabbit