| 262 | } |
| 263 | |
| 264 | func (t *tcShaper) ReconcileInterface() error { |
| 265 | exists, output, err := t.interfaceExists() |
| 266 | if err != nil { |
| 267 | return err |
| 268 | } |
| 269 | if !exists { |
| 270 | logrus.Info("Didn't find bandwidth interface, creating") |
| 271 | return t.initializeInterface() |
| 272 | } |
| 273 | fields := strings.Split(output, " ") |
| 274 | if len(fields) < 12 || fields[1] != "htb" || fields[2] != "1:" { |
| 275 | if err := t.deleteInterface(fields[2]); err != nil { |
| 276 | return err |
| 277 | } |
| 278 | return t.initializeInterface() |
| 279 | } |
| 280 | return nil |
| 281 | } |
| 282 | |
| 283 | func (t *tcShaper) initializeInterface() error { |
| 284 | return t.execAndLog("tc", "qdisc", "add", "dev", t.iface, "root", "handle", "1:", "htb", "default", "30") |