mirror of
https://github.com/rancher/os.git
synced 2025-08-31 22:32:14 +00:00
dhcpcd crashes when calling --release too often, or together with other commands
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
@@ -210,9 +210,13 @@ func RunDhcp(netCfg *NetworkConfig, setHostname, setDNS bool) error {
|
||||
wg.Add(1)
|
||||
go func(iface string, match InterfaceConfig) {
|
||||
if match.DHCP {
|
||||
// retrigger, perhaps we're running this to get the new address
|
||||
runDhcp(netCfg, iface, match.DHCPArgs, setHostname, setDNS)
|
||||
} else {
|
||||
runDhcp(netCfg, iface, dhcpReleaseCmd, false, true)
|
||||
if hasDhcp(iface) {
|
||||
log.Infof("dhcp release %s", iface)
|
||||
runDhcp(netCfg, iface, dhcpReleaseCmd, false, true)
|
||||
}
|
||||
}
|
||||
wg.Done()
|
||||
}(name, match)
|
||||
@@ -222,6 +226,17 @@ func RunDhcp(netCfg *NetworkConfig, setHostname, setDNS bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func hasDhcp(iface string) bool {
|
||||
cmd := exec.Command("dhcpcd", "-U", iface)
|
||||
//cmd.Stderr = os.Stderr
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
log.Debugf("dhcpcd -u %s: %s", iface, out)
|
||||
return len(out) > 0
|
||||
}
|
||||
|
||||
func runDhcp(netCfg *NetworkConfig, iface string, argstr string, setHostname, setDNS bool) {
|
||||
args := []string{}
|
||||
if argstr != "" {
|
||||
|
Reference in New Issue
Block a user