Skip to content

add support for provider network vlan interfaces#5949

Merged
oilbeater merged 2 commits intokubeovn:masterfrom
abasitt:pn_vlansubinterfaces
Dec 22, 2025
Merged

add support for provider network vlan interfaces#5949
oilbeater merged 2 commits intokubeovn:masterfrom
abasitt:pn_vlansubinterfaces

Conversation

@abasitt
Copy link
Copy Markdown
Contributor

@abasitt abasitt commented Nov 26, 2025

Pull Request

What type of this PR

  • Features
  • Docs
  • Tests

Which issue(s) this PR fixes

Fixes #5756

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Nov 26, 2025
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @abasitt, 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 Kube-OVN's provider network capabilities by adding robust support for VLAN interfaces. It allows users to either explicitly define VLAN interfaces to be managed by the provider network or enable automatic detection and preservation of existing VLAN configurations. This ensures seamless integration of physical VLAN setups with the Kube-OVN overlay, maintaining IP addresses and routing when interfaces are moved to OVS bridges.

Highlights

  • Provider Network VLAN Interface Support: Introduced new fields preserveVlanInterfaces (boolean) and vlanInterfaces (array of strings) to the ProviderNetworkSpec to allow for explicit configuration or automatic detection and preservation of VLAN interfaces.
  • OVS Integration for VLANs: Implemented logic to create OVS internal ports for specified or detected VLAN interfaces, transferring their IP addresses and routes from the kernel VLAN interfaces to the OVS internal ports. This ensures existing network configurations are maintained.
  • VLAN Interface Cleanup and Restoration: Added functionality to properly clean up OVS internal VLAN ports and, if necessary, restore the original kernel VLAN interfaces with their IP addresses and routes during provider network deletion.
  • Utility Functions for VLANs: New utility functions were added to detect existing VLAN interfaces, check interface existence, extract VLAN IDs from interface names, and identify OVS internal VLAN ports.
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.

@dosubot dosubot bot added the feature New network feature label Nov 26, 2025
Copy link
Copy Markdown
Contributor

@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 introduces support for provider network VLAN interfaces, allowing for both automatic detection and explicit configuration of VLAN sub-interfaces. The changes include updates to the ProviderNetwork CRD, new fields in the ProviderNetworkSpec struct, and comprehensive logic in the daemon to manage the lifecycle of these VLAN interfaces within the OVS bridge. New utility functions have been added to detect, extract, and manage VLAN interface properties, along with corresponding unit tests. The implementation appears robust and addresses the feature request effectively.

Comment on lines +2090 to +2093
baseLink, err := netlink.LinkByName(baseInterfaceName)
if err != nil {
klog.Warningf("Base interface %s not found, cannot recreate kernel VLAN %s", baseInterfaceName, kernelVlanName)
return nil
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.

medium

In removeProviderVlanInterface, if netlink.LinkByName(baseInterfaceName) fails, the function logs a warning and returns nil. While this might be acceptable for transient issues, it could lead to a situation where addresses and routes are not properly restored if the base interface is genuinely missing or renamed. Consider propagating this error or implementing a retry mechanism to ensure the restoration process is as robust as possible, especially during cleanup operations where state consistency is crucial.

Comment on lines +63 to +66
parts := strings.Split(interfaceName, ".")
if len(parts) != 2 {
return 0, fmt.Errorf("invalid VLAN interface name format: %s (expected format: interface.vlanid)", interfaceName)
}
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.

medium

The ExtractVlanIDFromInterface function allows interface names like .10 to be parsed successfully, extracting 10 as the VLAN ID. However, the CRD pattern ^[a-zA-Z0-9_-]+\.[0-9]{1,4}$ for vlanInterfaces explicitly requires at least one character before the dot. While the CRD validation should prevent such inputs, it's generally good practice for the parsing logic to align with the stricter validation rules defined in the CRD, or to have a clear reason for being more lenient. This is a minor consistency point.

Comment on lines +118 to +121
interfaceName: ".10",
expectedID: 10,
expectError: false,
},
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.

medium

The test case interface name starting with dot confirms that ExtractVlanIDFromInterface successfully parses .10 as a valid VLAN interface name. As noted in pkg/util/vlan_interfaces.go, this is more permissive than the CRD pattern, which requires at least one character before the dot. It would be beneficial to either align the function's parsing logic with the CRD's stricter pattern or document why this leniency is necessary.

@coveralls
Copy link
Copy Markdown

coveralls commented Dec 10, 2025

Pull Request Test Coverage Report for Build 20424107908

Details

  • 10 of 282 (3.55%) changed or added relevant lines in 5 files are covered.
  • 5 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.06%) to 22.538%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/daemon/init.go 0 20 0.0%
pkg/daemon/ovs.go 0 26 0.0%
pkg/util/vlan_interfaces.go 10 36 27.78%
pkg/daemon/controller.go 0 40 0.0%
pkg/daemon/ovs_linux.go 0 160 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/daemon/init.go 1 0.0%
pkg/daemon/ovs.go 2 0.0%
pkg/ovs/ovn-nb-logical_router_route.go 2 74.6%
Totals Coverage Status
Change from base Build 20420579027: -0.06%
Covered Lines: 12084
Relevant Lines: 53617

💛 - Coveralls

@oilbeater
Copy link
Copy Markdown
Collaborator

@abasitt can you run make lint and sign off the commit? I will try to fix the conflict issue later.

@abasitt abasitt force-pushed the pn_vlansubinterfaces branch from 0c14243 to b90ef2a Compare December 20, 2025 02:36
@abasitt
Copy link
Copy Markdown
Contributor Author

abasitt commented Dec 20, 2025

@oilbeater done, thank you.

Signed-off-by: abasitt <abdul.basit@rakuten.com>
@oilbeater oilbeater force-pushed the pn_vlansubinterfaces branch from f6ffb2f to 690c22a Compare December 22, 2025 02:50
Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
@oilbeater oilbeater force-pushed the pn_vlansubinterfaces branch from 690c22a to 7b1dd05 Compare December 22, 2025 06:42
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 22, 2025
@oilbeater oilbeater merged commit 769d1b7 into kubeovn:master Dec 22, 2025
10 of 11 checks passed
@oilbeater
Copy link
Copy Markdown
Collaborator

Thanks! @abasitt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New network feature lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Move vlan interfaces under ovs and create internal vlan interfaces

3 participants