fix(encapsulation): fall back to tunl0 when cilium_tunl is absent#9
fix(encapsulation): fall back to tunl0 when cilium_tunl is absent#9
Conversation
Instead of always creating cilium_tunl, reuse it only when Cilium has already created it (enable-ipip-termination). Otherwise create the standard tunl0 — Cilium will rename it later if needed. Also ensure the interface is brought UP when reusing cilium_tunl, as Cilium may leave it in DOWN state. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Summary of ChangesHello @kvaps, 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 network encapsulation layer's handling of IPIP tunnel interfaces, specifically improving compatibility with Cilium. It introduces adaptive logic to either reuse an existing Cilium-managed tunnel or create a standard one, ensuring robust network connectivity regardless of the Cilium configuration. The changes also include a critical fix to guarantee that reused interfaces are always operational. 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. Changelog
Activity
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
|
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request correctly fixes an issue in the Cilium encapsulation logic by falling back to tunl0 when cilium_tunl is not available. It also adds a necessary check to ensure the reused interface is up. The logic is sound. I have one suggestion to improve the code by avoiding a repeated function call, which will enhance readability and maintainability.
| if link, err := netlink.LinkByName(ciliumTunlIface); err == nil { | ||
| c.iface = link.Attrs().Index | ||
| c.ownsTunnel = false | ||
| // Ensure the interface is UP — Cilium may leave it DOWN. | ||
| if link.Attrs().Flags&net.FlagUp == 0 { | ||
| if err := iproute.Set(c.iface, true); err != nil { | ||
| return fmt.Errorf("failed to set %s up: %v", ciliumTunlIface, err) | ||
| } | ||
| } | ||
| return nil | ||
| } |
There was a problem hiding this comment.
To improve readability and avoid calling link.Attrs() twice, you can store its result in a variable and reuse it.
| if link, err := netlink.LinkByName(ciliumTunlIface); err == nil { | |
| c.iface = link.Attrs().Index | |
| c.ownsTunnel = false | |
| // Ensure the interface is UP — Cilium may leave it DOWN. | |
| if link.Attrs().Flags&net.FlagUp == 0 { | |
| if err := iproute.Set(c.iface, true); err != nil { | |
| return fmt.Errorf("failed to set %s up: %v", ciliumTunlIface, err) | |
| } | |
| } | |
| return nil | |
| } | |
| if link, err := netlink.LinkByName(ciliumTunlIface); err == nil { | |
| attrs := link.Attrs() | |
| c.iface = attrs.Index | |
| c.ownsTunnel = false | |
| // Ensure the interface is UP — Cilium may leave it DOWN. | |
| if attrs.Flags&net.FlagUp == 0 { | |
| if err := iproute.Set(c.iface, true); err != nil { | |
| return fmt.Errorf("failed to set %s up: %v", ciliumTunlIface, err) | |
| } | |
| } | |
| return nil | |
| } |
Summary
cilium_tunlwhen Cilium is running withenable-ipip-termination, otherwise create the standardtunl0cilium_tunl, as Cilium may leave it in DOWN stateTest plan
enable-ipip-terminationenabled) — verify Kilo reusescilium_tunlenable-ipip-terminationdisabled) — verify Kilo createstunl0