Skip to content

u2o keep src flow should consider multi-vlan on the same provider#5385

Merged
changluyi merged 1 commit intomasterfrom
fix_multi_vlan_keep_u2o_mac
Jun 23, 2025
Merged

u2o keep src flow should consider multi-vlan on the same provider#5385
changluyi merged 1 commit intomasterfrom
fix_multi_vlan_keep_u2o_mac

Conversation

@changluyi
Copy link
Copy Markdown
Collaborator

@changluyi changluyi commented Jun 20, 2025

Pull Request

What type of this PR

Examples of user facing changes:

  • Features
  • Bug fixes
  • Docs
  • Tests

When multiple VLANs share a provider, multiple localnet ports with the same name will appear, resulting in the port ID not being found by name, and the following error will be reported:

image

Which issue(s) this PR fixes

Fixes #(issue-number)

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 20, 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.

Summary of Changes

Hello @changluyi, 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 refines the User-to-Overlay (U2O) keep source MAC flow mechanism within Kube-OVN to correctly support environments with multiple VLANs on a single provider network. The changes introduce subnet-awareness into the OVS flow management, ensuring that traffic rules are accurately applied and distinguished per subnet, which is critical for robust multi-VLAN deployments.

Highlights

  • Enhanced U2O Flow Management: The core functions responsible for managing User-to-Overlay (U2O) keep source MAC flows, HandleU2OForPod in controller_linux.go and AddOrUpdateU2OKeepSrcMac/DeleteU2OKeepSrcMac in ovs-ofctl.go, have been updated to accept and utilize the subnetName as a new parameter. This ensures that U2O flows can be managed with subnet-specific context.
  • Subnet-Aware Patch Port Identification: A new helper function, getOfportByPeer, has been introduced in ovs-ofctl.go. This function dynamically retrieves the OpenFlow port ID (ofport) for OVS patch ports by querying their peer name. Crucially, the patch port names used for U2O flows are now constructed to include the subnetName (e.g., patch-br-int-to-localnet.<subnetName>), allowing for accurate identification of the correct patch port in multi-VLAN scenarios.
  • Improved Multi-VLAN Support: By making the U2O flow management subnet-aware and using subnet-specific patch port identification, this pull request addresses the issue of handling multiple VLANs on the same provider network. This change ensures that the correct OpenFlow rules are applied and removed for each subnet, preventing conflicts and maintaining proper network connectivity for pods in multi-VLAN environments.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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
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 updates the U2O keep source MAC functionality to handle multi-VLAN scenarios. It passes the subnetName to OVS interaction functions, enabling identification of the correct OVS patch port. A new helper getOfportByPeer is introduced, and OVS functions are updated to use it, improving the specificity of OpenFlow rule application. A suggestion is made to enhance getOfportByPeer by validating the ofport value.

Comment thread pkg/ovs/ovs-ofctl.go
return -1, fmt.Errorf("failed to get ofport for interface %s: %w", ifaceName, err)
}

return strconv.Atoi(ofportStr)
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 ofport obtained from OVSDB should be a positive integer. Add a check to ensure ofportNum is valid before returning it, to avoid issues if ovs-vsctl get Interface ... ofport returns a non-positive value.

Suggested change
return strconv.Atoi(ofportStr)
ofportNum, err := strconv.Atoi(ofportStr)
if err != nil {
return -1, fmt.Errorf("failed to parse ofport '%s' for interface %s: %w", ofportStr, ifaceName, err)
}
if ofportNum <= 0 {
return -1, fmt.Errorf("invalid ofport %d reported for interface %s", ofportNum, ifaceName)
}
return ofportNum, nil

@changluyi changluyi requested a review from zhangzujian June 20, 2025 12:05
@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 15778495257

Details

  • 0 of 34 (0.0%) changed or added relevant lines in 2 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.01%) to 21.572%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/daemon/controller_linux.go 0 6 0.0%
pkg/ovs/ovs-ofctl.go 0 28 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/ovs/ovn-nb-bfd.go 2 61.61%
pkg/ovs/ovn-nb-logical_router_route.go 2 74.6%
Totals Coverage Status
Change from base Build 15777108147: -0.01%
Covered Lines: 10479
Relevant Lines: 48577

💛 - Coveralls

@changluyi changluyi requested a review from oilbeater June 22, 2025 06:43
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 23, 2025
@changluyi changluyi merged commit a2db6b1 into master Jun 23, 2025
138 of 140 checks passed
@changluyi changluyi deleted the fix_multi_vlan_keep_u2o_mac branch June 23, 2025 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants