From ffeb13abd5a5debbd4f06e90314dc813c13b9e15 Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Tue, 5 Jul 2022 12:11:35 +0200 Subject: [PATCH] change tc instead of replacing it --- config.yaml | 1 - main.go | 16 +--------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/config.yaml b/config.yaml index 81f9323..60b9f84 100644 --- a/config.yaml +++ b/config.yaml @@ -8,6 +8,5 @@ ppp: 5 conformation_ppp: 30 log_level: DEBUG upload_interface: "enp1s0f1" -cake_options: "docsis diffserv4 ack-filter nat" throttle_ping_threshold: 50 try_restoring_after: 30 \ No newline at end of file diff --git a/main.go b/main.go index 5450966..997140c 100644 --- a/main.go +++ b/main.go @@ -12,7 +12,6 @@ import ( "os/signal" "regexp" "strconv" - "strings" "syscall" "time" ) @@ -29,7 +28,6 @@ type Conf struct { ConformationPPP int `yaml:"conformation_ppp"` LogLevel string `yaml:"log_level"` UploadInterface string `yaml:"upload_interface"` - CakeOptions string `yaml:"cake_options"` ThrottlePingThreshold int64 `yaml:"throttle_ping_threshold"` TryRestoringAfter int `yaml:"try_restoring_after"` } @@ -62,10 +60,7 @@ func (m UploadManager) Upload() (int, error) { } func (m UploadManager) SetUpload(upload int) (int, error) { - m.clearTC() - args := []string{"qdisc", "add", "dev", conf.UploadInterface, "root", "cake", "bandwidth", fmt.Sprintf("%dMbit", upload)} - args = append(args, strings.Split(conf.CakeOptions, " ")...) - tcCmd := exec.Command("tc", args...) + tcCmd := exec.Command("tc", "qdisc", "change", "dev", conf.UploadInterface, "root", "cake", "bandwidth", fmt.Sprintf("%dMbit", upload)) log.Debugf("[TC] exec %s", tcCmd.String()) out, err := tcCmd.CombinedOutput() if err != nil { @@ -75,15 +70,6 @@ func (m UploadManager) SetUpload(upload int) (int, error) { return upload, nil } -func (m UploadManager) clearTC() { - tcCmd := exec.Command("tc", "qdisc", "del", "dev", conf.UploadInterface, "root") - log.Debugf("[TC] exec %s", tcCmd.String()) - out, err := tcCmd.CombinedOutput() - if err != nil { - log.Debugf("[TC] executing %s failed with: %v (%s)", tcCmd.String(), err, out) - } -} - func doPing(host string, count int, interval time.Duration) (*ping.Statistics, error) { log.Debugf("[PING] starting to ping %s with %d packages", host, count) pinger, err := ping.NewPinger(host)