u2o keep src flow should consider multi-vlan on the same provider#5385
u2o keep src flow should consider multi-vlan on the same provider#5385
Conversation
Signed-off-by: clyi <clyi@alauda.io>
There was a problem hiding this comment.
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,
HandleU2OForPodincontroller_linux.goandAddOrUpdateU2OKeepSrcMac/DeleteU2OKeepSrcMacinovs-ofctl.go, have been updated to accept and utilize thesubnetNameas 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 inovs-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 thesubnetName(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
-
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. ↩
There was a problem hiding this comment.
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.
| return -1, fmt.Errorf("failed to get ofport for interface %s: %w", ifaceName, err) | ||
| } | ||
|
|
||
| return strconv.Atoi(ofportStr) |
There was a problem hiding this comment.
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.
| 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 |
Pull Request Test Coverage Report for Build 15778495257Details
💛 - Coveralls |
Pull Request
What type of this PR
Examples of user facing changes:
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:
Which issue(s) this PR fixes
Fixes #(issue-number)