tests to see if an interface exists, if it does, return true and the status line for the interface returns false, "", if an error occurs.
()
| 232 | // tests to see if an interface exists, if it does, return true and the status line for the interface |
| 233 | // returns false, "", <err> if an error occurs. |
| 234 | func (t *tcShaper) interfaceExists() (bool, string, error) { |
| 235 | data, err := t.e.Command("tc", "qdisc", "show", "dev", t.iface).CombinedOutput() |
| 236 | if err != nil { |
| 237 | return false, "", err |
| 238 | } |
| 239 | value := strings.TrimSpace(string(data)) |
| 240 | if len(value) == 0 { |
| 241 | return false, "", nil |
| 242 | } |
| 243 | // Newer versions of tc and/or the kernel return the following instead of nothing: |
| 244 | // qdisc noqueue 0: root refcnt 2 |
| 245 | fields := strings.Fields(value) |
| 246 | if len(fields) > 1 && fields[1] == "noqueue" { |
| 247 | return false, "", nil |
| 248 | } |
| 249 | return true, value, nil |
| 250 | } |
| 251 | |
| 252 | func (t *tcShaper) ReconcileCIDR(cidr string, upload, download *resource.Quantity) error { |
| 253 | _, found, err := t.findCIDRClass(cidr) |
no test coverage detected