Skip to content

motd/20-ip-info: align (LAN)/(WAN) labels across IPv4 + IPv6 rows#9728

Merged
igorpecovnik merged 1 commit intomainfrom
motd-ip-info-align-wan-only-rows
May 1, 2026
Merged

motd/20-ip-info: align (LAN)/(WAN) labels across IPv4 + IPv6 rows#9728
igorpecovnik merged 1 commit intomainfrom
motd-ip-info-align-wan-only-rows

Conversation

@igorpecovnik
Copy link
Copy Markdown
Member

@igorpecovnik igorpecovnik commented Apr 26, 2026

Summary

WAN-only motd rows (the common case on a server with only a public address, where the LAN entry gets deduplicated against WAN by lines 76-81) misalign the (WAN) label across the IPv4 and IPv6 rows by one column (addresses below are RFC 5737 / RFC 3849 documentation examples):

 IPv4:        (WAN) 192.0.2.42
 IPv6:         (WAN) 2001:db8::42
              ^^^ shifted right by one column

Two underlying causes:

  1. The IPv4 prefix is 14 chars (` IPv4:` + 8 trailing spaces); the IPv6 prefix is 15 (` IPv6:` + 9 trailing spaces).
  2. The IPv6 LAN appendix had no (LAN) label at all — just the bare address — so the extra space was an attempt to align v6's address column with v4's address-with-(LAN)-label column. Worked when both rows had a LAN portion; broke as soon as LAN got dropped.

Change

  • Use the same 13-char prefix for both rows (` IPv4:` / ` IPv6:` + 7 padding, no trailing space).
  • Both (LAN) and (WAN) appendices start with a single leading space — the label sits at the same column regardless of which (or both) are present.
  • Add a (LAN) label to the IPv6 row too; the asymmetry was what forced the per-row spacing offset, and mirroring the v4 structure removes the underlying cause.

Test plan

Verified across all four cases by stubbing the helpers and exercising print_ip_lines directly:

--- LAN+WAN (both):
 IPv4:        (LAN) 192.0.2.10, 192.0.2.11 (WAN) 198.51.100.7
 IPv6:        (LAN) fe80::1 (WAN) 2001:db8::42
--- LAN only:
 IPv4:        (LAN) 192.0.2.10
 IPv6:        (LAN) fe80::1
--- WAN only (the reported bug):
 IPv4:        (WAN) 198.51.100.7
 IPv6:        (WAN) 2001:db8::42
--- nothing:
(no output)

(LAN) and (WAN) align column-for-column on both rows in every case.

Summary by CodeRabbit

  • Bug Fixes

    • IPv6 addresses at login are now correctly labeled "(LAN)" when present, matching IPv4 labeling.
    • LAN/WAN labels for IP rows no longer misalign across address families.
  • Style

    • Improved column alignment and consistent left-padding for IPv4 and IPv6 lines in the terminal greeting.
    • Unified spacing so label/value columns line up across IPv4 and IPv6.

@igorpecovnik igorpecovnik requested a review from a team as a code owner April 26, 2026 08:26
@igorpecovnik igorpecovnik requested review from ArkadiuszRaj and martinayotte and removed request for a team April 26, 2026 08:26
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3a193a54-417c-4ac2-9a4f-6d2dc0752028

📥 Commits

Reviewing files that changed from the base of the PR and between 5a19109 and fbf0d4b.

📒 Files selected for processing (1)
  • packages/bsp/common/etc/update-motd.d/20-ip-info

📝 Walkthrough

Walkthrough

Updates only the print_ip_lines() output formatting: adds prefix4/prefix6 variables to standardize left padding, aligns IPv4 and IPv6 LAN/WAN label placement, and ensures IPv6 LAN addresses are labeled (LAN) when present.

Changes

Cohort / File(s) Summary
MOTD IP Formatting
packages/bsp/common/etc/update-motd.d/20-ip-info
Refactored print_ip_lines() to introduce prefix4 and prefix6 for consistent column alignment; normalized spacing for (LAN)/(WAN) suffixes; ensured IPv6 LAN addresses receive (LAN) label and align under IPv4 columns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Poem

I nibble at prefixes by moonlight,
Aligning addresses into sight,
IPv4, IPv6 — neat in a row,
LAN and WAN labels now show,
A tidy MOTD, soft and bright. 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: aligning (LAN)/(WAN) labels across IPv4 and IPv6 rows, which is precisely what the changeset accomplishes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch motd-ip-info-align-wan-only-rows

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size/small PR with less then 50 lines 05 Milestone: Second quarter release Needs review Seeking for review BSP Board Support Packages labels Apr 26, 2026
The IPv4 row used a 14-char prefix (` IPv4:` + 8 trailing spaces);
the IPv6 row used 15 (` IPv6:` + 9 trailing spaces). The extra
space on v6 was an attempt to make the v6 address column line up
with the v4 address column when v4 had a `(LAN)` label and v6
didn't (v6's LAN appendix had no label at all, just the bare
address). Worked when v4 had `(LAN)` and v6 had something — broke
the moment LAN got dropped against WAN by the dedup at lines
76-81 and only the `(WAN)` half remained.

Net visible bug (addresses are RFC 5737 / RFC 3849 examples):

   IPv4:        (WAN) 192.0.2.42
   IPv6:         (WAN) 2001:db8::42
                ^ shifted by one column

Fix:

  - Use the same 13-char prefix for both rows (IPv4: / IPv6: + 7
    padding, no trailing space).
  - Both `(LAN)` and `(WAN)` appendices start with a single
    leading space — the label always sits at the same column
    regardless of which (or both) are present.
  - Add a `(LAN)` label to v6 too; the asymmetry was the original
    reason the spacing was offset, and removing it lets v4 and v6
    structurally mirror each other.
  - Drop the trailing space the appendices used to carry — pure
    EOL whitespace, never visible.

Verified across all four cases (LAN+WAN / LAN only / WAN only /
nothing): `(LAN)` and `(WAN)` always align column-for-column on
both rows.
@igorpecovnik igorpecovnik force-pushed the motd-ip-info-align-wan-only-rows branch from 5a19109 to fbf0d4b Compare April 26, 2026 08:28
@igorpecovnik igorpecovnik added Ready to merge Reviewed, tested and ready for merge and removed Needs review Seeking for review labels May 1, 2026
@igorpecovnik igorpecovnik merged commit df93556 into main May 1, 2026
12 checks passed
@igorpecovnik igorpecovnik deleted the motd-ip-info-align-wan-only-rows branch May 1, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release BSP Board Support Packages Ready to merge Reviewed, tested and ready for merge size/small PR with less then 50 lines

Development

Successfully merging this pull request may close these issues.

1 participant