Skip to content

Commit 5ca635a

Browse files
benokolljanat
authored andcommitted
Fix #205: Multiple DHCP network interfaces fail to initialize
1 parent 29a661b commit 5ca635a

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

pkg/netconf/netconf_linux.go

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"os/exec"
99
"strconv"
1010
"strings"
11-
"sync"
1211
"syscall"
1312

1413
"github.com/burmilla/os/pkg/log"
@@ -185,23 +184,19 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig, userSetHostname, userSetDNS bool
185184
return false, err
186185
}
187186

188-
wg := sync.WaitGroup{}
189-
190187
//apply network config
191188
for _, link := range links {
192189
if !strings.Contains(link.Attrs().Name, "wlan") {
193-
applyOuter(link, netCfg, &wg, userSetHostname, userSetDNS)
190+
applyOuter(link, netCfg, userSetHostname, userSetDNS)
194191
}
195192
}
196-
wg.Wait()
197193

198194
// apply wifi network config
199195
for _, link := range links {
200196
if strings.Contains(link.Attrs().Name, "wlan") {
201-
applyOuter(link, netCfg, &wg, userSetHostname, userSetDNS)
197+
applyOuter(link, netCfg, userSetHostname, userSetDNS)
202198
}
203199
}
204-
wg.Wait()
205200

206201
// make sure there was a DHCP set dns - or tell ros to write 8.8.8.8,8.8.8.4
207202
log.Infof("Checking to see if DNS was set by DHCP")
@@ -219,7 +214,7 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig, userSetHostname, userSetDNS bool
219214
return dnsSet, nil
220215
}
221216

222-
func applyOuter(link netlink.Link, netCfg *NetworkConfig, wg *sync.WaitGroup, userSetHostname, userSetDNS bool) {
217+
func applyOuter(link netlink.Link, netCfg *NetworkConfig, userSetHostname, userSetDNS bool) {
223218
linkName := link.Attrs().Name
224219
log.Debugf("applyOuter(%v, %v), link: %s", userSetHostname, userSetDNS, linkName)
225220
match, ok := findMatch(link, netCfg)
@@ -249,20 +244,16 @@ func applyOuter(link netlink.Link, netCfg *NetworkConfig, wg *sync.WaitGroup, us
249244
return
250245
}
251246

252-
wg.Add(1)
253-
go func(link netlink.Link, match InterfaceConfig) {
254-
if match.DHCP {
255-
if match.WifiNetwork != "" {
256-
runWifiDhcp(netCfg, link, match.WifiNetwork, !userSetHostname, !userSetDNS)
257-
} else {
258-
runDhcp(netCfg, link.Attrs().Name, match.DHCPArgs, !userSetHostname, !userSetDNS)
259-
}
247+
if match.DHCP {
248+
if match.WifiNetwork != "" {
249+
runWifiDhcp(netCfg, link, match.WifiNetwork, !userSetHostname, !userSetDNS)
260250
} else {
261-
log.Infof("dhcp release %s", link.Attrs().Name)
262-
runDhcp(netCfg, link.Attrs().Name, dhcpReleaseCmd, false, true)
251+
runDhcp(netCfg, link.Attrs().Name, match.DHCPArgs, !userSetHostname, !userSetDNS)
263252
}
264-
wg.Done()
265-
}(link, match)
253+
} else {
254+
log.Infof("dhcp release %s", link.Attrs().Name)
255+
runDhcp(netCfg, link.Attrs().Name, dhcpReleaseCmd, false, true)
256+
}
266257
}
267258

268259
func GetDhcpLease(iface string) (lease map[string]string) {

0 commit comments

Comments
 (0)