git://git.halfball.org
/
cni.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c338807
)
dhcp: detect if link is down and attempt to set up
author
Stefan Junker
<mail@stefanjunker.de>
Thu, 19 Nov 2015 10:08:04 +0000
(11:08 +0100)
committer
Stefan Junker
<mail@stefanjunker.de>
Thu, 19 Nov 2015 10:11:32 +0000
(11:11 +0100)
With this we still get the "network is down" error, but after the 2nd
retry the interface is up and the dhcp request works.
plugins/ipam/dhcp/lease.go
patch
|
blob
|
history
diff --git
a/plugins/ipam/dhcp/lease.go
b/plugins/ipam/dhcp/lease.go
index
c8bfb8d
..
90c223c
100644
(file)
--- a/
plugins/ipam/dhcp/lease.go
+++ b/
plugins/ipam/dhcp/lease.go
@@
-118,6
+118,13
@@
func (l *DHCPLease) acquire() error {
}
defer c.Close()
+ if (l.link.Attrs().Flags & net.FlagUp) != net.FlagUp {
+ log.Printf("Link %q down. Attempting to set up", l.link.Attrs().Name)
+ if err = netlink.LinkSetUp(l.link); err != nil {
+ return err
+ }
+ }
+
pkt, err := backoffRetry(func() (*dhcp4.Packet, error) {
ok, ack, err := c.Request()
switch {