MCPcopy Create free account
hub / github.com/Mirantis/cri-dockerd / interfaceExists

Method interfaceExists

network/bandwidth/linux.go:234–250  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

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.
234func (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
252func (t *tcShaper) ReconcileCIDR(cidr string, upload, download *resource.Quantity) error {
253 _, found, err := t.findCIDRClass(cidr)

Callers 1

ReconcileInterfaceMethod · 0.95

Calls 3

lenFunction · 0.85
CombinedOutputMethod · 0.65
CommandMethod · 0.65

Tested by

no test coverage detected