-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wireguard: Set wireguard and route MTU to detected MTU #16020
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ import ( | |
"github.com/cilium/cilium/pkg/lock" | ||
"github.com/cilium/cilium/pkg/logging" | ||
"github.com/cilium/cilium/pkg/logging/logfields" | ||
"github.com/cilium/cilium/pkg/mtu" | ||
"github.com/cilium/cilium/pkg/node" | ||
"github.com/cilium/cilium/pkg/option" | ||
"github.com/cilium/cilium/pkg/sysctl" | ||
|
@@ -107,7 +108,7 @@ func (a *Agent) Close() error { | |
} | ||
|
||
// Init is called after we have obtained a local Wireguard IP | ||
func (a *Agent) Init() error { | ||
func (a *Agent) Init(mtuConfig mtu.Configuration) error { | ||
link := &netlink.Wireguard{LinkAttrs: netlink.LinkAttrs{Name: types.IfaceName}} | ||
err := netlink.LinkAdd(link) | ||
if err != nil && !errors.Is(err, unix.EEXIST) { | ||
|
@@ -134,6 +135,11 @@ func (a *Agent) Init() error { | |
return err | ||
} | ||
|
||
linkMTU := mtuConfig.GetDeviceMTU() - mtu.WireguardOverhead | ||
if err := netlink.LinkSetMTU(link, linkMTU); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is not enough. We need to make sure that route MTU in pod netns is set accordingly (MTU minus the WG overhead), grep for
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep you're right. The route MTU was set too high. Modified |
||
return err | ||
} | ||
|
||
if err := netlink.LinkSetUp(link); err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a follow up we should probably s/encryptEnabled/ipsecEnabled.