Skip to content

Commit

Permalink
Merge pull request tylertreat#39 from wulczer/fix-stopping-when-ipv6-…
Browse files Browse the repository at this point in the history
…disabled

Fix stopping on systems that have an ip6tables command, but no IPv6
  • Loading branch information
tylertreat committed Oct 27, 2015
2 parents d564510 + 251d923 commit 6ad4e28
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions throttler/tc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package throttler

import (
"fmt"
"os/exec"
"strconv"
"strings"
"syscall"
)

const (
Expand Down Expand Up @@ -217,6 +219,19 @@ func delIptablesRules(cfg *Config, c commander) error {
}
lines, err := c.executeGetLines(fmt.Sprintf(iptList, iptablesCommand))
if err != nil {
// ignore exit code 3 from iptables, which might happen if the system
// has the ip6tables command, but no IPv6 capabilities
werr, ok := err.(*exec.ExitError)
if !ok {
return err
}
status, ok := werr.Sys().(syscall.WaitStatus)
if !ok {
return err
}
if status.ExitStatus() == 3 {
continue
}
return err
}

Expand Down

0 comments on commit 6ad4e28

Please sign in to comment.