Skip to content

Commit

Permalink
Add detailed debug messages for device setup functions
Browse files Browse the repository at this point in the history
  • Loading branch information
buty4649 committed Apr 18, 2024
1 parent 1f622e4 commit d009cea
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func SetNetns(name string, netns string) error {
}

func SetupLoopback(netns string, ethernet config.Ethernet) error {
slog.Debug("setup loopback", "netns", netns, "addresses", ethernet.Addresses, "routes", ethernet.Routes)
slog.Debug("setup loopback device", "netns", netns, "addresses", ethernet.Addresses, "routes", ethernet.Routes)

n := ip.IntoNetns(netns)
return SetupDevice(n, "lo", ethernet.Addresses, ethernet.Routes)
Expand All @@ -194,6 +194,8 @@ func SetupLoopback(netns string, ethernet config.Ethernet) error {
func SetupEthernets(netns string, ethernets map[string]config.Ethernet) error {
n := ip.IntoNetns(netns)
for name, values := range ethernets {
slog.Debug("setup ethernet device", "netns", netns, "name", name, "addresses", values.Addresses, "routes", values.Routes)

_, err := n.ShowLink(name)
if err == nil {
slog.Debug("device is already exists in netns", "name", name, "netns", netns)
Expand All @@ -219,6 +221,8 @@ func SetupEthernets(netns string, ethernets map[string]config.Ethernet) error {
func SetupDummyDevices(netns string, devices map[string]config.Ethernet) error {
n := ip.IntoNetns(netns)
for name, values := range devices {
slog.Debug("setup dummy device", "netns", netns, "name", name, "addresses", values.Addresses, "routes", values.Routes)

_, err := n.ShowLink(name)
if err == nil {
slog.Debug("device is already exists in netns", "name", name, "netns", netns)
Expand Down Expand Up @@ -248,6 +252,9 @@ func SetupVethDevices(netns string, devices map[string]config.VethDevice) error
peerName := values.Peer.Name
peerNetns := values.Peer.Netns

slog.Debug("setup veth device", "netns", netns, "name", name, "addresses", values.Addresses, "routes", values.Routes,
"peer name", peerName, "peer netns", peerNetns, "peer addresses", values.Peer.Addresses, "peer routes", values.Peer.Routes)

// check if device is already exists in netns
_, err := n.ShowLink(name)
if err == nil {
Expand Down

0 comments on commit d009cea

Please sign in to comment.