@ -22,6 +22,7 @@ import (
"tailscale.com/types/logger"
"tailscale.com/types/logger"
"tailscale.com/types/preftype"
"tailscale.com/types/preftype"
"tailscale.com/version/distro"
"tailscale.com/version/distro"
"tailscale.com/wgengine/monitor"
)
)
const (
const (
@ -96,6 +97,7 @@ type netfilterRunner interface {
type linuxRouter struct {
type linuxRouter struct {
logf func ( fmt string , args ... interface { } )
logf func ( fmt string , args ... interface { } )
tunname string
tunname string
linkMon * monitor . Mon
addrs map [ netaddr . IPPrefix ] bool
addrs map [ netaddr . IPPrefix ] bool
routes map [ netaddr . IPPrefix ] bool
routes map [ netaddr . IPPrefix ] bool
localRoutes map [ netaddr . IPPrefix ] bool
localRoutes map [ netaddr . IPPrefix ] bool
@ -112,7 +114,7 @@ type linuxRouter struct {
cmd commandRunner
cmd commandRunner
}
}
func newUserspaceRouter ( logf logger . Logf , tunDev tun . Device ) ( Router , error ) {
func newUserspaceRouter ( logf logger . Logf , tunDev tun . Device , linkMon * monitor . Mon ) ( Router , error ) {
tunname , err := tunDev . Name ( )
tunname , err := tunDev . Name ( )
if err != nil {
if err != nil {
return nil , err
return nil , err
@ -143,16 +145,17 @@ func newUserspaceRouter(logf logger.Logf, tunDev tun.Device) (Router, error) {
}
}
}
}
return newUserspaceRouterAdvanced ( logf , tunname , ipt4, ipt6 , osCommandRunner { } , supportsV6 , supportsV6NAT )
return newUserspaceRouterAdvanced ( logf , tunname , linkMon, ipt4, ipt6 , osCommandRunner { } , supportsV6 , supportsV6NAT )
}
}
func newUserspaceRouterAdvanced ( logf logger . Logf , tunname string , netfilter4, netfilter6 netfilterRunner , cmd commandRunner , supportsV6 , supportsV6NAT bool ) ( Router , error ) {
func newUserspaceRouterAdvanced ( logf logger . Logf , tunname string , linkMon * monitor . Mon , netfilter4, netfilter6 netfilterRunner , cmd commandRunner , supportsV6 , supportsV6NAT bool ) ( Router , error ) {
ipRuleAvailable := ( cmd . run ( "ip" , "rule" ) == nil )
ipRuleAvailable := ( cmd . run ( "ip" , "rule" ) == nil )
return & linuxRouter {
return & linuxRouter {
logf : logf ,
logf : logf ,
tunname : tunname ,
tunname : tunname ,
netfilterMode : netfilterOff ,
netfilterMode : netfilterOff ,
linkMon : linkMon ,
ipRuleAvailable : ipRuleAvailable ,
ipRuleAvailable : ipRuleAvailable ,
v6Available : supportsV6 ,
v6Available : supportsV6 ,