mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
cmd/tailscaled: disable netns earlier in userspace-networking mode
The earlier 382b349c54
was too late,
as engine creation itself needed to listen on things.
Fixes #2827
Updates #2822
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
382b349c54
commit
4f648e6fcc
@ -297,9 +297,6 @@ func run() error {
|
|||||||
logf("wgengine.New: %v", err)
|
logf("wgengine.New: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if useNetstack {
|
|
||||||
netns.Disable()
|
|
||||||
}
|
|
||||||
|
|
||||||
var ns *netstack.Impl
|
var ns *netstack.Impl
|
||||||
if useNetstack || wrapNetstack {
|
if useNetstack || wrapNetstack {
|
||||||
@ -391,6 +388,10 @@ func tryEngine(logf logger.Logf, linkMon *monitor.Mon, name string) (e wgengine.
|
|||||||
ListenPort: args.port,
|
ListenPort: args.port,
|
||||||
LinkMonitor: linkMon,
|
LinkMonitor: linkMon,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useNetstack = name == "userspace-networking"
|
||||||
|
netns.SetEnabled(!useNetstack)
|
||||||
|
|
||||||
if args.birdSocketPath != "" && createBIRDClient != nil {
|
if args.birdSocketPath != "" && createBIRDClient != nil {
|
||||||
log.Printf("Connecting to BIRD at %s ...", args.birdSocketPath)
|
log.Printf("Connecting to BIRD at %s ...", args.birdSocketPath)
|
||||||
conf.BIRDClient, err = createBIRDClient(args.birdSocketPath)
|
conf.BIRDClient, err = createBIRDClient(args.birdSocketPath)
|
||||||
@ -398,7 +399,6 @@ func tryEngine(logf logger.Logf, linkMon *monitor.Mon, name string) (e wgengine.
|
|||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
useNetstack = name == "userspace-networking"
|
|
||||||
if !useNetstack {
|
if !useNetstack {
|
||||||
dev, devName, err := tstun.New(logf, name)
|
dev, devName, err := tstun.New(logf, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -24,9 +24,10 @@
|
|||||||
|
|
||||||
var disabled syncs.AtomicBool
|
var disabled syncs.AtomicBool
|
||||||
|
|
||||||
// Disable disables netns for the process.
|
// SetEnabled enables or disables netns for the process.
|
||||||
func Disable() {
|
// It defaults to being enabled.
|
||||||
disabled.Set(true)
|
func SetEnabled(on bool) {
|
||||||
|
disabled.Set(!on)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listener returns a new net.Listener with its Control hook func
|
// Listener returns a new net.Listener with its Control hook func
|
||||||
|
Loading…
Reference in New Issue
Block a user