Skip to content

Commit

Permalink
Refactor SetupDevice to handle SetLinkUp internally
Browse files Browse the repository at this point in the history
  • Loading branch information
buty4649 committed Mar 20, 2024
1 parent 472e654 commit 236ce01
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ var applyCmd = &cobra.Command{
}

func SetupDevice(name string, addresses []string) error {
err := SetLinkUp(name)
if err != nil {
return err
}

slog.Info("add addresses", "name", name, "addresses", addresses)

for _, address := range addresses {
Expand All @@ -78,12 +83,11 @@ func SetupDevice(name string, addresses []string) error {
return err
}
}

return SetLinkUp(name)
return nil
}

func SetLinkUp(name string) error {
slog.Info("link up", "name", "lo", "netns", ip.Netns())
slog.Info("link up", "name", name, "netns", ip.Netns())

return ip.SetLinkUp(name)
}
Expand Down Expand Up @@ -148,11 +152,7 @@ func SetupVethDevices(netns string, devices map[string]config.VethDeviceConfig)
return err
}
ip.IntoNetns(netns, func() error {
err = SetupDevice(peerName, values.Peer.Addresses)
if err != nil {
return err
}
return nil
return SetupDevice(peerName, values.Peer.Addresses)
})
} else {
SetupDevice(peerName, values.Peer.Addresses)
Expand Down

0 comments on commit 236ce01

Please sign in to comment.