Skip to content

Draft Add ability to override network interface#12

Open
evgkrsk wants to merge 5 commits intocozystack:mainfrom
evgkrsk:add-vlan-support
Open

Draft Add ability to override network interface#12
evgkrsk wants to merge 5 commits intocozystack:mainfrom
evgkrsk:add-vlan-support

Conversation

@evgkrsk
Copy link
Copy Markdown

@evgkrsk evgkrsk commented Dec 27, 2025

Summary by CodeRabbit

  • New Features
    • Added a command-line option to explicitly override the selected network interface during setup for precise interface or VLAN selection.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 27, 2025

📝 Walkthrough

Walkthrough

Added a CLI flag --override-interface (stored in devFlag) and used it in collectKernelArgsSimple to override the automatically detected network interface when provided.

Changes

Cohort / File(s) Summary
CLI & kernel-args
main.go
Added devFlag string; bound --override-interface in init; modified collectKernelArgsSimple to assign the detected dev from devFlag when devFlag is set, overriding auto-detection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐇 I found a flag beneath the clover,
A gentle push for where packets rover,
If detection naps, dev takes the cue,
A hop, a swap — the path runs true,
Carrot-topped joy for a small redo.

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title mentions 'override network interface' but the PR objectives request this feature to support VLAN configuration, making the title partially related but incomplete. Consider updating the title to reflect the actual objective: 'Add --override-interface flag for VLAN support' or similar to clarify the purpose of this feature.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @evgkrsk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the network configuration capabilities by adding support for VLAN-tagged interfaces. It allows the system to correctly identify and configure network settings for interfaces that are part of a Virtual Local Area Network, ensuring proper network connectivity in VLAN environments by generating the necessary kernel boot parameters.

Highlights

  • VLAN Support: Introduces the capability to parse VLAN IDs from network interface names and generate the corresponding kernel boot parameters for VLAN configuration.
  • New Function getVID: Adds a helper function getVID that uses regular expressions to extract the VLAN ID and the physical interface name from a given interface string (e.g., 'eth0.100').
  • Kernel Argument Generation: Modifies the collectKernelArgs function to utilize getVID and, if a valid VLAN ID is detected, append a vlan= kernel argument alongside the existing ip= argument.
  • Dependency Updates: Imports the regexp and strconv packages to support the new VLAN parsing logic.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for VLAN configuration by parsing interface names with a .vid suffix. The implementation is a good start, but there are a few important issues to address. The new getVID function compiles a regular expression on every call, which is inefficient, and the regex pattern itself is too restrictive for common Linux interface names. Additionally, the function's logic can be simplified for better readability. Most critically, an error returned from getVID for invalid VLAN IDs is ignored, which will lead to silent network configuration failures at boot time. I've provided specific comments and suggestions to resolve these issues.

Comment thread main.go Outdated
Comment thread main.go Outdated
Comment thread main.go Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
main.go (2)

290-290: Move regex compilation to package level for efficiency.

Compiling the regex pattern on every function call is inefficient. Since the pattern is constant, compile it once at package level.

🔎 Proposed refactor

Add this near the top of the file (e.g., after the flag variables section):

var vlanRegex = regexp.MustCompile(`^([a-z0-9]+)\.(\d+)$`)

Then update the function:

 func getVID(name string) (int, string, error) {
-	re := regexp.MustCompile(`^([a-z0-9]+)\.(\d+)$`)
-	matches := re.FindStringSubmatch(name)
+	matches := vlanRegex.FindStringSubmatch(name)
 	phy := ""

292-303: Consider simplifying the control flow.

The else block could be eliminated by initializing phy before the conditional.

🔎 Proposed refactor
 func getVID(name string) (int, string, error) {
 	re := regexp.MustCompile(`^([a-z0-9]+)\.(\d+)$`)
 	matches := re.FindStringSubmatch(name)
-	phy := ""
+	phy := name
 	if len(matches) == 3 {
 		vid, err := strconv.Atoi(matches[2])
 		phy = matches[1]
 		if err != nil || vid < 1 || vid > 4094 {
 			return 0, phy, fmt.Errorf("invalid VID: %s", matches[2])
 		}
 		return vid, phy, nil
-	} else {
-		phy = name
 	}
 	return 0, phy, nil
 }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2064c2a and ee0786a.

📒 Files selected for processing (1)
  • main.go
🔇 Additional comments (2)
main.go (2)

18-19: LGTM: Standard library imports for VLAN parsing.

The addition of regexp and strconv packages appropriately supports the new VLAN ID parsing functionality.


325-327: The kernel VLAN parameter format is correct as written.

The code generates vlan=<vlan-ifname>:<physical-dev> format (e.g., vlan=eth0.100:eth0), which matches the standard Linux kernel boot parameter syntax. The getVID() function correctly extracts the physical device name from the VLAN interface name (e.g., eth0 from eth0.100), and the conditional appends the parameter only when a valid VLAN ID is detected. No changes needed.

Comment thread main.go Outdated
@evgkrsk
Copy link
Copy Markdown
Author

evgkrsk commented Dec 27, 2025

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for VLAN interfaces. The changes correctly parse VLAN interface names to extract the VLAN ID and physical device, and then add the appropriate vlan= kernel boot parameter. My review focuses on improving the robustness of the VLAN interface parsing and enhancing error messages for a better user experience.

Comment thread main.go Outdated
Comment thread main.go Outdated
@evgkrsk evgkrsk changed the title Add VLAN support Draft Add VLAN support Dec 31, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
main.go (1)

291-291: Regex pattern is too restrictive for Linux interface names.

The pattern ^([a-z0-9]+)\.(\d+)$ doesn't match many valid Linux interface names. This was flagged in previous reviews but remains unaddressed.

Valid interface names that will fail:

  • Names with uppercase: Some USB/virtual devices
  • Names with hyphens: br-lan, eth-wan
  • Names with underscores: Custom interface names
  • Modern predictable names: enp0s3 (actually this works, but enP0s3 wouldn't)

This means VLAN detection will silently fail for these interfaces, and the vlan= kernel argument won't be added even when needed.

🔎 Proposed fix
-var vlanInterfaceRegex = regexp.MustCompile(`^([a-z0-9]+)\.(\d+)$`)
+var vlanInterfaceRegex = regexp.MustCompile(`^([a-zA-Z0-9._-]+)\.(\d+)$`)

This allows uppercase letters, dots, hyphens, and underscores in the physical interface name, covering the vast majority of valid Linux interface names.

🧹 Nitpick comments (1)
main.go (1)

293-308: Consider early-return pattern for clearer flow.

The logic is correct, but readability could be improved by handling the non-match case with an early return, making the happy path less nested.

🔎 Proposed refactor
 func getVID(name string) (int, string, error) {
 	matches := vlanInterfaceRegex.FindStringSubmatch(name)
-	phy := name
-	if len(matches) == 3 {
-		vid, err := strconv.Atoi(matches[2])
-		phy = matches[1]
-		if err != nil {
-			return 0, phy, fmt.Errorf("invalid VID in interface name: %q is not a valid integer", matches[2])
-		}
-		if vid < 1 || vid > 4094 {
-			return 0, phy, fmt.Errorf("invalid VID in interface name: %d is out of the valid range (1-4094)", vid)
-		}
-		return vid, phy, nil
+	if len(matches) < 3 {
+		return 0, name, nil
 	}
-	return 0, phy, nil
+	
+	phy := matches[1]
+	vid, err := strconv.Atoi(matches[2])
+	if err != nil {
+		return 0, phy, fmt.Errorf("invalid VID in interface name: %q is not a valid integer", matches[2])
+	}
+	if vid < 1 || vid > 4094 {
+		return 0, phy, fmt.Errorf("invalid VID in interface name: %d is out of the valid range (1-4094)", vid)
+	}
+	return vid, phy, nil
 }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 350c4d2 and d6a51a2.

📒 Files selected for processing (1)
  • main.go
🔇 Additional comments (6)
main.go (6)

18-19: LGTM!

The new imports are appropriate for VLAN parsing functionality.


38-38: LGTM!

The flag variable declaration is appropriate.


48-48: LGTM!

The flag binding is clear and provides a useful override mechanism.


316-318: LGTM!

The override logic is straightforward and provides a useful escape hatch for users.


324-327: Good error handling improvement.

The error from getVID is now properly captured and handled, addressing a critical issue from previous reviews. The program will fail fast with a descriptive error message if an invalid VLAN interface is provided.


335-337: LGTM!

The conditional appending of the vlan= kernel argument is correct. It only adds the argument when a valid VID is detected (vid > 0), following the kernel's VLAN configuration convention.

@kvaps
Copy link
Copy Markdown
Member

kvaps commented Jan 6, 2026

Hey @evgkrsk thank you for your contibution, vlan support just been added in main 02874d7 together with bond support 067822d could you please check latest release v0.6.0

@evgkrsk
Copy link
Copy Markdown
Author

evgkrsk commented Jan 7, 2026

Thank you for quick reaction, @kvaps

I have compared 0.5.1 vs 0.6.0 official linux/amd64 binaries on one node with VLAN and official siderolabs/installer:v1.12.1 image:

Pro

  • I have managed to successfully run node maintenance in boot mode with "vlan=..." kernel arg AND correct (not default) interface in "Network device for IP"

Contra

  • Both boot and install modes failed to set up node network automatically (with -yes arg AND without extra kernel args): there was propagated hostname, but no ip/mask/gw.
  • VLAN autodetection failed to use right interface,so only -extra-kernel-arg "vlan=..." helps
  • Manual "vlan=..." configuration via kernel args fails in install mode: hostname without ip/mask/gw

Summary: in 0.6.0, there is still no way to non-interactive run boot-to-talos with proper args to get working VLAN network. Please, consider (re)adding --override-interface or similar flag to combine in with -yes.

Perhaps it is worth to add ability to override any internal variable?

evgkrsk and others added 4 commits January 8, 2026 01:06
Signed-off-by: Evgenii Tereshkov <etereshkov@ozon.ru>
Signed-off-by: Evgenii Tereshkov <etereshkov@ozon.ru>
Signed-off-by: Evgenii Tereshkov <etereshkov@ozon.ru>
Signed-off-by: Evgenii Tereshkov <evg.krsk@gmail.com>
Signed-off-by: Evgenii Tereshkov <evg.krsk@gmail.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @main.go:
- Around line 306-308: The override of the interface (dev = devFlag) currently
happens after calling ifaceAddr(), causing IP/mask to be fetched from the wrong
interface; move the dev override to occur before the call to ifaceAddr() so that
ifaceAddr(dev) queries the overridden interface (use symbols dev, devFlag, and
ifaceAddr) and ensure non-interactive flows (-yes) return consistent dev plus
its IP/mask.
🧹 Nitpick comments (1)
main.go (1)

36-36: Consider a more descriptive variable name (optional).

While devFlag is consistent with the existing naming pattern, interfaceFlag or overrideInterfaceFlag would be more self-documenting given that the flag is named --override-interface.

📝 Suggested naming improvement
-	devFlag   string
+	interfaceFlag string

Then update the binding and usage accordingly.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c00c571 and 93aea02.

📒 Files selected for processing (1)
  • main.go
🔇 Additional comments (1)
main.go (1)

46-46: Flag binding looks good.

The flag name and help text are clear, and the implementation follows the established pattern.

Comment thread main.go
@evgkrsk evgkrsk changed the title Draft Add VLAN support Draft Add ability to override network interface Jan 8, 2026
@evgkrsk
Copy link
Copy Markdown
Author

evgkrsk commented Jan 14, 2026

Hey @kvaps , can you review/merge new (minimalistic) version of the PR? This is last reason not to use non-interactive (-yes) version of boot-to-talos for me.

Sadly, I have not enough experience or ideas how to debug why current (0.6.0) version fails to reproduce working VLAN network setup in this mode.

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