Skip to content

Commit

Permalink
Print NIC hardware address
Browse files Browse the repository at this point in the history
It helps with debugging in case if a host has multiple network cards

Issue #155
  • Loading branch information
anatol committed Aug 6, 2022
1 parent f8fa101 commit 47227ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
10 changes: 9 additions & 1 deletion init/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,19 @@ func shutdownNetwork() {
var initializedIfnames []string

func initializeNetworkInterface(ifname string) error {
debug("%s: start initializing network interface", ifname)
link, err := netlink.LinkByName(ifname)
if err != nil {
return err
}
hardwareAddr := link.Attrs().HardwareAddr
debug("detected network interface %s (%s)", ifname, hardwareAddr)

if len(config.Network.Interfaces) > 0 {
if !macListContains(hardwareAddr, config.Network.Interfaces) {
info("interface %s (%s) is not in 'active' list, skipping it", ifname, hardwareAddr)
return nil
}
}

ch := make(chan netlink.LinkUpdate)
done := make(chan struct{})
Expand Down
13 changes: 0 additions & 13 deletions init/udev.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"fmt"
"io"
"net"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -123,18 +122,6 @@ func handleNetworkUevent(ev *uevent.Uevent) error {
return nil
}

if len(config.Network.Interfaces) > 0 {
i, err := net.InterfaceByName(ifname)
if err != nil {
return err
}

if !macListContains(i.HardwareAddr, config.Network.Interfaces) {
info("interface %s is not in 'active' list, skipping it", ifname)
return nil
}
}

return initializeNetworkInterface(ifname)
}

Expand Down

0 comments on commit 47227ac

Please sign in to comment.