[release-1.14] northd: set dl_src for packets redirected by router port#6102
Conversation
Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
Summary of ChangesHello @zhangzujian, 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 significantly refactors the Kube-OVN controller by removing the Underlay-to-Overlay (U2O) interconnection logic, simplifying pod event handling, and introducing a new startup cleanup for obsolete U2O OpenFlow rules. Concurrently, it enhances the OVN northd component with a patch to correctly manage the data link source for packets redirected by router ports, addressing a specific networking behavior. Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request refactors the handling of packets redirected by a router port by moving the logic from node-level OVS flow rules to a centralized implementation in northd. This is a good architectural improvement that simplifies the daemon's responsibilities.
The changes include:
- Adding a new patch for
northdto create logical flows that modify the source MAC address of redirected packets. - Removing the now-obsolete U2O (Underlay to Overlay) feature from the
kube-ovn-cnidaemon, including related functions, work queues, and OpenFlow rule management. - Adding a cleanup function (
ClearU2OFlows) to remove any lingering OVS flows from the old implementation upon daemon startup.
The implementation is solid. I have a couple of suggestions for the new C code in northd to improve readability and maintainability.
| + if (!op->nbsp || !op->od || !op->od->nbs || | ||
| + !op->od->n_router_ports || !op->od->n_localnet_ports) { | ||
| + return; | ||
| + } | ||
| + if (!lsp_is_enabled(op->nbsp)) { | ||
| + return; | ||
| + } | ||
| + if (!strcmp(op->nbsp->type, "virtual") || | ||
| + !strcmp(op->nbsp->type, "localport")) { | ||
| + return; | ||
| + } | ||
| + if (lsp_is_external(op->nbsp) || lsp_is_router(op->nbsp) || | ||
| + op->has_unknown) { | ||
| + return; | ||
| + } | ||
| + | ||
| + if (op->n_lsp_addrs != 1 || !strlen(op->lsp_addrs[0].ea_s) || | ||
| + (!op->lsp_addrs[0].n_ipv4_addrs && !op->lsp_addrs[0].n_ipv6_addrs)) { | ||
| + return; | ||
| + } |
There was a problem hiding this comment.
For better readability, the series of if statements at the beginning of build_lswitch_mod_dl_src_rules can be combined into a single if block. This would clearly separate the precondition checks from the main logic of the function.
if (!op->nbsp || !op->od || !op->od->nbs ||
!op->od->n_router_ports || !op->od->n_localnet_ports ||
!lsp_is_enabled(op->nbsp) ||
!strcmp(op->nbsp->type, "virtual") ||
!strcmp(op->nbsp->type, "localport") ||
lsp_is_external(op->nbsp) || lsp_is_router(op->nbsp) ||
op->has_unknown ||
op->n_lsp_addrs != 1 || !strlen(op->lsp_addrs[0].ea_s) ||
(!op->lsp_addrs[0].n_ipv4_addrs && !op->lsp_addrs[0].n_ipv6_addrs)) {
return;
}
| + for (size_t j = 0; j < op->lsp_addrs[0].n_ipv4_addrs; j++) { | ||
| + ds_clear(match); | ||
| + ds_put_format(match, | ||
| + "inport == %s && ip4.src == %s && eth.src != %s", | ||
| + rp->json_key, op->lsp_addrs[0].ipv4_addrs[j].addr_s, | ||
| + op->lsp_addrs[0].ea_s); | ||
| + ovn_lflow_add_with_hint(lflows, op->od, S_SWITCH_IN_L2_LKUP, 60, | ||
| + ds_cstr(match), ds_cstr(actions), | ||
| + &op->nbsp->header_, op->lflow_ref); | ||
| + } | ||
| + | ||
| + for (size_t j = 0; j < op->lsp_addrs[0].n_ipv6_addrs; j++) { | ||
| + ds_clear(match); | ||
| + ds_put_format(match, | ||
| + "inport == %s && ip6.src == %s && eth.src != %s", | ||
| + rp->json_key, op->lsp_addrs[0].ipv6_addrs[j].addr_s, | ||
| + op->lsp_addrs[0].ea_s); | ||
| + ovn_lflow_add_with_hint(lflows, op->od, S_SWITCH_IN_L2_LKUP, 60, | ||
| + ds_cstr(match), ds_cstr(actions), | ||
| + &op->nbsp->header_, op->lflow_ref); | ||
| + } |
There was a problem hiding this comment.
Pull Request Test Coverage Report for Build 20496212592Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Pull Request
What type of this PR
Examples of user facing changes:
Which issue(s) this PR fixes
Fixes #(issue-number)