fix: sysctl net.ipv4.conf.dae0peer.accept_local=1 (#512)

Co-authored-by: Sumire (菫) <151038614+sumire88@users.noreply.github.com>
This commit is contained in:
/gray 2024-05-03 19:11:28 +08:00 committed by GitHub
parent 19cacf5900
commit 3764df2af3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -289,13 +289,20 @@ func (ns *DaeNetns) setupSysctl() (err error) {
return fmt.Errorf("failed to set forwarding for dae0: %v", err)
}
// *_early_demux is not mandatory, but it's recommended to enable it for better performance
if err = netns.Set(ns.daeNs); err != nil {
return fmt.Errorf("failed to switch to daens: %v", err)
}
defer netns.Set(ns.hostNs)
// *_early_demux is not mandatory, but it's recommended to enable it for better performance
sysctl.Set("net.ipv4.tcp_early_demux", "1", false)
sysctl.Set("net.ipv4.ip_early_demux", "1", false)
// (ip net e daens) sysctl net.ipv4.conf.dae0peer.accept_local=1
// This is to prevent kernel from dropping skb due to "martian source" check: https://elixir.bootlin.com/linux/v6.6/source/net/ipv4/fib_frontend.c#L381
if err = sysctl.Set(fmt.Sprintf("net.ipv4.conf.%s.accept_local", NsVethName), "1", false); err != nil {
return fmt.Errorf("failed to set accept_local for dae0peer: %v", err)
}
return
}