Skip to content

fix(encapsulation): fall back to tunl0 when cilium_tunl is absent#9

Merged
kvaps merged 1 commit intomainfrom
fix/cilium-tunl0-fallback
Feb 17, 2026
Merged

fix(encapsulation): fall back to tunl0 when cilium_tunl is absent#9
kvaps merged 1 commit intomainfrom
fix/cilium-tunl0-fallback

Conversation

@kvaps
Copy link
Member

@kvaps kvaps commented Feb 17, 2026

Summary

  • Reuse cilium_tunl when Cilium is running with enable-ipip-termination, otherwise create the standard tunl0
  • Ensure the interface is brought UP when reusing cilium_tunl, as Cilium may leave it in DOWN state

Test plan

  • Deploy Kilo with Cilium (enable-ipip-termination enabled) — verify Kilo reuses cilium_tunl
  • Deploy Kilo with Cilium (enable-ipip-termination disabled) — verify Kilo creates tunl0
  • Verify IPIP routes work in both scenarios

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>
@gemini-code-assist
Copy link

Summary of Changes

Hello @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

  • IPIP Tunnel Interface Initialization: The logic for initializing the IPIP tunnel interface has been updated to dynamically adapt to Cilium's configuration. If Cilium is running with enable-ipip-termination, the existing cilium_tunl interface is now reused.
  • Fallback to tunl0: When Cilium's enable-ipip-termination is not active and cilium_tunl is not found, the system will now correctly fall back to creating the standard tunl0 interface.
  • Interface State Management: An explicit check and action have been added to ensure that if cilium_tunl is reused, it is brought to an 'UP' state, addressing potential scenarios where Cilium might leave it 'DOWN'.

🧠 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
  • pkg/encapsulation/cilium.go
    • Updated comments to reflect the new logic regarding cilium_tunl and enable-ipip-termination.
    • Modified the Init function to first attempt to find and reuse cilium_tunl if it exists.
    • Added logic within Init to explicitly bring the cilium_tunl interface up if it is found but in a down state.
    • Changed the fallback mechanism in Init to create a generic tunl0 interface when cilium_tunl is not present.
Activity
  • No human activity has been recorded on this pull request yet.
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.

@coderabbitai
Copy link

coderabbitai bot commented Feb 17, 2026

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/cilium-tunl0-fallback

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kvaps kvaps marked this pull request as ready for review February 17, 2026 21:02
@kvaps kvaps merged commit 97f10c9 into main Feb 17, 2026
11 checks passed
Copy link

@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 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.

Comment on lines 99 to 109
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
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and avoid calling link.Attrs() twice, you can store its result in a variable and reuse it.

Suggested change
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
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant