Skip to content

Commit

Permalink
network: set name based on path if no uevent file
Browse files Browse the repository at this point in the history
On WSL, there is no uevent file, so we take the name based on the path
instead.
  • Loading branch information
powersj committed Dec 27, 2020
1 parent a9af32f commit eef8df8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path"
"path/filepath"
"sort"
"strings"

Expand Down Expand Up @@ -87,11 +88,15 @@ func (p *Probe) probe() error {
}

var uevent map[string]string = p.sys.UEvent(path)
var name string = uevent["INTERFACE"]
if name == "" {
name = filepath.Base(path)
}

switch {
case uevent["DEVTYPE"] == "bridge":
var bridge Bridge = Bridge{
Name: uevent["INTERFACE"],
Name: name,
MAC: p.MAC(path),
MTU: p.MTU(path),
Path: path,
Expand All @@ -100,7 +105,7 @@ func (p *Probe) probe() error {
p.Bridges = append(p.Bridges, bridge)
case virtualDev:
var virtual Virtual = Virtual{
Name: uevent["INTERFACE"],
Name: name,
MAC: p.MAC(path),
MTU: p.MTU(path),
Path: path,
Expand All @@ -109,7 +114,7 @@ func (p *Probe) probe() error {
p.Virtual = append(p.Virtual, virtual)
default:
var adapter Adapter = Adapter{
Name: uevent["INTERFACE"],
Name: name,
MAC: p.MAC(path),
Speed: p.Speed(path),
MTU: p.MTU(path),
Expand Down

0 comments on commit eef8df8

Please sign in to comment.