mirror of https://github.com/tailscale/tailscale/
feature/linkspeed: move cosmetic tstun netlink code out to modular feature
Part of making all netlink monitoring code optional. Updates #17311 (how I got started down this path) Updates #12614 Change-Id: Ic80d8a7a44dc261c4b8678b3c2241c3b3778370d Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>pull/17482/head
parent
63f7a400a8
commit
232b928974
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
// Code generated by gen.go; DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build ts_omit_linkspeed
|
||||||
|
|
||||||
|
package buildfeatures
|
||||||
|
|
||||||
|
// HasLinkSpeed is whether the binary was built with support for modular feature "Set link speed on TUN device for better OS integration (Linux only)".
|
||||||
|
// Specifically, it's whether the binary was NOT built with the "ts_omit_linkspeed" build tag.
|
||||||
|
// It's a const so it can be used for dead code elimination.
|
||||||
|
const HasLinkSpeed = false
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
// Code generated by gen.go; DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build !ts_omit_linkspeed
|
||||||
|
|
||||||
|
package buildfeatures
|
||||||
|
|
||||||
|
// HasLinkSpeed is whether the binary was built with support for modular feature "Set link speed on TUN device for better OS integration (Linux only)".
|
||||||
|
// Specifically, it's whether the binary was NOT built with the "ts_omit_linkspeed" build tag.
|
||||||
|
// It's a const so it can be used for dead code elimination.
|
||||||
|
const HasLinkSpeed = true
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
//go:build linux && !android && !ts_omit_linkspeed
|
||||||
|
|
||||||
|
package condregister
|
||||||
|
|
||||||
|
import _ "tailscale.com/feature/linkspeed"
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
// Package linkspeed registers support for setting the TUN link speed on Linux,
|
||||||
|
// to better integrate with system monitoring tools.
|
||||||
|
package linkspeed
|
||||||
@ -1,17 +1,22 @@
|
|||||||
// Copyright (c) Tailscale Inc & AUTHORS
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
//go:build !android
|
//go:build linux && !android
|
||||||
|
|
||||||
package tstun
|
package linkspeed
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mdlayher/genetlink"
|
"github.com/mdlayher/genetlink"
|
||||||
"github.com/mdlayher/netlink"
|
"github.com/mdlayher/netlink"
|
||||||
"github.com/tailscale/wireguard-go/tun"
|
"github.com/tailscale/wireguard-go/tun"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
"tailscale.com/net/tstun"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
tstun.HookSetLinkAttrs.Set(setLinkAttrs)
|
||||||
|
}
|
||||||
|
|
||||||
// setLinkSpeed sets the advertised link speed of the TUN interface.
|
// setLinkSpeed sets the advertised link speed of the TUN interface.
|
||||||
func setLinkSpeed(iface tun.Device, mbps int) error {
|
func setLinkSpeed(iface tun.Device, mbps int) error {
|
||||||
name, err := iface.Name()
|
name, err := iface.Name()
|
||||||
@ -1,12 +0,0 @@
|
|||||||
// Copyright (c) Tailscale Inc & AUTHORS
|
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
|
|
||||||
//go:build !linux || android
|
|
||||||
|
|
||||||
package tstun
|
|
||||||
|
|
||||||
import "github.com/tailscale/wireguard-go/tun"
|
|
||||||
|
|
||||||
func setLinkAttrs(iface tun.Device) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue