@@ -55,6 +55,7 @@ datapath of old kernel versions (https://github.com/weaveworks/weave/issues/1577
55
55
56
56
const (
57
57
WeaveBridgeName = "weave"
58
+ WeaveDummyIfName = "vethwedu"
58
59
DatapathName = "datapath"
59
60
DatapathIfName = "vethwe-datapath"
60
61
BridgeIfName = "vethwe-bridge"
@@ -328,8 +329,8 @@ func (b bridgeImpl) initPrep(config *BridgeConfig) error {
328
329
// instead we create a temporary interface with the desired MTU,
329
330
// attach that to the bridge, and then remove it again.
330
331
dummy := & netlink.Dummy {LinkAttrs : netlink .NewLinkAttrs ()}
331
- dummy .LinkAttrs .Name = "vethwedu"
332
- if err = netlink . LinkAdd (dummy ); err != nil {
332
+ dummy .LinkAttrs .Name = WeaveDummyIfName
333
+ if err = LinkAddIfNotExist (dummy ); err != nil {
333
334
return errors .Wrap (err , "creating dummy interface" )
334
335
}
335
336
if err := netlink .LinkSetMTU (dummy , config .MTU ); err != nil {
@@ -338,11 +339,16 @@ func (b bridgeImpl) initPrep(config *BridgeConfig) error {
338
339
if err := netlink .LinkSetMasterByIndex (dummy , b .bridge .Attrs ().Index ); err != nil {
339
340
return errors .Wrap (err , "setting dummy interface master" )
340
341
}
341
- if err := netlink .LinkDel (dummy ); err != nil {
342
- return errors .Wrap (err , "deleting dummy interface" )
343
- }
344
-
345
- return nil
342
+ defer func () {
343
+ var dummyIf netlink.Link
344
+ dummyIf , err = netlink .LinkByName (WeaveDummyIfName )
345
+ if err == nil {
346
+ if err = netlink .LinkDel (dummyIf ); err != nil {
347
+ err = errors .Wrap (err , "deleting dummy interface" )
348
+ }
349
+ }
350
+ }()
351
+ return err
346
352
}
347
353
348
354
func (b bridgeImpl ) init (config * BridgeConfig ) error {
0 commit comments